Changeset 9ec2896 in subsurface


Ignore:
Timestamp:
Jan 12, 2017, 2:15:53 PM (6 months ago)
Author:
Subsurface <dirk@…>
Branches:
master
Children:
450092cd
Parents:
4714f50
git-author:
Anton Lundin <glance@…> (01/03/17 00:00:52)
git-committer:
Subsurface <dirk@…> (01/12/17 14:15:53)
Message:

android: Introduce propper quoting in build.sh

This where quoting issues found by shellcheck.

Signed-off-by: Anton Lundin <glance@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • packaging/android/build.sh

    r346f4d4f r9ec2896  
    2424# (trick to get the absolute path, either if we're called with a
    2525# absolute path or a relative path)
    26 pushd $(dirname $0)/../../
     26pushd "$(dirname "$0")/../../"
    2727export SUBSURFACE_SOURCE=$PWD
    2828popd
     
    6363fi
    6464
    65 if [ $PLATFORM = Darwin ] ; then
     65if [ "$PLATFORM" = "Darwin" ] ; then
    6666       export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT-$SUBSURFACE_SOURCE/../android-sdk-macosx}
    6767       export ANDROID_NDK_HOST=darwin-x86_64
     
    101101
    102102if [ ! -e ndk-$ARCH ] ; then
    103         $ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py --arch=$ARCH --install-dir=ndk-$ARCH --api=16
     103        "$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py" --arch=$ARCH --install-dir=ndk-$ARCH --api=16
    104104fi
    105105export BUILDROOT=$PWD
    106106export PATH=${BUILDROOT}/ndk-$ARCH/bin:$PATH
    107107export PREFIX=${BUILDROOT}/ndk-$ARCH/sysroot/usr
    108 export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig
     108export PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig
    109109export CC=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-gcc
    110110export CXX=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-g++
     
    116116# Junk needed for qt-android-cmake
    117117export ANDROID_STANDALONE_TOOLCHAIN=${BUILDROOT}/ndk-$ARCH
    118 if [ $PLATFORM = Darwin ] ; then
     118if [ "$PLATFORM" = "Darwin" ] ; then
    119119        JAVA_HOME=$(/usr/libexec/java_home)
    120120        export JAVA_HOME
     
    129129        tar -zxf sqlite-autoconf-${SQLITE_VERSION}.tar.gz
    130130fi
    131 if [ ! -e $PKG_CONFIG_LIBDIR/sqlite3.pc ] ; then
     131if [ ! -e "$PKG_CONFIG_LIBDIR/sqlite3.pc" ] ; then
    132132        mkdir -p sqlite-build-$ARCH
    133133        pushd sqlite-build-$ARCH
    134         ../sqlite-autoconf-${SQLITE_VERSION}/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared
     134        ../sqlite-autoconf-${SQLITE_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared
    135135        make
    136136        make install
     
    144144        tar -zxf libxml2-${LIBXML2_VERSION}.tar.gz
    145145fi
    146 if [ ! -e $PKG_CONFIG_LIBDIR/libxml-2.0.pc ] ; then
     146if [ ! -e "$PKG_CONFIG_LIBDIR/libxml-2.0.pc" ] ; then
    147147        mkdir -p libxml2-build-$ARCH
    148148        pushd libxml2-build-$ARCH
    149         ../libxml2-${LIBXML2_VERSION}/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --without-python --without-iconv --enable-static --disable-shared
     149        ../libxml2-${LIBXML2_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --without-python --without-iconv --enable-static --disable-shared
    150150        perl -pi -e 's/runtest\$\(EXEEXT\)//' Makefile
    151151        perl -pi -e 's/testrecurse\$\(EXEEXT\)//' Makefile
     
    163163        cp libxml2-${LIBXML2_VERSION}/config.sub libxslt-${LIBXSLT_VERSION}
    164164fi
    165 if [ ! -e $PKG_CONFIG_LIBDIR/libxslt.pc ] ; then
     165if [ ! -e "$PKG_CONFIG_LIBDIR/libxslt.pc" ] ; then
    166166        mkdir -p libxslt-build-$ARCH
    167167        pushd libxslt-build-$ARCH
    168         ../libxslt-${LIBXSLT_VERSION}/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --with-libxml-prefix=${PREFIX} --without-python --without-crypto --enable-static --disable-shared
     168        ../libxslt-${LIBXSLT_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --with-libxml-prefix="$PREFIX" --without-python --without-crypto --enable-static --disable-shared
    169169        make
    170170        make install
     
    178178        tar -zxf libzip-${LIBZIP_VERSION}.tar.gz
    179179fi
    180 if [ ! -e $PKG_CONFIG_LIBDIR/libzip.pc ] ; then
     180if [ ! -e "$PKG_CONFIG_LIBDIR/libzip.pc" ] ; then
    181181        mkdir -p libzip-build-$ARCH
    182182        pushd libzip-build-$ARCH
    183         ../libzip-${LIBZIP_VERSION}/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared
     183        ../libzip-${LIBZIP_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared
    184184        make
    185185        make install
     
    194194        mv openssl-${OPENSSL_VERSION} openssl-build-$ARCH
    195195fi
    196 if [ ! -e $PKG_CONFIG_LIBDIR/libssl.pc ] ; then
     196if [ ! -e "$PKG_CONFIG_LIBDIR/libssl.pc" ] ; then
    197197        pushd openssl-build-$ARCH
    198198        perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
     
    203203                HOSTCC=gcc \
    204204                CC=gcc \
    205                 ANDROID_DEV=$PREFIX \
    206                 bash -x ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir=$PREFIX
     205                ANDROID_DEV="$PREFIX" \
     206                bash -x ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir="$PREFIX"
    207207#       sed -i.bak -e 's/soname=\$\$SHLIB\$\$SHLIB_SOVER\$\$SHLIB_SUFFIX/soname=\$\$SHLIB/g' Makefile.shared
    208208        make depend
     
    218218        tar -zxf libgit2-${LIBGIT2_VERSION}.tar.gz
    219219fi
    220 if [ ! -e $PKG_CONFIG_LIBDIR/libgit2.pc ] ; then
     220if [ ! -e "$PKG_CONFIG_LIBDIR/libgit2.pc" ] ; then
    221221        mkdir -p libgit2-build-$ARCH
    222222        pushd libgit2-build-$ARCH
    223223        cmake -DCMAKE_SYSTEM_NAME=Android -DSHA1_TYPE=builtin \
    224224                -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=OFF \
    225                 -DCMAKE_INSTALL_PREFIX=${PREFIX} \
     225                -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    226226                -DCURL=OFF \
    227227                -DUSE_SSH=OFF \
    228                 -DOPENSSL_SSL_LIBRARY=${PREFIX}/lib/libssl.so \
    229                 -DOPENSSL_CRYPTO_LIBRARY=${PREFIX}/lib/libcrypto.so \
    230                 -DOPENSSL_INCLUDE_DIR=${PREFIX}/include/openssl \
     228                -DOPENSSL_SSL_LIBRARY="$PREFIX"/lib/libssl.so \
     229                -DOPENSSL_CRYPTO_LIBRARY="$PREFIX"/lib/libcrypto.so \
     230                -DOPENSSL_INCLUDE_DIR="$PREFIX"/include/openssl \
    231231                -D_OPENSSL_VERSION=1.0.1p \
    232232                ../libgit2-${LIBGIT2_VERSION}/
     
    234234        make install
    235235        # Patch away pkg-config dependency to zlib, its there, i promise
    236         perl -pi -e 's/^(Requires.private:.*)zlib(.*)$/$1 $2/' $PKG_CONFIG_LIBDIR/libgit2.pc
     236        perl -pi -e 's/^(Requires.private:.*)zlib(.*)$/$1 $2/' "$PKG_CONFIG_LIBDIR"/libgit2.pc
    237237        popd
    238238fi
     
    247247        # Patch in our libusb callback
    248248        pushd libusb-${LIBUSB_VERSION}
    249         patch -p1 < $SUBSURFACE_SOURCE/packaging/android/patches/libusb-android.patch
     249        patch -p1 < "$SUBSURFACE_SOURCE"/packaging/android/patches/libusb-android.patch
    250250        popd
    251251fi
     
    256256        popd
    257257fi
    258 if [ ! -e $PKG_CONFIG_LIBDIR/libusb-1.0.pc ] ; then
     258if [ ! -e "$PKG_CONFIG_LIBDIR/libusb-1.0.pc" ] ; then
    259259        mkdir -p libusb-build-$ARCH
    260260        pushd libusb-build-$ARCH
    261         ../libusb-${LIBUSB_VERSION}/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared --disable-udev --enable-system-log
     261        ../libusb-${LIBUSB_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --disable-udev --enable-system-log
    262262        # --enable-debug-log
    263263        make
     
    272272        tar -jxf libftdi1-${LIBFTDI_VERSION}.tar.bz2
    273273fi
    274 if [ ! -e $PKG_CONFIG_LIBDIR/libftdi1.pc ] && [ $PLATFORM != Darwin ] ; then
     274if [ ! -e "$PKG_CONFIG_LIBDIR/libftdi1.pc" ] && [ "$PLATFORM" != "Darwin" ] ; then
    275275        mkdir -p libftdi1-build-$ARCH
    276276        pushd libftdi1-build-$ARCH
    277         cmake ../libftdi1-${LIBFTDI_VERSION} -DCMAKE_C_COMPILER=${CC} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} -DSTATICLIBS=ON -DPYTHON_BINDINGS=OFF -DDOCUMENTATION=OFF -DFTDIPP=OFF -DBUILD_TESTS=OFF -DEXAMPLES=OFF -DFTDI_EEPROM=OFF
     277        cmake ../libftdi1-${LIBFTDI_VERSION} -DCMAKE_C_COMPILER="$CC" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" -DSTATICLIBS=ON -DPYTHON_BINDINGS=OFF -DDOCUMENTATION=OFF -DFTDIPP=OFF -DBUILD_TESTS=OFF -DEXAMPLES=OFF -DFTDI_EEPROM=OFF
    278278        make
    279279        make install
     
    281281fi
    282282# Blast away the shared version to force static linking
    283 if [ -e $PREFIX/lib/libftdi1.so ] ; then
    284         rm $PREFIX/lib/libftdi1.so*
    285 fi
    286 
    287 if [ ! -e $PKG_CONFIG_LIBDIR/libdivecomputer.pc ] ; then
     283if [ -e "$PREFIX/lib/libftdi1.so" ] ; then
     284        rm "$PREFIX"/lib/libftdi1.so*
     285fi
     286
     287if [ ! -e "$PKG_CONFIG_LIBDIR/libdivecomputer.pc" ] ; then
    288288        mkdir -p libdivecomputer-build-$ARCH
    289289        pushd libdivecomputer-build-$ARCH
    290         $SUBSURFACE_SOURCE/../libdivecomputer/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared --enable-examples=no
     290        "$SUBSURFACE_SOURCE"/../libdivecomputer/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --enable-examples=no
    291291        make
    292292        make install
     
    311311
    312312if [ "$SUBSURFACE_MOBILE" = "ON" ] ; then
    313         pushd $SUBSURFACE_SOURCE
     313        pushd "$SUBSURFACE_SOURCE"
    314314        bash ./scripts/mobilecomponents.sh
    315315        popd
     
    326326
    327327# something in the qt-android-cmake-thingies mangles your path, so thats why we need to hard-code ant and pkg-config here.
    328 if [ $PLATFORM = Darwin ] ; then
     328if [ "$PLATFORM" = "Darwin" ] ; then
    329329        ANT=/usr/local/bin/ant
    330330        FTDI=OFF
     
    337337cmake $MOBILE_CMAKE \
    338338        -DQT_ANDROID_ANT=${ANT} \
    339         -DPKG_CONFIG_EXECUTABLE=${PKGCONF} \
    340         -DQT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
    341         -DQT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT \
    342         -DCMAKE_TOOLCHAIN_FILE=$BUILDROOT/qt-android-cmake/toolchain/android.toolchain.cmake \
    343         -DQT_ANDROID_CMAKE=$BUILDROOT/qt-android-cmake/AddQtAndroidApk.cmake \
     339        -DPKG_CONFIG_EXECUTABLE="$PKGCONF" \
     340        -DQT_ANDROID_SDK_ROOT="$ANDROID_SDK_ROOT" \
     341        -DQT_ANDROID_NDK_ROOT="$ANDROID_NDK_ROOT" \
     342        -DCMAKE_TOOLCHAIN_FILE="$BUILDROOT"/qt-android-cmake/toolchain/android.toolchain.cmake \
     343        -DQT_ANDROID_CMAKE="$BUILDROOT"/qt-android-cmake/AddQtAndroidApk.cmake \
    344344        -DFORCE_LIBSSH=OFF \
    345345        -DLIBDC_FROM_PKGCONFIG=ON \
     
    349349        -DNO_USERMANUAL=ON \
    350350        -DFBSUPPORT=OFF \
    351         -DCMAKE_PREFIX_PATH:UNINITIALIZED=${QT5_ANDROID}/android_${QT_ARCH}/lib/cmake \
    352         -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
     351        -DCMAKE_PREFIX_PATH:UNINITIALIZED="$QT5_ANDROID/android_$QT_ARCH/lib/cmake" \
     352        -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
    353353        -DMAKE_TESTS=OFF \
    354354        -DFTDISUPPORT=${FTDI} \
    355         -DANDROID_NATIVE_LIBSSL=$BUILDROOT/ndk-${ARCH}/sysroot/usr/lib/libssl.so \
    356         -DANDROID_NATIVE_LIBCRYPT=$BUILDROOT/ndk-${ARCH}/sysroot/usr/lib/libcrypto.so \
    357         $SUBSURFACE_SOURCE
     355        -DANDROID_NATIVE_LIBSSL="$BUILDROOT/ndk-$ARCH/sysroot/usr/lib/libssl.so" \
     356        -DANDROID_NATIVE_LIBCRYPT="$BUILDROOT/ndk-$ARCH/sysroot/usr/lib/libcrypto.so" \
     357        "$SUBSURFACE_SOURCE"
    358358
    359359# set up the version number
     
    364364if [ ! -z "$SUBSURFACE_MOBILE" ] ; then
    365365        SUBSURFACE_MOBILE_VERSION=$(grep MOBILE_VERSION_STRING ssrf-version.h | awk '{ print $3 }' | tr -d \" )
    366         SUBSURFACE_MOBILE_VERSION="${SUBSURFACE_MOBILE_VERSION} ($(grep CANONICAL_VERSION_STRING ssrf-version.h | awk '{ print $3 }' | tr -d \"))"
     366        SUBSURFACE_MOBILE_VERSION="$SUBSURFACE_MOBILE_VERSION ($(grep CANONICAL_VERSION_STRING ssrf-version.h | awk '{ print $3 }' | tr -d \"))"
    367367
    368368        rm -rf android-mobile
    369         cp -a $SUBSURFACE_SOURCE/android-mobile .
     369        cp -a "$SUBSURFACE_SOURCE/android-mobile" .
    370370        sed -i -e "s/@SUBSURFACE_MOBILE_VERSION@/\"$SUBSURFACE_MOBILE_VERSION\"/;s/@BUILD_NR@/$BUILD_NR/" android-mobile/AndroidManifest.xml
    371371else
     
    374374        # android-mobile is hardcoded in CMakeLists.txt nowadays.
    375375        rm -rf android-mobile
    376         cp -a $SUBSURFACE_SOURCE/android android-mobile
     376        cp -a "$SUBSURFACE_SOURCE/android android-mobile"
    377377        sed -i -e "s/@SUBSURFACE_VERSION@/\"$SUBSURFACE_VERSION\"/;s/@BUILD_NR@/$BUILD_NR/" android-mobile/AndroidManifest.xml
    378378fi
     
    384384
    385385# now build Subsurface and use the rest of the command line arguments
    386 make $@
     386make "$@"
    387387
    388388#make install INSTALL_ROOT=android_build
Note: See TracChangeset for help on using the changeset viewer.