Skip to content
Permalink
fc19738ea7
Go to file
 
 
Cannot retrieve contributors at this time
executable file 389 lines (361 sloc) 17.8 KB
#!/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
-o, --offline build offline after all repos have been cloned or refreshed
No options assumes building for all areas.
EOF
exit 1
}
OPTIONS=$(getopt -o hdcm::gvib:s:Do -l help,droid-hal,configs,mw::,gg,version,mic,build:,spec:,do-not-install,offline -- "$@")
if [ $? -ne 0 ]; then
echo "getopt error"
exit 1
fi
# build all if none or only --offline parameter is in the cmdline
if [[ $# -lt 2 && "$1" =~ ^(|-o|--offline)$ ]]; then
BUILDDHD=1
BUILDCONFIGS=1
BUILDMW=1
BUILDGG=1
BUILDVERSION=1
BUILDIMAGE=1
fi
eval set -- $OPTIONS
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 ;;
-o|--offline) BUILDOFFLINE=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
if [ "$BUILDOFFLINE" = "1" ]; then
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -m sdk-install zypper ref local-$DEVICE-hal
else
sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -R -m sdk-install zypper ref
fi
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
# The following two packages are pre-downgraded to match the latest SFOS release to avoid build issues
buildmw -u "https://github.com/sailfishos-oneplus5/ofono-ril-binder-plugin" || die
buildmw -u "https://github.com/sailfishos-oneplus5/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
elif [ $android_version_major -eq 8 ]; then
buildmw -u "https://github.com/sailfishos-oneplus5/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
# Additional MW for extra functionality on OnePlus 5(T) devices
if [[ "cheeseburger dumpling" = *"$DEVICE"* ]]; then
buildmw -u "https://github.com/sailfishos-oneplus5/triambience-daemon" || die
buildmw -u "https://github.com/sailfishos-oneplus5/onyx-triambience-settings-plugin" || die
buildmw -u "https://github.com/sailfishos-oneplus5/gesture-daemon" || die
buildmw -u "https://github.com/sailfishos-oneplus5/onyx-gesture-settings-plugin" || die
fi
# Setup bluez5 & droid-config packages properly during initial build_packages run
[ -f "$ANDROID_ROOT/.first_${RELEASE}_${DEVICE}_build_done" ] || sb2 -t $VENDOR-$DEVICE-$PORT_ARCH -m sdk-install -R zypper -n in bluez5-obexd droid-config-$DEVICE droid-config-$DEVICE-bluez5 kf5bluezqt-bluez5 libcommhistory-qt5 libcontacts-qt5 libical obex-capability obexd-calldata-provider obexd-contentfilter-helper qt5-qtpim-versit qtcontacts-sqlite-qt5
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=$(curl -s https://github.com/sailfishos/droidmedia/tags | grep "tag/" | head -1 | cut -d'"' -f2 | cut -d'/' -f6)
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 -qE "^- pulseaudio-modules-droid-glue|^- audioflingerglue" $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=$(curl -s https://github.com/mer-hybris/audioflingerglue/tags | grep "tag/" | head -1 | cut -d'"' -f2 | cut -d'/' -f6)
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
if grep -q "^- pulseaudio-modules-droid-glue" $pattern_lookup &>/dev/null; then
buildmw -u "https://github.com/mer-hybris/pulseaudio-modules-droid-glue.git" || die
fi
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
[ -f "$ANDROID_ROOT/.first_${RELEASE}_${DEVICE}_build_done" ] || touch "$ANDROID_ROOT/.first_${RELEASE}_${DEVICE}_build_done"
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 -qE "^- 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
You can’t perform that action at this time.