-
Notifications
You must be signed in to change notification settings - Fork 77
/
build_packages.sh
executable file
·379 lines (352 loc) · 16.6 KB
/
build_packages.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
# build_packages.sh - takes care of rebuilding droid-hal-device, -configs, and
# -version, as well as any middleware packages. All in correct sequence, so that
# any change made (e.g. to patterns) could be simply picked up just by
# re-running this script.
#
# Copyright (c) 2015 Alin Marin Elena <alin@elena.space>
# Copyright (c) 2015 - 2019 Jolla Ltd.
# Contact: Simonas Leleiva <simonas.leleiva@jollamobile.com>
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the <organization> nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
usage() {
cat <<EOF
Usage: $0 [OPTION]..."
-h, --help you're reading it
-d, --droid-hal build droid-hal-device (rpm/)
-c, --configs build droid-configs
-m, --mw[=REPO] build HW middleware packages or REPO
-g, --gg build droidmedia, gst-droid, and audioflingerglue
-v, --version build droid-hal-version
-i, --mic build image
-b, --build=PKG build one package (PKG can include path)
-s, --spec=SPEC optionally used with -m or -b
can be supplied multiple times to build multiple .spec files at once
-D, --do-not-install
useful when package is needed only in the final image
especially when it conflicts in an SDK target
-p, --pull do \`git pull\` before building each mw repo
No options assumes building for all areas.
EOF
exit 1
}
OPTIONS=$(getopt -o hdcm::gvib:s:Dp -l help,droid-hal,configs,mw::,gg,version,mic,build:,spec:,do-not-install,pull -- "$@")
if [ $? -ne 0 ]; then
echo "getopt error"
exit 1
fi
eval set -- $OPTIONS
if [ "$#" == "1" ]; then
BUILDDHD=1
BUILDCONFIGS=1
BUILDMW=1
BUILDGG=1
BUILDVERSION=1
BUILDIMAGE=1
fi
BUILDSPEC_FILE=()
while true; do
case "$1" in
-h|--help) usage ;;
-d|--droid-hal) BUILDDHD=1 ;;
-c|--configs) BUILDCONFIGS=1 ;;
-D|--do-not-install) DO_NOT_INSTALL=1;;
-m|--mw) BUILDMW=1
BUILDMW_ASK=1
case "$2" in
*) BUILDMW_REPO=$2;;
esac
shift;;
-g|--gg) BUILDGG=1 ;;
-b|--build) BUILDPKG=1
case "$2" in
*) BUILDPKG_PATH=$2;;
esac
shift;;
-s|--spec) BUILDSPEC=1
case "$2" in
*) BUILDSPEC_FILE+=("$2");;
esac
shift;;
-v|--version) BUILDVERSION=1 ;;
-i|--mic) BUILDIMAGE=1 ;;
-p|--pull) UPDATE_MW_REPOS=1 ;;
--) shift ; break ;;
*) echo "unknown option: $1" ; exit 1 ;;
esac
shift
done
if [ $# -ne 0 ]; then
echo "unknown option(s): $@"
exit 1
fi
if [ ! -d rpm/dhd ]; then
echo $0: 'launch this script from the $ANDROID_ROOT directory'
exit 1
fi
# utilities
. ./rpm/dhd/helpers/util.sh
if [ "$BUILDDHD" = "1" ]; then
builddhd
fi
if [ -n "$(grep '%define community_adaptation' $ANDROID_ROOT/hybris/droid-configs/rpm/droid-config-$DEVICE.spec)" ]; then
community_adaptation=1
else
community_adaptation=0
fi
if [ "$BUILDCONFIGS" = "1" ]; then
if [ "$community_adaptation" == "1" ]; then
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper se -i community-adaptation > /dev/null
ret=$?
if [ $ret -eq 104 ]; then
BUILDMW_QUIET=1
buildmw -u "https://github.com/mer-hybris/community-adaptation.git" \
-s rpm/community-adaptation-localbuild.spec || die
BUILDMW_QUIET=
elif [ $ret -ne 0 ]; then
die "Could not determine if community-adaptation package is available, exiting."
fi
fi
# avoid a SIGSEGV on exit of libhybris client
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R ls /system/build.prop &> /dev/null
ret=$?
if [ $ret -ne 0 ]; then
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R bash -c "mkdir -p /system; echo ro.build.version.sdk=99 > /system/build.prop"
fi
buildconfigs
fi
if [ "$BUILDMW" = "1" ]; then
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -msdk-install ssu domain sales
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -msdk-install ssu dr sdk
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -msdk-install zypper ref
if [ "$FAMILY" == "" ]; then
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -msdk-install zypper -n install $ALLOW_UNSIGNED_RPM droid-hal-$DEVICE-devel
else
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -msdk-install zypper -n install $ALLOW_UNSIGNED_RPM droid-hal-$HABUILD_DEVICE-devel
fi
android_version_major=$(sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R cat /usr/lib/droid-devel/droid-headers/android-version.h |grep "#define.*ANDROID_VERSION_MAJOR" |sed -e "s/#define.*ANDROID_VERSION_MAJOR//g")
pushd $ANDROID_ROOT/hybris/mw > /dev/null
manifest_lookup=$ANDROID_ROOT
while true; do
manifest=$manifest_lookup/.repo/manifest.xml
if [ -f "$manifest" ] || [ "$manifest_lookup" = "$(dirname "$manifest_lookup")" ]; then
break
fi
manifest=""
manifest_lookup=$(dirname "$manifest_lookup")
done
if [ ! "$BUILDMW_REPO" = "" ]; then
# No point in asking when only one mw package is being built
BUILDMW_QUIET=1
if [ -z "$BUILDSPEC_FILE" ]; then
buildmw -u "$BUILDMW_REPO" || die
else
# Supply all given spec files from $BUILDSPEC_FILE array prefixed with "-s"
buildmw -u "$BUILDMW_REPO" "${BUILDSPEC_FILE[@]/#/-s }" || die
fi
elif [ -n "$manifest" ] &&
grep -ql hybris/mw $manifest; then
buildmw_cmds=()
bifs=$IFS
while IFS= read -r line; do
if [[ $line = *"hybris/mw"* ]]; then
IFS="= "$'\t'
for tok in $line; do
word=$(echo "$tok" | cut -d \" -f2 | cut -d \' -f2)
if [ "$preword" = "path" ]; then
if [ "$(basename $(dirname "$word"))" = "mw" ]; then
# Only build first level projects
mw=$(basename "$word")
fi
elif [ "$preword" = "spec" ]; then
spec=$word
fi
preword=$word
done
if [ ! -z "$mw" ] \
&& [ ! "$mw" = "gst-droid" ] \
&& [ ! "$mw" = "pulseaudio-modules-droid-glue" ]; then
if [ -z "$spec" ]; then
buildmw_cmds+=("$mw")
else
buildmw_cmds+=("$mw:$spec")
spec=
fi
mw=
fi
fi
done < "$manifest"
IFS=$bifs
for bcmd in "${buildmw_cmds[@]}"; do
bcmdsplit=(); while read -rd:; do bcmdsplit+=("$REPLY"); done <<< "$bcmd:"
if [ ! -z "${bcmdsplit[1]}" ]; then
buildmw -u "${bcmdsplit[0]}" -s "${bcmdsplit[1]}" || die
elif [ ! -z "${bcmdsplit[0]}" ]; then
buildmw -u "${bcmdsplit[0]}" || die
fi
done
else
buildmw -u "https://github.com/mer-hybris/libhybris" || die
if [ $android_version_major -ge 8 ]; then
buildmw -u "https://git.sailfishos.org/mer-core/libglibutil.git" || die
buildmw -u "https://github.com/mer-hybris/libgbinder" || die
buildmw -u "https://github.com/mer-hybris/libgbinder-radio" || die
buildmw -u "https://github.com/mer-hybris/bluebinder" || die
buildmw -u "https://github.com/mer-hybris/ofono-ril-binder-plugin" || die
buildmw -u "https://github.com/mer-hybris/nfcd-binder-plugin" || die
fi
buildmw -u "https://github.com/mer-hybris/pulseaudio-modules-droid.git" \
-s rpm/pulseaudio-modules-droid.spec || die
if [ $android_version_major -ge 9 ]; then
buildmw -u "https://github.com/mer-hybris/pulseaudio-modules-droid-hidl.git" || die
fi
buildmw -u "https://github.com/nemomobile/mce-plugin-libhybris.git" || die
buildmw -u "https://github.com/mer-hybris/ngfd-plugin-droid-vibrator" \
-s rpm/ngfd-plugin-native-vibrator.spec || die
buildmw -u "https://github.com/mer-hybris/qt5-feedback-haptics-droid-vibrator" \
-s rpm/qt5-feedback-haptics-native-vibrator.spec || die
buildmw -u "https://github.com/mer-hybris/qt5-qpa-hwcomposer-plugin" || die
buildmw -u "https://git.sailfishos.org/mer-core/qtscenegraph-adaptation.git" \
-s rpm/qtscenegraph-adaptation-droid.spec || die
if [ $android_version_major -ge 9 ]; then
buildmw -u "https://git.sailfishos.org/mer-core/sensorfw.git" \
-s rpm/sensorfw-qt5-binder.spec || die
else
buildmw -u "https://git.sailfishos.org/mer-core/sensorfw.git" \
-s rpm/sensorfw-qt5-hybris.spec || die
fi
if [ $android_version_major -ge 8 ]; then
buildmw -u "https://github.com/mer-hybris/geoclue-providers-hybris" \
-s rpm/geoclue-providers-hybris-binder.spec || die
else
buildmw -u "https://github.com/mer-hybris/geoclue-providers-hybris" \
-s rpm/geoclue-providers-hybris.spec || die
fi
# build kf5bluezqt-bluez4 if not yet provided by Sailfish OS itself
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper se kf5bluezqt-bluez4 > /dev/null
ret=$?
if [ $ret -eq 104 ]; then
buildmw -u "https://git.sailfishos.org/mer-core/kf5bluezqt.git" \
-s rpm/kf5bluezqt-bluez4.spec || die
# pull device's bluez4 configs correctly
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper remove bluez-configs-mer
fi
fi
popd > /dev/null
fi
if [ "$BUILDGG" = "1" ]; then
# look for either DEVICE or HABUILD_DEVICE files, do not use wildcards as there could be other variants
pattern_lookup=$(ls "$ANDROID_ROOT"/hybris/droid-configs/patterns/jolla-hw-adaptation-{$DEVICE,$HABUILD_DEVICE}.yaml 2>/dev/null)
if grep -q "^- gstreamer1.0-droid" $pattern_lookup &>/dev/null; then
droidmedia_version=$(git --git-dir external/droidmedia/.git describe --tags 2>/dev/null | sed -r "s/\-/\+/g")
if [ -z "$droidmedia_version" ]; then
# in case of shallow clone:
droidmedia_version=999.99999999.99
fi
rpm/dhd/helpers/pack_source_droidmedia-localbuild.sh "$droidmedia_version"
mkdir -p hybris/mw/droidmedia-localbuild/rpm
if [ -d .git ] && [ ! -d hybris/mw/droidmedia-localbuild/.git ]; then
# for the top-level .git adaptations such as Xperia 10 Android 9, otherwise mb2 will complain:
(cd hybris/mw/droidmedia-localbuild; git init; git commit --allow-empty -m "initial")
fi
cp rpm/dhd/helpers/droidmedia-localbuild.spec hybris/mw/droidmedia-localbuild/rpm/droidmedia.spec
sed -ie "s/0.0.0/$droidmedia_version/" hybris/mw/droidmedia-localbuild/rpm/droidmedia.spec
mv hybris/mw/droidmedia-"$droidmedia_version".tgz hybris/mw/droidmedia-localbuild
buildmw -u "droidmedia-localbuild" || die
buildmw -u "https://github.com/sailfishos/gst-droid.git" || die
else
minfo "Not building droidmedia and gstreamer1.0-droid due to the latter not being in patterns"
fi
if grep -q "^- pulseaudio-modules-droid-hidl" $pattern_lookup &>/dev/null; then
minfo "Not building audioflingerglue and pulseaudio-modules-droid-glue due to pulseaudio-modules-droid-hidl in patterns"
elif grep -q "^- pulseaudio-modules-droid-glue" $pattern_lookup &>/dev/null; then
audioflingerglue_version=$(git --git-dir external/audioflingerglue/.git describe --tags 2>/dev/null | sed -r "s/\-/\+/g")
if [ -z "$audioflingerglue_version" ]; then
# in case of shallow clone:
audioflingerglue_version=999.0.0
fi
rpm/dhd/helpers/pack_source_audioflingerglue-localbuild.sh "$audioflingerglue_version"
mkdir -p hybris/mw/audioflingerglue-localbuild/rpm
if [ -d .git ] && [ ! -d hybris/mw/audioflingerglue-localbuild/.git ]; then
# for the top-level .git adaptations such as Xperia 10 Android 9, otherwise mb2 will complain:
(cd hybris/mw/audioflingerglue-localbuild; git init; git commit --allow-empty -m "initial")
fi
cp rpm/dhd/helpers/audioflingerglue-localbuild.spec hybris/mw/audioflingerglue-localbuild/rpm/audioflingerglue.spec
sed -ie "s/0.0.0/$audioflingerglue_version/" hybris/mw/audioflingerglue-localbuild/rpm/audioflingerglue.spec
mv hybris/mw/audioflingerglue-"$audioflingerglue_version".tgz hybris/mw/audioflingerglue-localbuild
buildmw -u "audioflingerglue-localbuild" || die
buildmw -u "https://github.com/mer-hybris/pulseaudio-modules-droid-glue.git" || die
else
minfo "Not building audioflingerglue and pulseaudio-modules-droid-glue due to the latter not being in patterns"
fi
fi
if [ "$BUILDVERSION" = "1" ]; then
buildversion
echo "----------------------DONE! Now proceed on creating the rootfs------------------"
fi
if [ "$BUILDIMAGE" = "1" ]; then
ks="Jolla-@RELEASE@-$DEVICE-@ARCH@.ks"
if [ "$community_adaptation" == "1" ]; then
ha_repo="repo --name=adaptation-community-common-$DEVICE-@RELEASE@"
ha_dev="repo --name=adaptation-community-$DEVICE-@RELEASE@"
sed "/$ha_repo/i$ha_dev --baseurl=file:\/\/$ANDROID_ROOT\/droid-local-repo\/$DEVICE" \
"$ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$ks" \
> "$ks"
else
ha_repo="repo --name=adaptation0-$DEVICE-@RELEASE@"
sed -e "s|^$ha_repo.*$|$ha_repo --baseurl=file://$ANDROID_ROOT/droid-local-repo/$DEVICE|" \
"$ANDROID_ROOT/hybris/droid-configs/installroot/usr/share/kickstarts/$ks" \
> "$ks"
fi
# Clear out extra store repositories from kickstart if exist
sed -i "/store-repository.jolla.com/d" "$ks"
[ -n "$RELEASE" ] || die 'Please set the desired RELEASE variable in ~/.hadk.env to build an image for'
hybris/droid-configs/droid-configs-device/helpers/process_patterns.sh
# Check if we need to build loop or fs image
pattern_lookup=$(ls "$ANDROID_ROOT"/hybris/droid-configs/patterns/jolla-hw-adaptation-{$DEVICE,$HABUILD_DEVICE}.yaml 2>/dev/null)
if grep -q "^- droid-hal-{$DEVICE,$HABUILD_DEVICE}-kernel-modules" $pattern_lookup &>/dev/null; then
sudo mic create fs --arch=$PORT_ARCH \
--tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:"$EXTRA_NAME" \
--record-pkgs=name,url \
--outdir=sfe-$DEVICE-$RELEASE"$EXTRA_NAME" \
--pack-to=sfe-$DEVICE-$RELEASE"$EXTRA_NAME".tar.bz2 \
"$ANDROID_ROOT"/Jolla-@RELEASE@-$DEVICE-@ARCH@.ks
else
sudo mic create loop --arch=$PORT_ARCH \
--tokenmap=ARCH:$PORT_ARCH,RELEASE:$RELEASE,EXTRA_NAME:"$EXTRA_NAME" \
--record-pkgs=name,url \
--outdir=sfe-$DEVICE-$RELEASE"$EXTRA_NAME" \
--copy-kernel \
"$ANDROID_ROOT"/Jolla-@RELEASE@-$DEVICE-@ARCH@.ks
fi
fi
if [ "$BUILDPKG" = "1" ]; then
if [ -z $BUILDPKG_PATH ]; then
echo "--build requires an argument (path to package)"
else
buildpkg $BUILDPKG_PATH "${BUILDSPEC_FILE[@]}"
fi
fi