changed(scripts|main/termux-tools): Use TERMUX_APP_PACKAGE_MANAGER instead of TERMUX_MAIN_PACKAGE_FORMAT

Make changes as per new design implemented in termux/termux-app@b950efec and termux/termux-app#2740

The package build and termux-tools scripts use current package manager for custom logic. The `termux-tools/termux-setup-package-manager` script has been added that will now be used to provide backward compatibility for termux-app `< 0.119.0` (when its released) and validate the package manager. It will also ensure the variable in not unset to prevent `unbound variable` errors if `set -u` is being used by calling scripts.

Closes #10782
This commit is contained in:
agnostic-apollo 2022-05-22 23:00:24 +05:00
parent ee224d779e
commit 0275d9bff3
20 changed files with 105 additions and 53 deletions

View File

@ -313,10 +313,13 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_finish_build.sh"
. "$TERMUX_SCRIPTDIR/scripts/properties.sh"
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
# Setup TERMUX_APP_PACKAGE_MANAGER
source "$TERMUX_PREFIX/bin/termux-setup-package-manager"
# For on device builds cross compiling is not supported.
# Target architecture must be same as for environment used currently.
case "$TERMUX_MAIN_PACKAGE_FORMAT" in
"debian") TERMUX_ARCH=$(dpkg --print-architecture);;
case "$TERMUX_APP_PACKAGE_MANAGER" in
"apt") TERMUX_ARCH=$(dpkg --print-architecture);;
"pacman") TERMUX_ARCH=$(pacman-conf | grep Architecture | sed 's/Architecture = //g');;
esac
export TERMUX_ARCH
@ -360,11 +363,7 @@ while (($# >= 1)); do
if [ -z "$1" ]; then
termux_error_exit "./build-package.sh: argument to '--format' should not be empty"
fi
case "$1" in
debian|pacman) TERMUX_PACKAGE_FORMAT="$1";;
*) termux_error_exit "./build-package.sh: only 'debian' and 'pacman' formats are supported";;
esac
TERMUX_PACKAGE_FORMAT="$1"
else
termux_error_exit "./build-package.sh: option '--format' requires an argument"
fi
@ -416,6 +415,13 @@ while (($# >= 1)); do
done
unset -f _show_usage
if [ -n "${TERMUX_PACKAGE_FORMAT-}" ]; then
case "${TERMUX_PACKAGE_FORMAT-}" in
debian|pacman) :;;
*) termux_error_exit "Unsupported package format \"${TERMUX_PACKAGE_FORMAT-}\". Only 'debian' and 'pacman' formats are supported";;
esac
fi
if [ "${TERMUX_INSTALL_DEPS-false}" = "true" ]; then
# Setup PGP keys for verifying integrity of dependencies.
# Keys are obtained from our keyring package.

View File

@ -40,7 +40,7 @@ termux_step_make_install() {
for script in chsh dalvikvm login pkg su termux-fix-shebang termux-backup \
termux-info termux-open termux-open-url termux-reload-settings \
termux-reset termux-restore termux-setup-storage termux-wake-lock \
termux-wake-unlock termux-change-repo; do
termux-wake-unlock termux-change-repo termux-setup-package-manager; do
install -Dm700 $TERMUX_PKG_BUILDER_DIR/$script $TERMUX_PREFIX/bin/$script
sed -i -e "s%\@TERMUX_APP_PACKAGE\@%${TERMUX_APP_PACKAGE}%g" \
-e "s%\@TERMUX_BASE_DIR\@%${TERMUX_BASE_DIR}%g" \
@ -49,6 +49,7 @@ termux_step_make_install() {
-e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
-e "s%\@PACKAGE_VERSION\@%${TERMUX_PKG_VERSION}%g" \
-e "s%\@TERMUX_PACKAGE_FORMAT\@%${TERMUX_PACKAGE_FORMAT}%g" \
-e "s%\@TERMUX_PACKAGE_MANAGER\@%${TERMUX_PACKAGE_MANAGER}%g" \
$TERMUX_PREFIX/bin/$script
done

View File

@ -23,8 +23,14 @@ else
done
fi
# for the correct operation of scripts that work with the package manager
export TERMUX_MAIN_PACKAGE_FORMAT="@TERMUX_PACKAGE_FORMAT@"
# TERMUX_APP_PACKAGE_MANAGER should be exported by termux-app v0.119.0+ itself
if [ -z "${TERMUX_APP_PACKAGE_MANAGER-}" ]; then
if { [ -n "$(command -v dpkg)" ] && dpkg --compare-versions "$TERMUX_VERSION" lt 0.119.0; } || # apt
{ [ -n "$(command -v vercmp)" ] && [ "$(vercmp "$TERMUX_VERSION" 0.119.0)" = "-1" ]; }; then # pacman
# For the correct operation of scripts that work with the package manager
export TERMUX_MAIN_PACKAGE_FORMAT="@TERMUX_PACKAGE_FORMAT@"
fi
fi
if [ -f @TERMUX_PREFIX@/lib/libtermux-exec.so ]; then
export LD_PRELOAD=@TERMUX_PREFIX@/lib/libtermux-exec.so

View File

@ -2,16 +2,19 @@
set -eu
declare -A commands_pkg=(
["debian"]="dpkg -L|apt show|select_mirror; update_apt_cache; apt install|apt autoclean|apt clean|apt list|apt list --installed|apt install --reinstall|select_mirror; update_apt_cache; apt search|apt remove|select_mirror; apt update; apt full-upgrade"
["apt"]="dpkg -L|apt show|select_mirror; update_apt_cache; apt install|apt autoclean|apt clean|apt list|apt list --installed|apt install --reinstall|select_mirror; update_apt_cache; apt search|apt remove|select_mirror; apt update; apt full-upgrade"
["pacman"]="pacman -Ql|pacman -Qi|pacman -Sy --needed|pacman -Sc|pacman -Scc|pacman -Sl|pacman -Q|pacman -S|pacman -Sys|pacman -Rcns|pacman -Syu"
)
# Setup TERMUX_APP_PACKAGE_MANAGER
source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
show_help() {
local cache_size
local cache_dir=""
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" ]; then
if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then
cache_dir="@TERMUX_CACHE_DIR@/apt/archives"
elif [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
elif [ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" ]; then
cache_dir="@TERMUX_PREFIX@/var/cache/pacman/pkg"
fi
cache_size=$(du -sh "$cache_dir" 2>/dev/null | cut -f1)
@ -194,9 +197,9 @@ if [ $# = 0 ]; then
show_help
fi
case "$TERMUX_MAIN_PACKAGE_FORMAT" in
debian|pacman) IFS="|" pkg_cmd=(${commands_pkg["$TERMUX_MAIN_PACKAGE_FORMAT"]});;
*) echo "Error: pkg is not supported with '$TERMUX_MAIN_PACKAGE_FORMAT' package manager format"; exit 1;;
case "${TERMUX_APP_PACKAGE_MANAGER-}" in
apt|pacman) IFS="|" pkg_cmd=(${commands_pkg["$TERMUX_APP_PACKAGE_MANAGER"]});;
*) echo "Error: pkg is not supported with '${TERMUX_APP_PACKAGE_MANAGER-}' package manager"; exit 1;;
esac
CMD="$1"

View File

@ -12,12 +12,12 @@ updates() {
if [ "$(id -u)" = "0" ]; then
echo "Running as root. Cannot check package updates."
else
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
pacman -Sy >/dev/null 2>&1
updatable=$(pacman -Qu)
else
if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then
apt update >/dev/null 2>&1
updatable=$(apt list --upgradable 2>/dev/null | tail -n +2)
elif [ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" ]; then
pacman -Sy >/dev/null 2>&1
updatable=$(pacman -Qu)
fi
if [ -z "$updatable" ];then
@ -69,6 +69,9 @@ repo_subscriptions_pacman() {
fi
}
# Setup TERMUX_APP_PACKAGE_MANAGER
source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
output=""
if [ -n "$TERMUX_VERSION" ]; then
@ -84,18 +87,18 @@ fi
output+="Packages CPU architecture:
$(
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
pacman-conf | grep Architecture | sed 's/Architecture = //g'
else
if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then
dpkg --print-architecture
elif [ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" ]; then
pacman-conf | grep Architecture | sed 's/Architecture = //g'
fi
)
Subscribed repositories:
$(
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
repo_subscriptions_pacman
else
if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then
repo_subscriptions_apt
elif [ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" ]; then
repo_subscriptions_pacman
fi
)
Updatable packages:

View File

@ -0,0 +1,20 @@
#!/bin/bash
# TERMUX_APP_PACKAGE_MANAGER should be exported by termux-app v0.119.0+
# itself and should contain "apt" or "pacman".
# TERMUX_MAIN_PACKAGE_FORMAT should be exported by login script in
# termux-tools v0.161+ if termux-app version is less than 0.119.0 and
# should contain "debian" or "pacman".
if [ -z "${TERMUX_APP_PACKAGE_MANAGER-}" ]; then
if [ -n "${TERMUX_MAIN_PACKAGE_FORMAT-}" ]; then
TERMUX_APP_PACKAGE_MANAGER="$([ "${TERMUX_MAIN_PACKAGE_FORMAT-}" = "debian" ] && echo "apt" || echo "${TERMUX_MAIN_PACKAGE_FORMAT-}")"
else
TERMUX_APP_PACKAGE_MANAGER="@TERMUX_PACKAGE_MANAGER@"
fi
fi
case "${TERMUX_APP_PACKAGE_MANAGER-}" in
apt|pacman) :;;
*) echo "Unsupported package manager \"${TERMUX_APP_PACKAGE_MANAGER-}\". Only 'apt' and 'pacman' managers are supported" 1>&2; exit 1;;
esac
export TERMUX_APP_PACKAGE_MANAGER

View File

@ -27,8 +27,8 @@ termux_setup_cabal() {
cabal update
else
if [[ "${TERMUX_MAIN_PACKAGE_FORMAT}" == "debian" ]] && "$(dpkg-query -W -f '${db:Status-Status}\n' cabal-install 2>/dev/null)" != "installed" ||
[[ "${TERMUX_MAIN_PACKAGE_FORMAT}" == "pacman" ]] && ! "$(pacman -Q cabal-install 2>/dev/null)"; then
if [[ "${TERMUX_APP_PACKAGE_MANAGER}" == "apt" ]] && "$(dpkg-query -W -f '${db:Status-Status}\n' cabal-install 2>/dev/null)" != "installed" ||
[[ "${TERMUX_APP_PACKAGE_MANAGER}" == "pacman" ]] && ! "$(pacman -Q cabal-install 2>/dev/null)"; then
echo "Package 'cabal-install' is not installed."
exit 1
fi

View File

@ -25,8 +25,8 @@ termux_setup_cmake() {
export PATH=$TERMUX_CMAKE_FOLDER/bin:$PATH
else
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
if [[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' cmake 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q cmake 2>/dev/null)" ]]; then
echo "Package 'cmake' is not installed."
echo "You can install it with"
echo

View File

@ -58,8 +58,8 @@ termux_setup_ghc() {
)
rm -Rf "$TERMUX_GHC_TEMP_FOLDER" "$TERMUX_GHC_TAR"
else
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
if [[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q ghc 2>/dev/null)" ]]; then
echo "Package 'ghc' is not installed."
exit 1
fi

View File

@ -124,8 +124,8 @@ termux_setup_ghc_cross_compiler() {
rm "${TERMUX_GHC_TAR}"
else
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
if [[ "${TERMUX_APP_PACKAGE_MANAGER}" == "apt" ]] && "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ||
[[ "${TERMUX_APP_PACKAGE_MANAGER}" == "pacman" ]] && ! "$(pacman -Q ghc 2>/dev/null)"; then
echo "Package 'ghc' is not installed."
exit 1
else

View File

@ -40,8 +40,8 @@ termux_setup_gn() {
fi
export PATH=$GN_FOLDER/out:$PATH
else
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
if [[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' gn 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q gn 2>/dev/null)" ]]; then
echo "Package 'gn' is not installed."
echo "You can install it with"
echo

View File

@ -26,8 +26,8 @@ termux_setup_golang() {
( cd "$TERMUX_BUILDGO_FOLDER"; . ${TERMUX_SCRIPTDIR}/packages/golang/fix-hardcoded-etc-resolv-conf.sh )
else
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
if [[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q golang 2>/dev/null)" ]]; then
echo "Package 'golang' is not installed."
echo "You can install it with"
echo

View File

@ -26,8 +26,8 @@ termux_setup_jailbreak_cabal() {
rm "${TERMUX_JAILBREAK_TAR}"
else
if [[ "${TERMUX_MAIN_PACKAGE_FORMAT}" == "debian" ]] && "$(dpkg-query -W -f '${db:Status-Status}\n' jailbreak-cabal 2>/dev/null)" != "installed" ||
[[ "${TERMUX_MAIN_PACKAGE_FORMAT}" = "pacman" ]] && ! "$(pacman -Q jailbreak-cabal 2>/dev/null)"; then
if [[ "${TERMUX_APP_PACKAGE_MANAGER}" == "apt" ]] && "$(dpkg-query -W -f '${db:Status-Status}\n' jailbreak-cabal 2>/dev/null)" != "installed" ||
[[ "${TERMUX_APP_PACKAGE_MANAGER}" = "pacman" ]] && ! "$(pacman -Q jailbreak-cabal 2>/dev/null)"; then
echo "Package 'jailbreak-cabal' is not installed."
exit 1
fi

View File

@ -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" ]) &&
([[ "$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
([[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' ninja 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q ninja 2>/dev/null)" ]]); then
echo "Package 'ninja' is not installed."
echo "You can install it with"
echo

View File

@ -23,8 +23,8 @@ termux_setup_nodejs() {
local NODEJS_PKG_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/nodejs/build.sh; echo \$TERMUX_PKG_VERSION")
if ([ ! -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/nodejs" ] ||
[ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/nodejs")" != "$NODEJS_PKG_VERSION" ]) &&
([[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" && "$(dpkg-query -W -f '${db:Status-Status}\n' nodejs 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" && ! "$(pacman -Q nodejs 2>/dev/null)" ]]); then
([[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' nodejs 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q nodejs 2>/dev/null)" ]]); then
echo "Package 'nodejs' is not installed."
echo "You can install it with"
echo

View File

@ -6,8 +6,8 @@ termux_setup_rust() {
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; 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
if [[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && ! "$(pacman -Q rust 2>/dev/null)" ]]; then
echo "Package 'rust' is not installed."
echo "You can install it with"
echo

View File

@ -5,8 +5,8 @@ termux_download_deb_pac() {
local VERSION_PACMAN=$4
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
case "$TERMUX_MAIN_PACKAGE_FORMAT" in
"debian") apt install -y "${PACKAGE}=${VERSION}";;
case "$TERMUX_APP_PACKAGE_MANAGER" in
"apt") apt install -y "${PACKAGE}=${VERSION}";;
"pacman") pacman -S "${PACKAGE}=${VERSION_PACMAN}" --needed --noconfirm;;
esac
return "$?"

View File

@ -5,8 +5,8 @@ termux_step_get_dependencies() {
# When doing build on device, ensure that apt lists are up-to-date.
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
case "$TERMUX_MAIN_PACKAGE_FORMAT" in
"debian") apt update;;
case "$TERMUX_APP_PACKAGE_MANAGER" in
"apt") apt update;;
"pacman") pacman -Sy;;
esac
fi

View File

@ -1,5 +1,4 @@
termux_step_setup_variables() {
: "${TERMUX_PACKAGE_FORMAT:="$([ ! -z "${TERMUX_MAIN_PACKAGE_FORMAT+x}" ] && 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"}"
@ -14,6 +13,20 @@ termux_step_setup_variables() {
: "${TERMUX_TOPDIR:="$HOME/.termux-build"}"
: "${TERMUX_PACMAN_PACKAGE_COMPRESSION:="xz"}"
if [ -z "${TERMUX_PACKAGE_FORMAT-}" ]; then
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && [ -n "${TERMUX_APP_PACKAGE_MANAGER-}" ]; then
TERMUX_PACKAGE_FORMAT="$([ "${TERMUX_APP_PACKAGE_MANAGER-}" = "apt" ] && echo "debian" || echo "${TERMUX_APP_PACKAGE_MANAGER-}")"
else
TERMUX_PACKAGE_FORMAT="debian"
fi
fi
case "${TERMUX_PACKAGE_FORMAT-}" in
debian) TERMUX_PACKAGE_MANAGER="apt";;
pacman) TERMUX_PACKAGE_MANAGER="pacman";;
*) termux_error_exit "Unsupported package format \"${TERMUX_PACKAGE_FORMAT-}\". Only 'debian' and 'pacman' formats are supported";;
esac
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.

View File

@ -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" ] &&
([[ "$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
([[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ]] ||
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "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