termux-packages/scripts/build/termux_download_deb.sh
Leonid Pliushch c352216c63 packages: standardize values of several control variables for build.sh
Variables

 TERMUX_PKG_PLATFORM_INDEPENDENT
 TERMUX_DEBUG
 TERMUX_PKG_HAS_DEBUG
 TERMUX_PKG_ESSENTIAL
 TERMUX_SUBPKG_ESSENTIAL
 TERMUX_PKG_NO_STATICSPLIT
 TERMUX_PKG_BUILD_IN_SRC
 TERMUX_PKG_FORCE_CMAKE
 TERMUX_PKG_HOSTBUILD

should not accept arbitrary values for marking them "enabled". Instead
they should accept boolean values which makes them easier to handle and
also makes their meaning clear.

build-package.sh should make decision based on variable's value but not on
whether it is set or empty.

%ci:no-build
2019-08-12 18:49:13 +03:00

42 lines
1.3 KiB
Bash
Executable File

termux_download_deb() {
local PACKAGE=$1
local PACKAGE_ARCH=$2
local VERSION=$3
if $TERMUX_ON_DEVICE_BUILD; then
apt install -y "${PACKAGE}=${VERSION}"
return "$?"
fi
local DEB_FILE=${PACKAGE}_${VERSION}_${PACKAGE_ARCH}.deb
PKG_HASH=""
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"
if [ -f "${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/${PACKAGE_FILE_PATH}" ]; then
read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/$PACKAGE_FILE_PATH" $PACKAGE $VERSION)
if [ ! -z "$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
fi
done
if [ "$PKG_HASH" = "" ]; then
return 1
else
termux_download ${TERMUX_REPO_URL[$idx-1]}/${PKG_PATH} \
$TERMUX_COMMON_CACHEDIR-$PACKAGE_ARCH/${DEB_FILE} \
$PKG_HASH
return 0
fi
}
# Make script standalone executable as well as sourceable
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
termux_download "$@"
fi