-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·91 lines (73 loc) · 2.68 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
here=$(dirname "$0")
test -n "$here" -a -d "$here" || (echo "Cannot determine build dir. FIXME!" && exit 1)
. "$here"/../base.sh # functions we use below (fail, et al)
if [ ! -z "$1" ]; then
REV="$1"
else
fail "Please specify a release tag or branch to build (eg: master or 4.0.0, etc)"
fi
if [ ! -d 'contrib' ]; then
fail "Please run this script form the top-level ViLight git directory"
fi
pushd .
docker_version=`docker --version`
if [ "$?" != 0 ]; then
echo ''
echo "Please install docker by issuing the following commands (assuming you are on Ubuntu):"
echo ''
echo '$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -'
echo '$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"'
echo '$ sudo apt-get update'
echo '$ sudo apt-get install -y docker-ce'
echo ''
fail "Docker is required to build for Windows"
fi
set -e
info "Using docker: $docker_version"
SUDO="" # on macOS (and others?) we don't do sudo for the docker commands ...
if [ $(uname) = "Linux" ]; then
# .. on Linux we do
SUDO="sudo"
fi
info "Creating docker image ..."
$SUDO docker build -t electroncash-wine-builder-img contrib/build-wine/docker \
|| fail "Failed to create docker image"
# This is the place where we checkout and put the exact revision we want to work
# on. Docker will run mapping this directory to /opt/wine64/drive_c/vilight
# which inside wine will look lik c:\vilight
FRESH_CLONE=`pwd`/contrib/build-wine/fresh_clone
FRESH_CLONE_DIR=$FRESH_CLONE/$GIT_DIR_NAME
(
$SUDO rm -fr $FRESH_CLONE && \
mkdir -p $FRESH_CLONE && \
cd $FRESH_CLONE && \
git clone $GIT_REPO && \
cd $GIT_DIR_NAME && \
git checkout $REV
) || fail "Could not create a fresh clone from git"
(
# NOTE: We propagate forward the GIT_REPO override to the container's env,
# just in case it needs to see it.
$SUDO docker run -it \
-e GIT_REPO="$GIT_REPO" \
--name electroncash-wine-builder-cont \
-v $FRESH_CLONE_DIR:/opt/wine64/drive_c/vilight \
--rm \
--workdir /opt/wine64/drive_c/vilight/contrib/build-wine \
electroncash-wine-builder-img \
./_build.sh $REV
) || fail "Build inside docker container failed"
popd
info "Copying .exe files out of our build directory ..."
mkdir -p dist/
files=$FRESH_CLONE_DIR/contrib/build-wine/dist/*.exe
for f in $files; do
bn=`basename $f`
cp -fpv $f dist/$bn || fail "Failed to copy $bn"
touch dist/$bn || fail "Failed to update timestamp on $bn"
done
info "Removing $FRESH_CLONE ..."
$SUDO rm -fr $FRESH_CLONE
echo ""
info "Done. Built .exe files have been placed in dist/"