2019-02-26 20:41:19 +00:00
|
|
|
termux_step_start_build() {
|
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "$TERMUX_PKG_BUILDER_SCRIPT"
|
2021-08-21 17:18:37 +00:00
|
|
|
# Path to hostbuild marker, for use if package has hostbuild step
|
|
|
|
TERMUX_HOSTBUILD_MARKER="$TERMUX_PKG_HOSTBUILD_DIR/TERMUX_BUILT_FOR_$TERMUX_PKG_VERSION"
|
2019-02-26 20:41:19 +00:00
|
|
|
|
2019-08-14 17:29:58 +00:00
|
|
|
if [ "$TERMUX_PKG_METAPACKAGE" = "true" ]; then
|
|
|
|
# Metapackage has no sources and therefore platform-independent.
|
|
|
|
TERMUX_PKG_SKIP_SRC_EXTRACT=true
|
|
|
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
|
|
|
fi
|
|
|
|
|
2019-02-26 20:41:19 +00:00
|
|
|
if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then
|
|
|
|
echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-04-21 15:05:39 +00:00
|
|
|
TERMUX_PKG_FULLVERSION=$TERMUX_PKG_VERSION
|
|
|
|
if [ "$TERMUX_PKG_REVISION" != "0" ] || [ "$TERMUX_PKG_FULLVERSION" != "${TERMUX_PKG_FULLVERSION/-/}" ]; then
|
|
|
|
# "0" is the default revision, so only include it if the upstream versions contains "-" itself
|
|
|
|
TERMUX_PKG_FULLVERSION+="-$TERMUX_PKG_REVISION"
|
|
|
|
fi
|
2022-01-14 13:16:37 +00:00
|
|
|
# full format version for pacman
|
|
|
|
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION//-/.}
|
|
|
|
local INCORRECT_SYMBOLS=$(echo $TERMUX_PKG_VERSION_EDITED | grep -o '[0-9][a-z]')
|
|
|
|
if [ -n "$INCORRECT_SYMBOLS" ]; then
|
|
|
|
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION_EDITED//${INCORRECT_SYMBOLS:0:1}${INCORRECT_SYMBOLS:1:1}/${INCORRECT_SYMBOLS:0:1}.${INCORRECT_SYMBOLS:1:1}}
|
|
|
|
fi
|
|
|
|
TERMUX_PKG_FULLVERSION_FOR_PACMAN="${TERMUX_PKG_VERSION_EDITED}"
|
|
|
|
if [ -n "$TERMUX_PKG_REVISION" ]; then
|
|
|
|
TERMUX_PKG_FULLVERSION_FOR_PACMAN+="-${TERMUX_PKG_REVISION}"
|
|
|
|
else
|
|
|
|
TERMUX_PKG_FULLVERSION_FOR_PACMAN+="-0"
|
|
|
|
fi
|
2019-04-21 15:05:39 +00:00
|
|
|
|
2021-08-21 14:50:05 +00:00
|
|
|
if [ "$TERMUX_DEBUG_BUILD" = "true" ]; then
|
2019-08-12 21:16:07 +00:00
|
|
|
if [ "$TERMUX_PKG_HAS_DEBUG" = "true" ]; then
|
2019-04-21 15:05:39 +00:00
|
|
|
DEBUG="-dbg"
|
|
|
|
else
|
|
|
|
echo "Skipping building debug build for $TERMUX_PKG_NAME"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
DEBUG=""
|
|
|
|
fi
|
|
|
|
|
2021-08-21 14:50:05 +00:00
|
|
|
if [ "$TERMUX_DEBUG_BUILD" = "false" ] && [ "$TERMUX_FORCE_BUILD" = "false" ]; then
|
2019-08-06 12:39:42 +00:00
|
|
|
if [ -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME" ] &&
|
2021-02-03 09:43:39 +00:00
|
|
|
[ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME")" = "$TERMUX_PKG_FULLVERSION" ]; then
|
2019-08-06 12:39:42 +00:00
|
|
|
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm $TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME to force rebuild)"
|
|
|
|
exit 0
|
2019-08-12 21:16:07 +00:00
|
|
|
elif [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] &&
|
2022-05-22 18:00:24 +00:00
|
|
|
([[ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" && "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ]] ||
|
|
|
|
[[ "$TERMUX_APP_PACKAGE_MANAGER" = "pacman" && "$(pacman -Q $TERMUX_PKG_NAME 2>/dev/null)" = "$TERMUX_PKG_NAME $TERMUX_PKG_FULLVERSION_FOR_PACMAN" ]]); then
|
2019-08-06 12:39:42 +00:00
|
|
|
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION installed - skipping"
|
2019-04-21 15:05:39 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-08-21 16:08:57 +00:00
|
|
|
echo "termux - building $TERMUX_PKG_NAME for arch $TERMUX_ARCH..."
|
|
|
|
test -t 1 && printf "\033]0;%s...\007" "$TERMUX_PKG_NAME"
|
|
|
|
|
|
|
|
# Avoid exporting PKG_CONFIG_LIBDIR until after termux_step_host_build.
|
2022-11-09 07:41:50 +00:00
|
|
|
export TERMUX_PKG_CONFIG_LIBDIR=$TERMUX_PREFIX/lib/pkgconfig:$TERMUX_PREFIX/share/pkgconfig
|
2021-08-21 16:08:57 +00:00
|
|
|
|
|
|
|
if [ "$TERMUX_PKG_BUILD_IN_SRC" = "true" ]; then
|
|
|
|
echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set to true" > "$TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt"
|
|
|
|
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TERMUX_CONTINUE_BUILD" == "true" ]; then
|
2021-08-21 17:18:37 +00:00
|
|
|
# If the package has a hostbuild step, verify that it has been built
|
|
|
|
if [ "$TERMUX_PKG_HOSTBUILD" == "true" ] && [ ! -f "$TERMUX_HOSTBUILD_MARKER" ]; then
|
|
|
|
termux_error_exit "Cannot continue this build, hostbuilt tools are missing"
|
|
|
|
fi
|
|
|
|
|
2021-08-22 10:48:47 +00:00
|
|
|
# The rest in this function can be skipped when doing
|
|
|
|
# a continued build
|
2021-08-21 16:08:57 +00:00
|
|
|
return
|
|
|
|
fi
|
2023-01-03 14:57:00 +00:00
|
|
|
|
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && [ "$TERMUX_PKG_ON_DEVICE_BUILD_NOT_SUPPORTED" = "true" ]; then
|
|
|
|
termux_error_exit "Package '$TERMUX_PKG_NAME' is not available for on-device builds."
|
|
|
|
fi
|
|
|
|
|
2022-07-31 14:46:49 +00:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
|
|
|
case "$TERMUX_APP_PACKAGE_MANAGER" in
|
2022-07-31 16:59:47 +00:00
|
|
|
"apt") apt install -y termux-elf-cleaner;;
|
2022-07-31 14:46:49 +00:00
|
|
|
"pacman") pacman -S termux-elf-cleaner --needed --noconfirm;;
|
|
|
|
esac
|
|
|
|
TERMUX_ELF_CLEANER="$(command -v termux-elf-cleaner)"
|
|
|
|
else
|
|
|
|
local TERMUX_ELF_CLEANER_VERSION
|
|
|
|
TERMUX_ELF_CLEANER_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/termux-elf-cleaner/build.sh; echo \$TERMUX_PKG_VERSION")
|
|
|
|
termux_download \
|
|
|
|
"https://github.com/termux/termux-elf-cleaner/releases/download/v${TERMUX_ELF_CLEANER_VERSION}/termux-elf-cleaner" \
|
|
|
|
"$TERMUX_ELF_CLEANER" \
|
|
|
|
7c29143b9cffb3a9a580f39a7966b2bb36c5fc099da6f4c98dcdedacb14f08a2
|
|
|
|
chmod u+x "$TERMUX_ELF_CLEANER"
|
|
|
|
fi
|
2019-02-26 20:41:19 +00:00
|
|
|
}
|