-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun-gitian
executable file
·137 lines (120 loc) · 4.1 KB
/
run-gitian
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
if [ ! -f "`dirname "$0"`/vendor/gitian-builder/bin/gbuild" ]; then
echo "Gitian-builder not found, please update submodule" 1>&2
exit 1
fi
cd "`dirname "$0"`/vendor/gitian-builder"
export PATH="$PATH:`pwd`/bin:`pwd`/libexec"
if ! `gbuild --help 1>/dev/null`; then # check if gbuild works
exit 1
fi
usage() {
echo "Usage:\t$0 [-b | -s KEY_ID | -v] [-O linux|win|osx] VERSION [builder-options]"
echo "\t$0 [-O linux|win|osx] KEY_ID VERSION [builder-options]"
echo "\t$0 --help"
echo ""
echo "-b\tbuild"
echo "-s\tsign"
echo "-v\tverify"
echo "\t(will build and sign with KEY_ID if neither option is present)"
echo "-O\tchoose target operating system linux or win, defaults to linux"
echo "--help\tdisplay this help and exit"
echo ""
echo "KEY_ID\tis the GPG key ID to use for signing"
echo "VERSION\tis the BitShares release version to build, sign or verify"
echo ""
echo "builder-options:"
gbuild --help 2>&1 | tail -n +2
echo ""
echo "You should allow at least 4G RAM for the build (-m 4096), more if"
echo "you want to build with more than one core!"
}
if [ "$1" = "--help" ]; then
usage; exit 0
fi
if [ "$#" -lt 1 ]; then
usage 1>&2; exit 1
fi
set -e
BUILD=
SIGN=
VERIFY=
OS=linux
while [ "$1" = "-b" -o "$1" = "-s" -o "$1" = "-v" -o "$1" = "-O" ]; do
case "$1" in
-b) BUILD=1; ;;
-s) SIGN=1;
if [ -z "$2" ]; then
echo "Missing argument to -s" 1>&2
exit 1
fi
KEY_ID="$2"; shift; ;;
-v) VERIFY=1; ;;
-O) if [ -z "$2" ]; then
echo "Missing argument to -O" 1>&2
exit 1
fi
OS="$2"; shift; ;;
esac
shift
done
case "$OS" in
linux|win|osx) true; ;;
*) echo "Unsupported OS '$OS', try 'linux', 'osx' or 'win' instead!" 1>&2
exit 1
;;
esac
if [ -z "$BUILD$SIGN$VERIFY" ]; then
BUILD=1
SIGN=1
if [ "$#" -lt 1 ]; then
usage 1>&2; exit 1
fi
KEY_ID="$1"
shift
fi
if [ "$#" -lt 1 ]; then
usage 1>&2; exit 1
fi
VERSION="$1"
shift
mkdir -p var
mkdir -p inputs
if [ -n "$BUILD" ]; then
if [ "$OS" = "osx" ]; then
if [ ! -r inputs/MacOSX10.15.sdk.tar.xz ]; then
echo "Please download MacOSX10.15.sdk.tar.xz and place it in `pwd`/inputs." 1>&2
echo "Also be sure to read and understand Apple's licensing terms." 1>&2
exit 1
fi
fi
tar cfz inputs/supplement.tar.gz --sort=name -C ../.. supplement
(
echo https://www.openssl.org/source/openssl-1.1.1w.tar.gz cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
echo https://curl.se/download/curl-8.6.0.tar.xz 3ccd55d91af9516539df80625f818c734dc6f2ecf9bada33c76765e99121db15
if [ "$OS" = "win" -o "$OS" = "osx" ]; then
echo https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.bz2 8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406
echo https://zlib.net/zlib-1.3.1.tar.gz 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
fi
if [ "$OS" = "osx" ]; then
echo https://github.com/tpoechtrager/osxcross/archive/50e86ebca7d14372febd0af8cd098705049161b9.tar.gz d0496d5874a3252c4df7ce24bd724e453f85c513505b970e039fd01638fc1ff7
fi
) | while read url sha; do
FILE="${url##*/}"
if [ ! -r "inputs/$FILE" ]; then
echo "Downloading $FILE..."
( cd inputs; curl -LO "$url" )
fi
sha256sum "inputs/$FILE" \
| grep -q "$sha" \
|| ( echo "inputs/$FILE is wrong!?" 1>&2 && exit 1 )
done
fi
[ -z "$BUILD" ] || (
rm -rf inputs/bitshares
gbuild "../../descriptors/bitshares-core-$OS.yml" -c bitshares="$VERSION" "$@"
)
[ -z "$SIGN" ] || gsign --signer "$KEY_ID" --destination ../../signatures --release "$VERSION"-"$OS" \
"../../descriptors/bitshares-core-$OS.yml"
[ -z "$VERIFY" ] || gverify --destination ../../signatures --release "$VERSION"-"$OS" \
"../../descriptors/bitshares-core-$OS.yml"