forked from joncrlsn/pgdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·65 lines (60 loc) · 1.93 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
#!/bin/bash -x
#
# For OSX and Linux, this script:
# * builds pgdiff
# * downloads pgrun
# * combines them and pgdiff.sh into a tgz file
#
SCRIPT_DIR="$(dirname `ls -l $0 | awk '{ print $NF }'`)"
[[ -z $APPNAME ]] && APPNAME=pgdiff
if [[ -d bin-linux ]]; then
echo " ==== Building Linux ===="
tempdir="$(mktemp -d)"
workdir="$tempdir/$APPNAME"
echo $workdir
mkdir -p $workdir
# Build the executable
GOOS=linux GOARCH=386 go build -o "$workdir/$APPNAME"
# Download pgrun to the temp directory
wget -O "$workdir/pgrun" "https://github.com/joncrlsn/pgrun/raw/master/bin-linux/pgrun"
# Copy the bash runtime script to the temp directory
cp pgdiff.sh "$workdir/"
cd "$tempdir"
# Make everything executable
chmod -v ugo+x $APPNAME/*
COPYFILE_DISABLE=true tar -cvzf "${APPNAME}.tgz" $APPNAME
cd -
mv "${tempdir}/${APPNAME}.tgz" "${SCRIPT_DIR}/bin-linux/"
echo "Built linux."
else
echo "Skipping linux. No bin-linux directory."
fi
if [[ -d bin-osx ]]; then
echo " ==== Building OSX ===="
tempdir="$(mktemp -d)"
workdir="$tempdir/$APPNAME"
echo $workdir
mkdir -p $workdir
# Build the executable
GOOS=darwin GOARCH=386 go build -o "$workdir/$APPNAME"
# Download pgrun to the work directory
wget -O "$workdir/pgrun" "https://github.com/joncrlsn/pgrun/raw/master/bin-osx/pgrun"
# Copy the bash runtime script to the temp directory
cp pgdiff.sh "$workdir/"
cd "$tempdir"
# Make everything executable
chmod -v ugo+x $APPNAME/*
COPYFILE_DISABLE=true tar -cvzf "${APPNAME}.tgz" $APPNAME
cd -
mv "${tempdir}/${APPNAME}.tgz" "${SCRIPT_DIR}/bin-osx/"
echo "Built osx."
else
echo "Skipping osx. No bin-osx directory."
fi
if [[ -d bin-win ]]; then
echo " ==== Building Windows ===="
GOOS=windows GOARCH=386 go build -o bin-win/${APPNAME}.exe
echo "Built win."
else
echo "Skipping win. No bin-win directory."
fi