diff --git a/helpers/build_packages.sh b/helpers/build_packages.sh new file mode 100755 index 00000000..b74029cd --- /dev/null +++ b/helpers/build_packages.sh @@ -0,0 +1,87 @@ +#!/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 +# Copyright (C) 2015 Jolla Ltd. +# Contact: Simonas Leleiva +# +# All rights reserved. +# +# This script uses parts of code located at https://github.com/dmt4/sfa-mer +# +# 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 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 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. +# + +if [ -z $DEVICE ]; then + echo 'Error: $DEVICE is undefined. Please run hadk' + exit 1 +fi +if [[ ! -d rpm/helpers && ! -d rpm/dhd ]]; then + echo $0: launch this script from the $ANDROID_ROOT directory + exit 1 +fi + +# utilities +. $ANDROID_ROOT/rpm/dhd/helpers/util.sh + + +if [ ! -d rpm/dhd ]; then + echo "rpm/dhd/ does not exist, please run migrate first." + exit 1 +fi +LOCAL_REPO=$ANDROID_ROOT/droid-local-repo/$DEVICE +rm -rf $LOCAL_REPO/droid-hal-* +rm -rf $LOCAL_REPO/droid-config-* +builddhd +buildconfigs +echo "-------------------------------------------------------------------------------" + +read -p 'About to perform "Build HA Middleware Packages" HADK chapter. Press Enter to continue.' +sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install ssu domain sales +sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install ssu dr sdk + +sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install zypper ref -f +sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install zypper -n install droid-hal-$DEVICE-devel + +rm -rf $MER_ROOT/devel/mer-hybris +mkdir -p $MER_ROOT/devel/mer-hybris +pushd $MER_ROOT/devel/mer-hybris + +buildmw libhybris || die +sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-build zypper -n rm mesa-llvmpipe +buildmw "https://github.com/nemomobile/mce-plugin-libhybris.git" || die +buildmw ngfd-plugin-droid-vibrator || die +buildmw "https://github.com/mer-hybris/pulseaudio-modules-droid.git" rpm/pulseaudio-modules-droid.spec || die +buildmw qt5-feedback-haptics-droid-vibrator || die +buildmw qt5-qpa-hwcomposer-plugin || die +buildmw "https://github.com/mer-hybris/qtscenegraph-adaptation.git" rpm/qtscenegraph-adaptation-droid.spec || die +buildmw "https://github.com/mer-packages/qtsensors.git" || die +buildmw "https://github.com/mer-packages/sensorfw.git" rpm/sensorfw-qt5-hybris.spec || die +read -p '"Build HA Middleware Packages built". Press Enter to continue.' +popd + +buildversion +echo "----------------------DONE! Now proceed on creating the rootfs------------------" diff --git a/helpers/util.sh b/helpers/util.sh new file mode 100755 index 00000000..a2db683d --- /dev/null +++ b/helpers/util.sh @@ -0,0 +1,181 @@ +#!/bin/bash +source ~/.hadk.env + +function minfo { + echo -e "\e[01;34m* $* \e[00m" +} + +function merror { + echo -e "\e[01;31m!! $* \e[00m" +} + +function die { + if [ -z "$*" ]; then + merror "command failed at `date`, dying..." + else + merror "$*" + fi + exit 1 +} + +function die_with_log { + if [ -f "$1" ] ; then + tail -n10 "$1" + minfo "Check `pwd`/`basename $1` for full log." + fi + shift + die $* +} + +function buildconfigs() { + cd hybris/droid-configs + mb2 -t $VENDOR-$DEVICE-armv7hl \ + -s rpm/droid-config-$DEVICE.spec \ + build + mv -v RPMS/*.rpm $LOCAL_REPO || die + cd ../../ + + createrepo $LOCAL_REPO + sb2 -t $VENDOR-$DEVICE-armv7hl -R -m sdk-install \ + zypper ref +} + +function builddhd() { + mb2 -t $VENDOR-$DEVICE-armv7hl -s rpm/droid-hal-$DEVICE.spec build + + mv -v RPMS/*$DEVICE* $LOCAL_REPO + createrepo $LOCAL_REPO + + sb2 -t $VENDOR-$DEVICE-armv7hl -R -m sdk-install \ + ssu ar local-$DEVICE-hal-$1 file://$LOCAL_REPO + + sb2 -t $VENDOR-$DEVICE-armv7hl -R -m sdk-install \ + zypper ref +} + +function buildversion() { + cd hybris/droid-hal-version-$DEVICE + mb2 -t $VENDOR-$DEVICE-armv7hl \ + -s rpm/droid-hal-version-$DEVICE.spec \ + build + mv -v RPMS/*.rpm $LOCAL_REPO + cd ../../ +} + +function yesno() { + read -r -p "${1:-} [Y/n]" REPLY + REPLY=${REPLY:-y} + case $REPLY in + [yY]) + true + ;; + *) + false + ;; + esac +} + +function buildmw { + + GIT_URL="$1" + shift + + [ -z "$GIT_URL" ] && die "Please give me the git URL (or directory name, if it's already installed)." + + + PKG="$(basename ${GIT_URL%.git})" + yesno "Build $PKG?" + if [ $? == "0" ]; then + if [ "$GIT_URL" = "$PKG" ]; then + GIT_URL=https://github.com/mer-hybris/$PKG.git + minfo "No git url specified, assuming $GIT_URL" + fi + + cd "$MER_ROOT/devel/mer-hybris" || die + LOG="`pwd`/$PKG.log" + [ -f "$LOG" ] && rm "$LOG" + + if [ ! -d $PKG ] ; then + minfo "Source code directory doesn't exist, clonig repository" + git clone $GIT_URL >>$LOG 2>&1|| die_with_log "$LOG" "cloning of $GIT_URL failed" + fi + + pushd $PKG || die + minfo "pulling updates..." + git pull >>$LOG 2>&1|| die_with_log "$LOG" "pulling of updates failed" + git submodule update >>$LOG 2>&1|| die_with_log "$LOG" "pulling of updates failed" + + SPECS="$*" + if [ -z "$SPECS" ]; then + minfo "No spec files for package building specified, building all I can find." + SPECS="rpm/*.spec" + fi + + for SPEC in $SPECS ; do + minfo "Building $SPEC" + mb2 -s $SPEC -t $VENDOR-$DEVICE-armv7hl build >>$LOG 2>&1|| die_with_log "$LOG" "building of package failed" + done + minfo "Building successful, adding packages to repo" + mkdir -p "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG" >>$LOG 2>&1|| die_with_log "$LOG" + rm -f "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG/"*.rpm >>$LOG 2>&1|| die_with_log "$LOG" + mv RPMS/*.rpm "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG" >>$LOG 2>&1|| die_with_log "$LOG" + createrepo "$ANDROID_ROOT/droid-local-repo/$DEVICE" >>$LOG 2>&1|| die_with_log "$LOG" "can't create repo" + sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install zypper ref >>$LOG 2>&1|| die_with_log "$LOG" "can't update pkg info" + minfo "Building of $PKG finished successfully" + popd + fi + echo +} +function buildmwb { + + GIT_URL="$1" + shift + GIT_BRANCH="$1" + shift + + [ -z "$GIT_URL" ] && die "Please give me the git URL (or directory name, if it's already installed)." + + + PKG="$(basename ${GIT_URL%.git})" + yesno "Build $PKG?" + if [ $? == "0" ]; then + if [ "$GIT_URL" = "$PKG" ]; then + GIT_URL=https://github.com/mer-hybris/$PKG.git + minfo "No git url specified, assuming $GIT_URL" + fi + + cd "$MER_ROOT/devel/mer-hybris" || die + LOG="`pwd`/$PKG.log" + [ -f "$LOG" ] && rm "$LOG" + + if [ ! -d $PKG ] ; then + minfo "Source code directory doesn't exist, clonig repository" + git clone $GIT_URL -b $GIT_BRANCH>>$LOG 2>&1|| die_with_log "$LOG" "cloning of $GIT_URL failed" + fi + + pushd $PKG || die + minfo "pulling updates..." + git pull >>$LOG 2>&1|| die_with_log "$LOG" "pulling of updates failed" + git submodule update >>$LOG 2>&1|| die_with_log "$LOG" "pulling of updates failed" + + SPECS="$*" + if [ -z "$SPECS" ]; then + minfo "No spec files for package building specified, building all I can find." + SPECS="rpm/*.spec" + fi + + for SPEC in $SPECS ; do + minfo "Building $SPEC" + mb2 -s $SPEC -t $VENDOR-$DEVICE-armv7hl build >>$LOG 2>&1|| die_with_log "$LOG" "building of package failed" + done + minfo "Building successful, adding packages to repo" + mkdir -p "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG" >>$LOG 2>&1|| die_with_log "$LOG" + rm -f "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG/"*.rpm >>$LOG 2>&1|| die_with_log "$LOG" + mv RPMS/*.rpm "$ANDROID_ROOT/droid-local-repo/$DEVICE/$PKG" >>$LOG 2>&1|| die_with_log "$LOG" + createrepo "$ANDROID_ROOT/droid-local-repo/$DEVICE" >>$LOG 2>&1|| die_with_log "$LOG" "can't create repo" + sb2 -t $VENDOR-$DEVICE-armv7hl -R -msdk-install zypper ref >>$LOG 2>&1|| die_with_log "$LOG" "can't update pkg info" + minfo "Building of $PKG finished successfully" + popd + fi + echo +}