fix(build-package.sh): Do not use dependencies while building from repo if it hosts packages built for a different package name than TERMUX_APP_PACKAGE

This commit is contained in:
agnostic-apollo 2022-07-22 16:54:04 +05:00
parent ea66e0a7c7
commit cd2928cbe1
4 changed files with 29 additions and 4 deletions

View File

@ -419,6 +419,13 @@ while (($# >= 1)); do
done
unset -f _show_usage
# Dependencies should be used from repo only if they are built for
# same package name.
if [ "$TERMUX_REPO_PACKAGE" != "$TERMUX_APP_PACKAGE" ]; then
echo "Ignoring -i option to download dependencies since repo package name ($TERMUX_REPO_PACKAGE) does not equal app package name ($TERMUX_APP_PACKAGE)"
TERMUX_INSTALL_DEPS=false
fi
if [ -n "${TERMUX_PACKAGE_FORMAT-}" ]; then
case "${TERMUX_PACKAGE_FORMAT-}" in
debian|pacman) :;;

View File

@ -6,6 +6,19 @@ termux_download_deb_pac() {
local VERSION=$3
local VERSION_PACMAN=$4
local DEB_FILE="${PACKAGE}_${VERSION}_${PACKAGE_ARCH}.deb"
PKG_HASH=""
# Dependencies should be used from repo only if they are built for
# same package name.
# The data.tar.xz extraction by termux_step_get_dependencies would
# extract files to different prefix than TERMUX_PREFIX and builds
# would fail when looking for -I$TERMUX_PREFIX/include files.
if [ "$TERMUX_REPO_PACKAGE" != "$TERMUX_APP_PACKAGE" ]; then
echo "Ignoring download of $DEB_FILE since repo package name ($TERMUX_REPO_PACKAGE) does not equal app package name ($TERMUX_APP_PACKAGE)"
return 1
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
case "$TERMUX_APP_PACKAGE_MANAGER" in
"apt") apt install -y "${PACKAGE}=${VERSION}";;
@ -14,9 +27,6 @@ termux_download_deb_pac() {
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"

View File

@ -28,6 +28,9 @@ termux_step_get_dependencies() {
if [ -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG" ]; then
if [ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG")" = "$DEP_VERSION" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Skipping already built dependency $PKG@$DEP_VERSION"
fi
continue
fi
fi
@ -39,7 +42,7 @@ termux_step_get_dependencies() {
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "extracting $PKG..."
echo "extracting $PKG to $TERMUX_COMMON_CACHEDIR-$DEP_ARCH..."
fi
(
cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH

View File

@ -32,6 +32,11 @@ TERMUX_ANDROID_HOME="${TERMUX_BASE_DIR}/home"
TERMUX_APPS_DIR="${TERMUX_BASE_DIR}/apps"
TERMUX_PREFIX="${TERMUX_BASE_DIR}/usr"
# Package name for the packages hosted on the repo.
# This must only equal TERMUX_APP_PACKAGE if using custom repo that
# has packages that were built with same package name.
TERMUX_REPO_PACKAGE="com.termux"
# Termux repo urls.
TERMUX_REPO_URL=(
https://packages-cf.termux.dev/apt/termux-main