build-package: mv code for getting deps out of step_start_build

Into new function termux_step_get_dependencies.
This commit is contained in:
Henrik Grimler 2021-08-21 18:02:31 +02:00
parent 2c70621a98
commit e34ae5da03
3 changed files with 74 additions and 67 deletions

View File

@ -103,6 +103,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_get_repo_files.sh"
# shellcheck source=scripts/build/termux_step_start_build.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_start_build.sh"
# Download or build dependencies. Not to be overridden by packages.
# shellcheck source=scripts/build/termux_step_get_dependencies.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_get_dependencies.sh"
# Run just after sourcing $TERMUX_PKG_BUILDER_SCRIPT. Can be overridden by packages.
# shellcheck source=scripts/build/get_source/termux_step_get_source.sh
source "$TERMUX_SCRIPTDIR/scripts/build/get_source/termux_step_get_source.sh"
@ -365,6 +369,7 @@ while (($# > 0)); do
termux_step_setup_variables
termux_step_handle_buildarch
termux_step_start_build
termux_step_get_dependencies
cd "$TERMUX_PKG_CACHEDIR"
termux_step_get_source
cd "$TERMUX_PKG_SRCDIR"

View File

@ -0,0 +1,69 @@
termux_step_get_dependencies() {
if [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = true ] && [ "$TERMUX_PKG_METAPACKAGE" = "false" ]; then
# Download repo files
termux_get_repo_files
# When doing build on device, ensure that apt lists are up-to-date.
[ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && apt update
# Download dependencies
while read PKG PKG_DIR; do
if [ -z $PKG ]; then
continue
elif [ "$PKG" = "ERROR" ]; then
termux_error_exit "Obtaining buildorder failed"
fi
# llvm doesn't build if ndk-sysroot is installed:
if [ "$PKG" = "ndk-sysroot" ]; then continue; fi
read DEP_ARCH DEP_VERSION <<< $(termux_extract_dep_info $PKG "${PKG_DIR}")
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Downloading dependency $PKG@$DEP_VERSION if necessary..."
fi
if [ -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG" ]; then
if [ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG")" = "$DEP_VERSION" ]; then
continue
fi
fi
if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then
echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead"
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I "${PKG_DIR}"
continue
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "extracting $PKG..."
fi
(
cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH
ar x ${PKG}_${DEP_VERSION}_${DEP_ARCH}.deb data.tar.xz
if tar -tf data.tar.xz|grep "^./$">/dev/null; then
# Strip prefixed ./, to avoid possible
# permission errors from tar
tar -xf data.tar.xz --strip-components=1 \
--no-overwrite-dir -C /
else
tar -xf data.tar.xz --no-overwrite-dir -C /
fi
)
fi
mkdir -p $TERMUX_BUILT_PACKAGES_DIRECTORY
echo "$DEP_VERSION" > "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG"
done<<<$(./scripts/buildorder.py -i "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR")
elif [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = false ] && [ "$TERMUX_PKG_METAPACKAGE" = "false" ]; then
# Build dependencies
while read PKG PKG_DIR; do
if [ -z $PKG ]; then
continue
elif [ "$PKG" = "ERROR" ]; then
termux_error_exit "Obtaining buildorder failed"
fi
echo "Building dependency $PKG if necessary..."
# Built dependencies are put in the default TERMUX_DEBDIR instead of the specified one
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -s "${PKG_DIR}"
done<<<$(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR")
fi
}

View File

@ -47,73 +47,6 @@ termux_step_start_build() {
fi
fi
if [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = true ] && [ "$TERMUX_PKG_METAPACKAGE" = "false" ]; then
# Download repo files
termux_get_repo_files
# When doing build on device, ensure that apt lists are up-to-date.
[ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && apt update
# Download dependencies
while read PKG PKG_DIR; do
if [ -z $PKG ]; then
continue
elif [ "$PKG" = "ERROR" ]; then
termux_error_exit "Obtaining buildorder failed"
fi
# llvm doesn't build if ndk-sysroot is installed:
if [ "$PKG" = "ndk-sysroot" ]; then continue; fi
read DEP_ARCH DEP_VERSION <<< $(termux_extract_dep_info $PKG "${PKG_DIR}")
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Downloading dependency $PKG@$DEP_VERSION if necessary..."
fi
if [ -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG" ]; then
if [ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG")" = "$DEP_VERSION" ]; then
continue
fi
fi
if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then
echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead"
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I "${PKG_DIR}"
continue
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "extracting $PKG..."
fi
(
cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH
ar x ${PKG}_${DEP_VERSION}_${DEP_ARCH}.deb data.tar.xz
if tar -tf data.tar.xz|grep "^./$">/dev/null; then
# Strip prefixed ./, to avoid possible
# permission errors from tar
tar -xf data.tar.xz --strip-components=1 \
--no-overwrite-dir -C /
else
tar -xf data.tar.xz --no-overwrite-dir -C /
fi
)
fi
mkdir -p $TERMUX_BUILT_PACKAGES_DIRECTORY
echo "$DEP_VERSION" > "$TERMUX_BUILT_PACKAGES_DIRECTORY/$PKG"
done<<<$(./scripts/buildorder.py -i "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR")
elif [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = false ] && [ "$TERMUX_PKG_METAPACKAGE" = "false" ]; then
# Build dependencies
while read PKG PKG_DIR; do
if [ -z $PKG ]; then
continue
elif [ "$PKG" = "ERROR" ]; then
termux_error_exit "Obtaining buildorder failed"
fi
echo "Building dependency $PKG if necessary..."
# Built dependencies are put in the default TERMUX_DEBDIR instead of the specified one
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -s "${PKG_DIR}"
done<<<$(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR")
fi
if [ "$TERMUX_INSTALL_DEPS" == true ] && [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libllvm/}" ]; then
LLVM_DEFAULT_TARGET_TRIPLE=$TERMUX_HOST_PLATFORM
if [ $TERMUX_ARCH = "arm" ]; then