diff --git a/build-package.sh b/build-package.sh index 0efc834616..92e9a2294b 100755 --- a/build-package.sh +++ b/build-package.sh @@ -273,7 +273,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_finish_build.sh" 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. - TERMUX_ARCH=$(dpkg --print-architecture 2>/dev/null || pacman-conf | grep Architecture | sed 's/Architecture = //g') + case "$TERMUX_MAIN_PACKAGE_FORMAT" in + "debian") TERMUX_ARCH=$(dpkg --print-architecture);; + "pacman") TERMUX_ARCH=$(pacman-conf | grep Architecture | sed 's/Architecture = //g');; + esac export TERMUX_ARCH fi diff --git a/clean.sh b/clean.sh index 5df2b78d01..0a6047a062 100755 --- a/clean.sh +++ b/clean.sh @@ -35,7 +35,7 @@ fi fi if [ -d "$TERMUX_TOPDIR" ]; then - chmod +w -R "$TERMUX_TOPDIR" + chmod +w -R "$TERMUX_TOPDIR" || true fi if $TERMUX_ON_DEVICE_BUILD; then diff --git a/scripts/build/setup/termux_setup_cmake.sh b/scripts/build/setup/termux_setup_cmake.sh index 526b501585..d47c4d2455 100644 --- a/scripts/build/setup/termux_setup_cmake.sh +++ b/scripts/build/setup/termux_setup_cmake.sh @@ -25,8 +25,8 @@ termux_setup_cmake() { export PATH=$TERMUX_CMAKE_FOLDER/bin:$PATH else - if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' cmake 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q cmake 2>/dev/null)" ]]; then + if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' cmake 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q cmake 2>/dev/null)" ]]; then echo "Package 'cmake' is not installed." echo "You can install it with" echo diff --git a/scripts/build/setup/termux_setup_ghc.sh b/scripts/build/setup/termux_setup_ghc.sh index 28819eb88c..2490489d48 100644 --- a/scripts/build/setup/termux_setup_ghc.sh +++ b/scripts/build/setup/termux_setup_ghc.sh @@ -32,8 +32,8 @@ termux_setup_ghc() { rm -Rf "$TERMUX_GHC_TEMP_FOLDER" else - if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q ghc 2>/dev/null)" ]]; then + if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q ghc 2>/dev/null)" ]]; then echo "Package 'ghc' is not installed." exit 1 fi diff --git a/scripts/build/setup/termux_setup_gn.sh b/scripts/build/setup/termux_setup_gn.sh index d88dd3b969..4a97fff530 100644 --- a/scripts/build/setup/termux_setup_gn.sh +++ b/scripts/build/setup/termux_setup_gn.sh @@ -40,8 +40,8 @@ termux_setup_gn() { fi export PATH=$GN_FOLDER/out:$PATH else - if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' gn 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q gn 2>/dev/null)" ]]; then + if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' gn 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q gn 2>/dev/null)" ]]; then echo "Package 'gn' is not installed." echo "You can install it with" echo diff --git a/scripts/build/setup/termux_setup_golang.sh b/scripts/build/setup/termux_setup_golang.sh index 2226d4d660..652d0ecc18 100644 --- a/scripts/build/setup/termux_setup_golang.sh +++ b/scripts/build/setup/termux_setup_golang.sh @@ -24,8 +24,8 @@ termux_setup_golang() { ( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" ) else - if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q golang 2>/dev/null)" ]]; then + if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q golang 2>/dev/null)" ]]; then echo "Package 'golang' is not installed." echo "You can install it with" echo diff --git a/scripts/build/setup/termux_setup_ninja.sh b/scripts/build/setup/termux_setup_ninja.sh index 095fbff05a..9985d7eb3c 100644 --- a/scripts/build/setup/termux_setup_ninja.sh +++ b/scripts/build/setup/termux_setup_ninja.sh @@ -23,8 +23,8 @@ termux_setup_ninja() { local NINJA_PKG_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/ninja/build.sh; echo \$TERMUX_PKG_VERSION") if ([ ! -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/ninja" ] || [ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/ninja")" != "$NINJA_PKG_VERSION" ]) && - ([[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' ninja 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q ninja 2>/dev/null)" ]]); then + ([[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' ninja 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q ninja 2>/dev/null)" ]]); then echo "Package 'ninja' is not installed." echo "You can install it with" echo diff --git a/scripts/build/setup/termux_setup_rust.sh b/scripts/build/setup/termux_setup_rust.sh index 32a81080f7..dfd676cebb 100644 --- a/scripts/build/setup/termux_setup_rust.sh +++ b/scripts/build/setup/termux_setup_rust.sh @@ -6,8 +6,8 @@ termux_setup_rust() { fi if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then - if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]] || - [[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q rust 2>/dev/null)" ]]; then + if [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q rust 2>/dev/null)" ]]; then echo "Package 'rust' is not installed." echo "You can install it with" echo diff --git a/scripts/build/termux_download_deb_pac.sh b/scripts/build/termux_download_deb_pac.sh index dc476e50ac..86831b19d6 100755 --- a/scripts/build/termux_download_deb_pac.sh +++ b/scripts/build/termux_download_deb_pac.sh @@ -5,7 +5,10 @@ termux_download_deb_pac() { local VERSION_PACMAN=$4 if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then - apt install -y "${PACKAGE}=${VERSION}" 2>/dev/null || pacman -S "${PACKAGE}=${VERSION_PACMAN}" --needed --noconfirm + case "$TERMUX_MAIN_PACKAGE_FORMAT" in + "debian") apt install -y "${PACKAGE}=${VERSION}";; + "pacman") pacman -S "${PACKAGE}=${VERSION_PACMAN}" --needed --noconfirm;; + esac return "$?" fi diff --git a/scripts/build/termux_step_get_dependencies.sh b/scripts/build/termux_step_get_dependencies.sh index 0b61454908..8fb92cd7b7 100644 --- a/scripts/build/termux_step_get_dependencies.sh +++ b/scripts/build/termux_step_get_dependencies.sh @@ -4,7 +4,12 @@ termux_step_get_dependencies() { termux_get_repo_files # When doing build on device, ensure that apt lists are up-to-date. - [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && (apt update 2>/dev/null || pacman -Sy) + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then + case "$TERMUX_MAIN_PACKAGE_FORMAT" in + "debian") apt update;; + "pacman") pacman -Sy;; + esac + fi # Download dependencies while read PKG PKG_DIR; do diff --git a/scripts/build/termux_step_setup_build_folders.sh b/scripts/build/termux_step_setup_build_folders.sh index e418e595bb..da3a1e7c98 100644 --- a/scripts/build/termux_step_setup_build_folders.sh +++ b/scripts/build/termux_step_setup_build_folders.sh @@ -2,8 +2,8 @@ termux_step_setup_build_folders() { # Following directories may contain files with read-only # permissions which makes them undeletable. We need to fix # that. - [ -d "$TERMUX_PKG_BUILDDIR" ] && chmod +w -R "$TERMUX_PKG_BUILDDIR" - [ -d "$TERMUX_PKG_SRCDIR" ] && chmod +w -R "$TERMUX_PKG_SRCDIR" + [ -d "$TERMUX_PKG_BUILDDIR" ] && chmod +w -R "$TERMUX_PKG_BUILDDIR" || true + [ -d "$TERMUX_PKG_SRCDIR" ] && chmod +w -R "$TERMUX_PKG_SRCDIR" || true if [ "$TERMUX_SKIP_DEPCHECK" = false ] && \ [ "$TERMUX_INSTALL_DEPS" = true ] && \ [ "$TERMUX_PKG_METAPACKAGE" = false ] && \ diff --git a/scripts/build/termux_step_setup_variables.sh b/scripts/build/termux_step_setup_variables.sh index 9a714fee97..e9b8657fb3 100644 --- a/scripts/build/termux_step_setup_variables.sh +++ b/scripts/build/termux_step_setup_variables.sh @@ -1,5 +1,5 @@ termux_step_setup_variables() { - : "${TERMUX_PACKAGE_FORMAT:="debian"}" # debian, pacman + : "${TERMUX_PACKAGE_FORMAT:="$(([ -n "$TERMUX_MAIN_PACKAGE_FORMAT" ] && echo "$TERMUX_MAIN_PACKAGE_FORMAT") || echo "debian")"}" # debian, pacman : "${TERMUX_ARCH:="aarch64"}" # arm, aarch64, i686 or x86_64. : "${TERMUX_OUTPUT_DIR:="${TERMUX_SCRIPTDIR}/output"}" : "${TERMUX_DEBUG_BUILD:="false"}" diff --git a/scripts/build/termux_step_start_build.sh b/scripts/build/termux_step_start_build.sh index b1b7c7b5f1..7c54397034 100644 --- a/scripts/build/termux_step_start_build.sh +++ b/scripts/build/termux_step_start_build.sh @@ -55,8 +55,8 @@ termux_step_start_build() { 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" = "true" ] && - ([ "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ] || - [ "$(pacman -Q $TERMUX_PKG_NAME 2>/dev/null)" = "$TERMUX_PKG_NAME $TERMUX_PKG_FULLVERSION_FOR_PACMAN" ]); then + ([[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ]] || + [[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && "$(pacman -Q $TERMUX_PKG_NAME 2>/dev/null)" = "$TERMUX_PKG_NAME $TERMUX_PKG_FULLVERSION_FOR_PACMAN" ]]); then echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION installed - skipping" exit 0 fi