build-package: mv code for setting up src and build to to its own function

%ci:no-build
This commit is contained in:
Henrik Grimler 2021-08-24 08:22:54 +02:00
parent d1af6df63f
commit 6445645d7e
3 changed files with 35 additions and 23 deletions

View File

@ -103,6 +103,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_get_repo_files.sh"
# shellcheck source=scripts/build/termux_step_get_dependencies.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_get_dependencies.sh"
# Remove old src and build folders and create new ones
# shellcheck source=scripts/build/termux_step_setup_build_folders.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_setup_build_folders.sh"
# Source the package build script and start building. Not to be overridden by packages.
# shellcheck source=scripts/build/termux_step_start_build.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_start_build.sh"
@ -373,7 +377,13 @@ while (($# > 0)); do
termux_step_setup_variables
termux_step_handle_buildarch
if [ "$TERMUX_CONTINUE_BUILD" == "false" ]; then
termux_step_setup_build_folders
fi
termux_step_start_build
if [ "$TERMUX_CONTINUE_BUILD" == "false" ]; then
termux_step_get_dependencies
fi

View File

@ -0,0 +1,25 @@
termux_step_setup_build_folders() {
# Following directories may contain files with read-only permissions which
# makes them undeletable. We need to fix that.
[ -d "$TERMUX_PKG_BUILDDIR" ] && chmod +w -R "$TERMUX_PKG_BUILDDIR"
[ -d "$TERMUX_PKG_SRCDIR" ] && chmod +w -R "$TERMUX_PKG_SRCDIR"
# Cleanup old build state:
rm -Rf "$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_SRCDIR"
# Cleanup old packaging state:
rm -Rf "$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \
"$TERMUX_PKG_MASSAGEDIR"
# Ensure folders present (but not $TERMUX_PKG_SRCDIR, it will be created in build)
mkdir -p "$TERMUX_COMMON_CACHEDIR" \
"$TERMUX_DEBDIR" \
"$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \
"$TERMUX_PKG_CACHEDIR" \
"$TERMUX_PKG_MASSAGEDIR" \
$TERMUX_PREFIX/{bin,etc,lib,libexec,share,share/LICENSES,tmp,include}
}

View File

@ -92,29 +92,6 @@ termux_step_start_build() {
-e "s|@TERMUX_ARCH@|$TERMUX_ARCH|g" > $TERMUX_PREFIX/bin/llvm-config
chmod 755 $TERMUX_PREFIX/bin/llvm-config
fi
# Following directories may contain files with read-only permissions which
# makes them undeletable. We need to fix that.
[ -d "$TERMUX_PKG_BUILDDIR" ] && chmod +w -R "$TERMUX_PKG_BUILDDIR"
[ -d "$TERMUX_PKG_SRCDIR" ] && chmod +w -R "$TERMUX_PKG_SRCDIR"
# Cleanup old build state:
rm -Rf "$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_SRCDIR"
# Cleanup old packaging state:
rm -Rf "$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \
"$TERMUX_PKG_MASSAGEDIR"
# Ensure folders present (but not $TERMUX_PKG_SRCDIR, it will be created in build)
mkdir -p "$TERMUX_COMMON_CACHEDIR" \
"$TERMUX_DEBDIR" \
"$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \
"$TERMUX_PKG_CACHEDIR" \
"$TERMUX_PKG_MASSAGEDIR" \
$TERMUX_PREFIX/{bin,etc,lib,libexec,share,share/LICENSES,tmp,include}
# Make $TERMUX_PREFIX/bin/sh executable on the builder, so that build
# scripts can assume that it works on both builder and host later on: