diff --git a/build-package.sh b/build-package.sh index e05a0834d..3c70ea97c 100755 --- a/build-package.sh +++ b/build-package.sh @@ -168,7 +168,7 @@ export TERMUX_SCRIPTDIR # shellcheck source=scripts/properties.sh . "$TERMUX_SCRIPTDIR/scripts/properties.sh" -if $TERMUX_ON_DEVICE_BUILD; then +if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then # For on device builds cross compiling is not supported. # Target architecture must be same as for environment used currently. export TERMUX_ARCH=$(dpkg --print-architecture) @@ -180,11 +180,11 @@ _show_usage() { echo "Build a package by creating a .deb file in the debs/ folder." echo echo "Available options:" - ! $TERMUX_ON_DEVICE_BUILD && echo " -a The architecture to build for: aarch64(default), arm, i686, x86_64 or all." + [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && echo " -a The architecture to build for: aarch64(default), arm, i686, x86_64 or all." echo " -d Build with debug symbols." echo " -D Build a disabled package in disabled-packages/." echo " -f Force build even if package has already been built." - ! $TERMUX_ON_DEVICE_BUILD && echo " -i Download and extract dependencies instead of building them." + [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && echo " -i Download and extract dependencies instead of building them." echo " -I Download and extract dependencies instead of building them, keep existing /data/data/com.termux files." echo " -q Quiet build." echo " -s Skip dependency check." @@ -195,7 +195,7 @@ _show_usage() { while getopts :a:hdDfiIqso: option; do case "$option" in a) - if $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then termux_error_exit "./build-package.sh: option '-a' is not available for on-device builds" else export TERMUX_ARCH="$OPTARG" @@ -206,7 +206,7 @@ while getopts :a:hdDfiIqso: option; do D) local TERMUX_IS_DISABLED=true;; f) TERMUX_FORCE_BUILD=true;; i) - if $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then termux_error_exit "./build-package.sh: option '-i' is not available for on-device builds" else export TERMUX_INSTALL_DEPS=true @@ -236,7 +236,7 @@ while (($# > 0)); do fi # Handle 'all' arch: - if ! $TERMUX_ON_DEVICE_BUILD && [ -n "${TERMUX_ARCH+x}" ] && [ "${TERMUX_ARCH}" = 'all' ]; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && [ -n "${TERMUX_ARCH+x}" ] && [ "${TERMUX_ARCH}" = 'all' ]; then for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do env TERMUX_ARCH="$arch" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh \ ${TERMUX_FORCE_BUILD+-f} ${TERMUX_INSTALL_DEPS+-i} ${TERMUX_IS_DISABLED+-D} \ diff --git a/scripts/build/configure/termux_step_configure.sh b/scripts/build/configure/termux_step_configure.sh index 8647fe8c1..6d1d434fd 100644 --- a/scripts/build/configure/termux_step_configure.sh +++ b/scripts/build/configure/termux_step_configure.sh @@ -1,5 +1,5 @@ termux_step_configure() { - if ! ${TERMUX_PKG_FORCE_CMAKE-false} && [ -f "$TERMUX_PKG_SRCDIR/configure" ]; then + if [ "$TERMUX_PKG_FORCE_CMAKE" = "false" ] && [ -f "$TERMUX_PKG_SRCDIR/configure" ]; then termux_step_configure_autotools elif [ -f "$TERMUX_PKG_SRCDIR/CMakeLists.txt" ]; then termux_step_configure_cmake diff --git a/scripts/build/configure/termux_step_configure_autotools.sh b/scripts/build/configure/termux_step_configure_autotools.sh index 9c03cc6cd..aa01f0a6a 100644 --- a/scripts/build/configure/termux_step_configure_autotools.sh +++ b/scripts/build/configure/termux_step_configure_autotools.sh @@ -32,7 +32,7 @@ termux_step_configure_autotools() { QUIET_BUILD="--enable-silent-rules --silent --quiet" fi - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then # Some packages provides a $PKG-config script which some configure scripts pickup instead of pkg-config: mkdir "$TERMUX_PKG_TMPDIR/config-scripts" for f in $TERMUX_PREFIX/bin/*config; do diff --git a/scripts/build/configure/termux_step_configure_cmake.sh b/scripts/build/configure/termux_step_configure_cmake.sh index 7c8bb5377..a34c44cd6 100644 --- a/scripts/build/configure/termux_step_configure_cmake.sh +++ b/scripts/build/configure/termux_step_configure_cmake.sh @@ -18,7 +18,7 @@ termux_step_configure_cmake() { CFLAGS+=" -fno-addrsig" local CMAKE_ADDITIONAL_ARGS=() - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then CXXFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM" CFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM" LDFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM" diff --git a/scripts/build/setup/termux_setup_cmake.sh b/scripts/build/setup/termux_setup_cmake.sh index 4190dc741..2ba8461b3 100644 --- a/scripts/build/setup/termux_setup_cmake.sh +++ b/scripts/build/setup/termux_setup_cmake.sh @@ -6,7 +6,7 @@ termux_setup_cmake() { local TERMUX_CMAKE_TARFILE=$TERMUX_PKG_TMPDIR/$TERMUX_CMAKE_TARNAME local TERMUX_CMAKE_FOLDER=$TERMUX_COMMON_CACHEDIR/cmake-$TERMUX_CMAKE_VERSION - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ ! -d "$TERMUX_CMAKE_FOLDER" ]; then termux_download https://cmake.org/files/v$TERMUX_CMAKE_MAJORVESION/$TERMUX_CMAKE_TARNAME \ "$TERMUX_CMAKE_TARFILE" \ diff --git a/scripts/build/setup/termux_setup_golang.sh b/scripts/build/setup/termux_setup_golang.sh index 5afe2d779..cb4616cfb 100644 --- a/scripts/build/setup/termux_setup_golang.sh +++ b/scripts/build/setup/termux_setup_golang.sh @@ -19,7 +19,7 @@ termux_setup_golang() { termux_error_exit "Unsupported arch: $TERMUX_ARCH" fi - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then local TERMUX_GO_VERSION=go1.12.7 local TERMUX_GO_PLATFORM=linux-amd64 diff --git a/scripts/build/setup/termux_setup_ninja.sh b/scripts/build/setup/termux_setup_ninja.sh index ea2947eb5..54e682078 100644 --- a/scripts/build/setup/termux_setup_ninja.sh +++ b/scripts/build/setup/termux_setup_ninja.sh @@ -2,7 +2,7 @@ termux_setup_ninja() { local NINJA_VERSION=1.9.0 local NINJA_FOLDER=$TERMUX_COMMON_CACHEDIR/ninja-$NINJA_VERSION - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ ! -x "$NINJA_FOLDER/ninja" ]; then mkdir -p "$NINJA_FOLDER" local NINJA_ZIP_FILE=$TERMUX_PKG_TMPDIR/ninja-$NINJA_VERSION.zip diff --git a/scripts/build/setup/termux_setup_protobuf.sh b/scripts/build/setup/termux_setup_protobuf.sh index 9e106bbc4..b29f90b8a 100644 --- a/scripts/build/setup/termux_setup_protobuf.sh +++ b/scripts/build/setup/termux_setup_protobuf.sh @@ -3,7 +3,7 @@ termux_setup_protobuf() { local _PROTOBUF_ZIP=protoc-$_PROTOBUF_VERSION-linux-x86_64.zip local _PROTOBUF_FOLDER=$TERMUX_COMMON_CACHEDIR/protobuf-$_PROTOBUF_VERSION - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ ! -d "$_PROTOBUF_FOLDER" ]; then termux_download \ https://github.com/protocolbuffers/protobuf/releases/download/v$_PROTOBUF_VERSION/$_PROTOBUF_ZIP \ diff --git a/scripts/build/setup/termux_setup_rust.sh b/scripts/build/setup/termux_setup_rust.sh index 7134d4f04..34a1883bd 100644 --- a/scripts/build/setup/termux_setup_rust.sh +++ b/scripts/build/setup/termux_setup_rust.sh @@ -7,7 +7,7 @@ termux_setup_rust() { export RUSTFLAGS="-C link-arg=-Wl,-rpath=$TERMUX_PREFIX/lib -C link-arg=-Wl,--enable-new-dtags" - if $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then if [ "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]; then echo "Package 'rust' is not installed." echo "You can install it with" diff --git a/scripts/build/termux_create_subpackages.sh b/scripts/build/termux_create_subpackages.sh index fe84a1ffd..df503f4e0 100644 --- a/scripts/build/termux_create_subpackages.sh +++ b/scripts/build/termux_create_subpackages.sh @@ -1,6 +1,6 @@ termux_create_subpackages() { # Sub packages: - if ! ${TERMUX_PKG_NO_STATICSPLIT-false} && [[ -n $(shopt -s nullglob; echo lib/*.a) ]]; then + if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s nullglob; echo lib/*.a) ]]; then # Add virtual -static sub package if there are include files: local _STATIC_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-static.subpackage.sh echo TERMUX_SUBPKG_INCLUDE=\"lib/**/*.a lib/**/*.la\" > "$_STATIC_SUBPACKAGE_FILE" diff --git a/scripts/build/termux_download_deb.sh b/scripts/build/termux_download_deb.sh index 4a4afd6b0..3ce660696 100755 --- a/scripts/build/termux_download_deb.sh +++ b/scripts/build/termux_download_deb.sh @@ -3,7 +3,7 @@ termux_download_deb() { local PACKAGE_ARCH=$2 local VERSION=$3 - if $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then apt install -y "${PACKAGE}=${VERSION}" return "$?" fi diff --git a/scripts/build/termux_extract_dep_info.sh b/scripts/build/termux_extract_dep_info.sh index 970449f08..e5c889324 100755 --- a/scripts/build/termux_extract_dep_info.sh +++ b/scripts/build/termux_extract_dep_info.sh @@ -8,10 +8,10 @@ termux_extract_dep_info() { TERMUX_PKG_PLATFORM_INDEPENDENT=false source ${PKG_DIR}/build.sh TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT - if ! $TERMUX_INSTALL_DEPS || ${TERMUX_PKG_NO_STATICSPLIT-false} || [ "${PKG/-static/}-static" != "${PKG}" ]; then + if [ "$TERMUX_INSTALL_DEPS" = "false" ] || [ "$TERMUX_PKG_NO_STATICSPLIT" = "true" ] || [ "${PKG/-static/}-static" != "${PKG}" ]; then source ${PKG_DIR}/${PKG}.subpackage.sh fi - if ${TERMUX_SUBPKG_PLATFORM_INDEPENDENT-false}; then + if [ "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" = "true" ]; then echo all else echo $TERMUX_ARCH @@ -29,7 +29,7 @@ termux_extract_dep_info() { TERMUX_PKG_PLATFORM_INDEPENDENT=false TERMUX_PKG_REVISION="0" source ${PKG_DIR}/build.sh - ${TERMUX_PKG_PLATFORM_INDEPENDENT-false} && TERMUX_ARCH=all + [ "$TERMUX_PKG_PLATFORM_INDEPENDENT" = "true" ] && TERMUX_ARCH=all if [ "$TERMUX_PKG_REVISION" != "0" ] || [ "$TERMUX_PKG_VERSION" != "${TERMUX_PKG_VERSION/-/}" ]; then TERMUX_PKG_VERSION+="-$TERMUX_PKG_REVISION" fi diff --git a/scripts/build/termux_step_handle_hostbuild.sh b/scripts/build/termux_step_handle_hostbuild.sh index cfd9070fe..ab029a18c 100644 --- a/scripts/build/termux_step_handle_hostbuild.sh +++ b/scripts/build/termux_step_handle_hostbuild.sh @@ -1,5 +1,5 @@ termux_step_handle_hostbuild() { - if ! ${TERMUX_PKG_HOSTBUILD-false}; then return; fi + if [ "$TERMUX_PKG_HOSTBUILD" = "false" ]; then return; fi cd "$TERMUX_PKG_SRCDIR" for patch in $TERMUX_PKG_BUILDER_DIR/*.patch.beforehostbuild; do diff --git a/scripts/build/termux_step_massage.sh b/scripts/build/termux_step_massage.sh index 9485b3da7..c3ad3f97f 100644 --- a/scripts/build/termux_step_massage.sh +++ b/scripts/build/termux_step_massage.sh @@ -16,7 +16,7 @@ termux_step_massage() { # Remove world permissions and make sure that user still have read-write permissions. chmod -Rf u+rw,g-rwx,o-rwx . || true - if ! $TERMUX_DEBUG; then + if [ "$TERMUX_DEBUG" = "false" ]; then # Strip binaries. file(1) may fail for certain unusual files, so disable pipefail. set +e +o pipefail find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" \) -type f | \ diff --git a/scripts/build/termux_step_patch_package.sh b/scripts/build/termux_step_patch_package.sh index 0d1862d80..f70fdaaf7 100644 --- a/scripts/build/termux_step_patch_package.sh +++ b/scripts/build/termux_step_patch_package.sh @@ -1,7 +1,7 @@ termux_step_patch_package() { cd "$TERMUX_PKG_SRCDIR" local DEBUG_PATCHES="" - if $TERMUX_DEBUG && [ -f $TERMUX_PKG_BUILDER_DIR/*.patch.debug ] ; then + if [ "$TERMUX_DEBUG" = "true" ] && [ -f $TERMUX_PKG_BUILDER_DIR/*.patch.debug ] ; then DEBUG_PATCHES="$(ls $TERMUX_PKG_BUILDER_DIR/*.patch.debug)" fi # Suffix patch with ".patch32" or ".patch64" to only apply for these bitnesses: diff --git a/scripts/build/termux_step_setup_toolchain.sh b/scripts/build/termux_step_setup_toolchain.sh index d25065491..2a0ec17dc 100644 --- a/scripts/build/termux_step_setup_toolchain.sh +++ b/scripts/build/termux_step_setup_toolchain.sh @@ -14,7 +14,7 @@ termux_step_setup_toolchain() { export READELF=$TERMUX_HOST_PLATFORM-readelf export STRIP=$TERMUX_HOST_PLATFORM-strip - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then export PATH=$TERMUX_STANDALONE_TOOLCHAIN/bin:$PATH export CC_FOR_BUILD=gcc export PKG_CONFIG=$TERMUX_STANDALONE_TOOLCHAIN/bin/${TERMUX_HOST_PLATFORM}-pkg-config @@ -56,7 +56,7 @@ termux_step_setup_toolchain() { CFLAGS+=" -fstack-protector-strong" LDFLAGS+=" -Wl,-z,relro,-z,now" - if $TERMUX_DEBUG; then + if [ "$TERMUX_DEBUG" = "true" ]; then CFLAGS+=" -g3 -O1 -D_FORTIFY_SOURCE=2" else CFLAGS+=" -Oz" @@ -76,7 +76,7 @@ termux_step_setup_toolchain() { export ac_cv_func_sigsetmask=no export ac_cv_c_bigendian=no - if ! $TERMUX_ON_DEVICE_BUILD && [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then # Do not put toolchain in place until we are done with setup, to avoid having a half setup # toolchain left in place if something goes wrong (or process is just aborted): local _TERMUX_TOOLCHAIN_TMPDIR=${TERMUX_STANDALONE_TOOLCHAIN}-tmp @@ -173,7 +173,7 @@ termux_step_setup_toolchain() { export PKG_CONFIG_LIBDIR="$TERMUX_PKG_CONFIG_LIBDIR" - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then # Create a pkg-config wrapper. We use path to host pkg-config to # avoid picking up a cross-compiled pkg-config later on. local _HOST_PKGCONFIG diff --git a/scripts/build/termux_step_setup_variables.sh b/scripts/build/termux_step_setup_variables.sh index 4c990eab4..16f4042eb 100644 --- a/scripts/build/termux_step_setup_variables.sh +++ b/scripts/build/termux_step_setup_variables.sh @@ -13,7 +13,7 @@ termux_step_setup_variables() { : "${TERMUX_INSTALL_DEPS:="false"}" : "${TERMUX_PACKAGES_DIRECTORIES:="packages"}" - if $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then # For on-device builds cross-compiling is not supported so we can # store information about built packages under $TERMUX_TOPDIR. TERMUX_BUILT_PACKAGES_DIRECTORY="$TERMUX_TOPDIR/.built-packages" @@ -73,11 +73,11 @@ termux_step_setup_variables() { TERMUX_HOST_PLATFORM="${TERMUX_ARCH}-linux-android" if [ "$TERMUX_ARCH" = "arm" ]; then TERMUX_HOST_PLATFORM="${TERMUX_HOST_PLATFORM}eabi"; fi - if ! $TERMUX_ON_DEVICE_BUILD && [ ! -d "$NDK" ]; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && [ ! -d "$NDK" ]; then termux_error_exit 'NDK not pointing at a directory!' fi - if ! $TERMUX_ON_DEVICE_BUILD && ! grep -s -q "Pkg.Revision = $TERMUX_NDK_VERSION_NUM" "$NDK/source.properties"; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && ! grep -s -q "Pkg.Revision = $TERMUX_NDK_VERSION_NUM" "$NDK/source.properties"; then termux_error_exit "Wrong NDK version - we need $TERMUX_NDK_VERSION" fi diff --git a/scripts/build/termux_step_start_build.sh b/scripts/build/termux_step_start_build.sh index 9d5abe114..fe0fae412 100644 --- a/scripts/build/termux_step_start_build.sh +++ b/scripts/build/termux_step_start_build.sh @@ -18,8 +18,8 @@ termux_step_start_build() { TERMUX_PKG_FULLVERSION+="-$TERMUX_PKG_REVISION" fi - if $TERMUX_DEBUG; then - if $TERMUX_PKG_HAS_DEBUG; then + if [ "$TERMUX_DEBUG" = "true" ]; then + if [ "$TERMUX_PKG_HAS_DEBUG" = "true" ]; then DEBUG="-dbg" else echo "Skipping building debug build for $TERMUX_PKG_NAME" @@ -29,12 +29,12 @@ termux_step_start_build() { DEBUG="" fi - if ! $TERMUX_DEBUG && ${TERMUX_FORCE_BUILD-false}; then + if [ "$TERMUX_DEBUG" = "true" ] && [ "$TERMUX_FORCE_BUILD" = "true" ]; then if [ -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME" ] && [ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME")" = "$TERMUX_PKG_FULLVERSION" ]; then echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm $TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME to force rebuild)" exit 0 - elif $TERMUX_ON_DEVICE_BUILD && + elif [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && [ "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ]; then echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION installed - skipping" exit 0 @@ -74,7 +74,7 @@ termux_step_start_build() { TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I "${PKG_DIR}" continue else - if ! $TERMUX_ON_DEVICE_BUILD; then + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ ! "$TERMUX_QUIET_BUILD" = true ]; then echo "extracting $PKG..."; fi ( cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH @@ -125,7 +125,7 @@ termux_step_start_build() { # Make $TERMUX_PREFIX/bin/sh executable on the builder, so that build # scripts can assume that it works on both builder and host later on: - ! $TERMUX_ON_DEVICE_BUILD && ln -sf /bin/sh "$TERMUX_PREFIX/bin/sh" + [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && ln -sf /bin/sh "$TERMUX_PREFIX/bin/sh" local TERMUX_ELF_CLEANER_SRC=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner.cpp local TERMUX_ELF_CLEANER_VERSION @@ -139,7 +139,7 @@ termux_step_start_build() { "$TERMUX_ELF_CLEANER_SRC" -o "$TERMUX_ELF_CLEANER" fi - if ${TERMUX_PKG_BUILD_IN_SRC-false}; then + if [ "$TERMUX_PKG_BUILD_IN_SRC" = "true" ]; then echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set to true" > "$TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt" TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR fi