forked from flightaware/piaware_builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensible-build.sh
executable file
·200 lines (173 loc) · 7.01 KB
/
sensible-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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
set -e
TOP=`dirname $0`
export DEBFULLNAME="${DEBFULLNAME:-FlightAware build automation}"
export DEBEMAIL="${DEBEMAIL:[email protected]}"
shallow_clone() {
repo=$1
branch=$2
target=$3
echo "Retrieving $branch from $repo"
rm -fr $target
git clone -c advice.detachedHead=false --depth=1 --branch $branch $repo $target
(cd $target && git checkout --detach $branch)
(cd $target && git --no-pager log -1 --oneline)
}
usage() {
echo "syntax: $0 <buster|bullseye|bookworm>" >&2
exit 1
}
# setup:
if [ $# -lt 1 ]
then
usage
fi
dist="$1"
case $dist in
stretch)
# EOL, not tested
debdist=stretch
targetdist=stretch-backports
extraversion="~bpo9+"
;;
buster)
debdist=buster
targetdist=buster-backports
extraversion="~bpo10+"
;;
bullseye)
debdist=bullseye
targetdist=bullseye
extraversion="~bpo11+"
;;
bookworm)
debdist=bookworm
targetdist=bookworm
extraversion=""
;;
xenial)
# not tested
debdist=stretch
targetdist=xenial
extraversion="~ubuntu1604+"
;;
bionic)
# not tested
debdist=buster
targetdist=bionic
extraversion="~ubuntu1804+"
;;
disco)
# not tested
debdist=buster
targetdist=disco
extraversion="~ubuntu1904+"
;;
*)
echo "unknown build distribution $1" >&2
usage
;;
esac
if [ -z "$2" ]
then
OUTDIR=$TOP/package-$dist
else
OUTDIR="$2"
fi
mkdir -p $OUTDIR
mkdir -p $OUTDIR/archives
shallow_clone https://github.com/flightaware/piaware.git v9.0.1 $OUTDIR/piaware
shallow_clone https://github.com/flightaware/tcllauncher.git v1.10 $OUTDIR/tcllauncher
shallow_clone https://github.com/flightaware/dump1090.git v9.0 $OUTDIR/dump1090
shallow_clone https://github.com/mutability/mlat-client.git v0.2.13 $OUTDIR/mlat-client
shallow_clone https://github.com/flightaware/dump978.git v9.0 $OUTDIR/dump978
fetch_archive() {
name=$1
url=$2
hash=$3
if [ ! -f $OUTDIR/archives/$name.tar.gz ]; then
echo "Fetching $name .."
wget -nv -O $OUTDIR/archives/$name.tar.gz.unchecked --prefer-family=IPv4 --connect-timeout=30 $url
echo "$hash $OUTDIR/archives/$name.tar.gz.unchecked" | sha256sum -c -
mv $OUTDIR/archives/$name.tar.gz.unchecked $OUTDIR/archives/$name.tar.gz
fi
rm -fr $OUTDIR/$name/
tar -C $OUTDIR -zxf $OUTDIR/archives/$name.tar.gz $name/
if [ -f $TOP/$name.patch ]; then
echo "applying $name.patch .."
patch -d $OUTDIR/$name -p1 <$TOP/$name.patch
fi
}
# get cxfreeze version and dependencies matching the system python version
# this is a bit of a nightmare due to interactions between Debian / venv / pip / setuptools et al
# the simplest approach seems to be:
# - use a venv with system site packages and no pip
# - install packages via setup.py; patch setup.cfg on some packages so that the version is set,
# as we're missing the metadata stuff that pip will do via setuptools_scm
case $debdist in
stretch)
# stretch has Python 3.5; cx-freeze 6.3 is the last version supporting Python 3.5
fetch_archive importlib_metadata-2.1.2 \
https://files.pythonhosted.org/packages/6a/3d/21c1170a955a3ae8f5cdec1d89c57d3b146ed0436b25b83e98917af5fe18/importlib_metadata-2.1.2.tar.gz \
09db40742204610ef6826af16e49f0479d11d0d54687d0169ff7fddf8b3f557f
fetch_archive zipp-0.5.0 \
https://files.pythonhosted.org/packages/44/65/799bbac4c284c93ce9cbe67956a3625a4e1941d580832656bea202554117/zipp-0.5.0.tar.gz \
d7ac25f895fb65bff937b381353c14eb1fa23d35f40abd72a5342cd57eb57fd1
fetch_archive cx_Freeze-6.3 \
https://github.com/anthony-tuininga/cx_Freeze/archive/6.3.tar.gz \
ac6212e44e072869de5153dd81e5d1c369b2ef73e75ed58cbb81ab59b4eaf6e1
;;
buster)
# Buster has Python 3.7; cx_Freeze 6.8.3 supports this
# typing_extensions need updating on python <3.8
fetch_archive typing_extensions-3.6.5 \
https://files.pythonhosted.org/packages/a9/b0/c98f86c94706784699bff1262506ceab6e8101386e984a773b10be7500fc/typing_extensions-3.6.5.tar.gz \
1c0a8e3b4ce55207a03dd0dcb98bc47a704c71f14fe4311ec860cc8af8f4bd27
fetch_archive importlib_metadata-4.3.1 \
https://files.pythonhosted.org/packages/a4/8b/1d63614ef7ced52a7da2d40753968c40a4bbc14fd9c0ba85d612b44ffd9a/importlib_metadata-4.3.1.tar.gz \
2d932ea08814f745863fd20172fe7de4794ad74567db78f2377343e24520a5b6
fetch_archive zipp-0.5.0 \
https://files.pythonhosted.org/packages/44/65/799bbac4c284c93ce9cbe67956a3625a4e1941d580832656bea202554117/zipp-0.5.0.tar.gz \
d7ac25f895fb65bff937b381353c14eb1fa23d35f40abd72a5342cd57eb57fd1
fetch_archive cx_Freeze-6.8.3 \
https://github.com/anthony-tuininga/cx_Freeze/archive/6.8.3.tar.gz \
d39c59fdfc82106dfe1e5dce09f2537a3cc82dc8295024f40f639d94193979c3
;;
bullseye)
# Bullseye has Python 3.9; cx_Freeze 6.8.3 supports this
fetch_archive importlib_metadata-4.3.1 \
https://files.pythonhosted.org/packages/a4/8b/1d63614ef7ced52a7da2d40753968c40a4bbc14fd9c0ba85d612b44ffd9a/importlib_metadata-4.3.1.tar.gz \
2d932ea08814f745863fd20172fe7de4794ad74567db78f2377343e24520a5b6
fetch_archive zipp-0.5.0 \
https://files.pythonhosted.org/packages/44/65/799bbac4c284c93ce9cbe67956a3625a4e1941d580832656bea202554117/zipp-0.5.0.tar.gz \
d7ac25f895fb65bff937b381353c14eb1fa23d35f40abd72a5342cd57eb57fd1
fetch_archive cx_Freeze-6.8.3 \
https://github.com/anthony-tuininga/cx_Freeze/archive/6.8.3.tar.gz \
d39c59fdfc82106dfe1e5dce09f2537a3cc82dc8295024f40f639d94193979c3
;;
bookworm)
fetch_archive cx_Freeze-6.15.9 \
https://github.com/marcelotduarte/cx_Freeze/archive/refs/tags/6.15.9.tar.gz \
d32b309b355f2b377dae585a839e39e3251b3f9716f2b4983be92972c2863000
;;
esac
# copy our control files
rm -fr $OUTDIR/debian
mkdir $OUTDIR/debian
cp -r \
$TOP/changelog \
$TOP/common/* \
$TOP/$debdist/* \
$OUTDIR/debian
# copy over the init.d / systemd files from the piaware source
cp $OUTDIR/piaware/scripts/piaware-rc-script $OUTDIR/debian/piaware.init
cp $OUTDIR/piaware/scripts/piaware.service $OUTDIR/debian/piaware.piaware.service
cp $OUTDIR/piaware/scripts/generate-pirehose-cert.service $OUTDIR/debian/piaware.generate-pirehose-cert.service
if [ -n "$extraversion" ]
then
echo "Updating changelog for $targetdist build"
dch --changelog $OUTDIR/debian/changelog --local "$extraversion" --distribution "$targetdist" --force-distribution "Automated backport build via piaware_builder"
fi
# ok, ready to go.
echo "Ok, package is ready to be built in $OUTDIR"
echo "run 'dpkg-buildpackage -b --no-sign' there (or move it to a Pi and do so there, or use pbuilder, etc)"