2022-01-14 14:16:37 +01:00
|
|
|
termux_download_deb_pac() {
|
2019-03-03 10:30:04 +01:00
|
|
|
local PACKAGE=$1
|
|
|
|
local PACKAGE_ARCH=$2
|
|
|
|
local VERSION=$3
|
2022-01-14 14:16:37 +01:00
|
|
|
local VERSION_PACMAN=$4
|
2019-08-06 14:39:42 +02:00
|
|
|
|
2019-08-12 23:16:07 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
2022-02-02 15:45:36 +01:00
|
|
|
case "$TERMUX_MAIN_PACKAGE_FORMAT" in
|
|
|
|
"debian") apt install -y "${PACKAGE}=${VERSION}";;
|
|
|
|
"pacman") pacman -S "${PACKAGE}=${VERSION_PACMAN}" --needed --noconfirm;;
|
|
|
|
esac
|
2019-08-06 14:39:42 +02:00
|
|
|
return "$?"
|
|
|
|
fi
|
|
|
|
|
2020-08-21 14:39:06 +02:00
|
|
|
local DEB_FILE="${PACKAGE}_${VERSION}_${PACKAGE_ARCH}.deb"
|
2019-03-03 10:30:04 +01:00
|
|
|
PKG_HASH=""
|
2019-08-06 14:39:42 +02:00
|
|
|
|
2019-02-26 21:39:58 +01:00
|
|
|
for idx in $(seq ${#TERMUX_REPO_URL[@]}); do
|
|
|
|
local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/%-%g')
|
|
|
|
local PACKAGE_FILE_PATH="${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages"
|
2022-03-02 23:46:06 +01:00
|
|
|
if [ "${PACKAGE_ARCH}" = 'all' ]; then
|
|
|
|
for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do
|
|
|
|
if [ -f "${TERMUX_COMMON_CACHEDIR}-${arch}/${PACKAGE_FILE_PATH}" ]; then
|
|
|
|
read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-${arch}/$PACKAGE_FILE_PATH" $PACKAGE $VERSION)
|
|
|
|
if [ -n "$PKG_HASH" ]; then
|
|
|
|
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
|
|
|
|
echo "Found $PACKAGE in ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}"
|
|
|
|
fi
|
|
|
|
break 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif [ ! -f "${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/${PACKAGE_FILE_PATH}" ] && \
|
2021-05-14 11:58:09 +02:00
|
|
|
[ -f "${TERMUX_COMMON_CACHEDIR}-aarch64/${PACKAGE_FILE_PATH}" ]; then
|
|
|
|
# Packages file for $PACKAGE_ARCH did not
|
|
|
|
# exist. Could be an aptly mirror where the
|
|
|
|
# all arch is mixed into the other arches,
|
|
|
|
# check for package in aarch64 Packages
|
|
|
|
# instead.
|
|
|
|
read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-aarch64/$PACKAGE_FILE_PATH" $PACKAGE $VERSION)
|
|
|
|
if [ -n "$PKG_HASH" ]; then
|
|
|
|
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
|
|
|
|
echo "Found $PACKAGE in ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}"
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
elif [ -f "${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/${PACKAGE_FILE_PATH}" ]; then
|
2019-03-03 10:30:04 +01:00
|
|
|
read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/$PACKAGE_FILE_PATH" $PACKAGE $VERSION)
|
2019-08-13 00:39:35 +02:00
|
|
|
if [ -n "$PKG_HASH" ]; then
|
2019-03-03 10:30:04 +01:00
|
|
|
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
|
|
|
|
echo "Found $PACKAGE in ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}"
|
|
|
|
fi
|
|
|
|
break
|
2019-02-26 21:39:58 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2019-08-06 14:39:42 +02:00
|
|
|
|
2019-02-26 21:39:58 +01:00
|
|
|
if [ "$PKG_HASH" = "" ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2020-08-21 14:39:06 +02:00
|
|
|
|
|
|
|
termux_download "${TERMUX_REPO_URL[${idx}-1]}/${PKG_PATH}" \
|
|
|
|
"${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/${DEB_FILE}" \
|
|
|
|
"$PKG_HASH"
|
2019-02-26 21:39:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Make script standalone executable as well as sourceable
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
|
|
termux_download "$@"
|
|
|
|
fi
|