Merge pull request #7440 from termux/pacman-format

Introduce build-package.sh option "--format" which allows to select package output format between debian (default) and pacman. This also introduces a change to default package output directory, now it is named "./output" instead of "./debs".

Repositories using termux-packages as submodule should adjust their GitHub Actions workflows to fix name of package output dir.

This pull request does not add pacman package manager. Also there no support of libalpm hooks (analog of dpkg triggers).
This commit is contained in:
Leonid Pliushch 2021-09-10 20:12:36 +03:00 committed by GitHub
commit 2c36fb5284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 486 additions and 97 deletions

View File

@ -118,7 +118,7 @@ jobs:
if [ -f ./built_packages.txt ]; then if [ -f ./built_packages.txt ]; then
./scripts/lint-packages.sh $(cat ./built_packages.txt | awk '{print "packages/"$1"/build.sh"}') ./scripts/lint-packages.sh $(cat ./built_packages.txt | awk '{print "packages/"$1"/build.sh"}')
./scripts/run-docker.sh ./build-package.sh -I -a ${{ matrix.target_arch }} $(cat ./built_packages.txt) ./scripts/run-docker.sh ./build-package.sh -o ./debs -I -a ${{ matrix.target_arch }} $(cat ./built_packages.txt)
fi fi
test -d ./termux-packages/debs && mv ./termux-packages/debs/* ./debs/ test -d ./termux-packages/debs && mv ./termux-packages/debs/* ./debs/

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ scripts/.vagrant/
# Built *.deb files. # Built *.deb files.
/debs/ /debs/
/output/
# Preinstalled build tools. # Preinstalled build tools.
/build-tools/ /build-tools/

View File

@ -31,7 +31,7 @@ case "$option" in
a) TERMUX_ARCH="$OPTARG";; a) TERMUX_ARCH="$OPTARG";;
d) TERMUX_DEBUG_BUILD='-d';; d) TERMUX_DEBUG_BUILD='-d';;
i) TERMUX_INSTALL_DEPS='-i';; i) TERMUX_INSTALL_DEPS='-i';;
o) TERMUX_DEBDIR="$(realpath -m "$OPTARG")";; o) TERMUX_OUTPUT_DIR="$(realpath -m "$OPTARG")";;
h) _show_usage;; h) _show_usage;;
*) _show_usage >&2 ;; *) _show_usage >&2 ;;
esac esac
@ -73,7 +73,7 @@ while read -r PKG PKG_DIR; do
echo -n "Building $PKG... " echo -n "Building $PKG... "
BUILD_START=$(date "+%s") BUILD_START=$(date "+%s")
bash -x "$BUILDSCRIPT" -a "$TERMUX_ARCH" $TERMUX_DEBUG_BUILD \ bash -x "$BUILDSCRIPT" -a "$TERMUX_ARCH" $TERMUX_DEBUG_BUILD \
${TERMUX_DEBDIR+-o $TERMUX_DEBDIR} $TERMUX_INSTALL_DEPS "$PKG_DIR" \ ${TERMUX_OUTPUT_DIR+-o $TERMUX_OUTPUT_DIR} $TERMUX_INSTALL_DEPS "$PKG_DIR" \
> "$BUILDALL_DIR"/"${PKG}".out 2> "$BUILDALL_DIR"/"${PKG}".err > "$BUILDALL_DIR"/"${PKG}".out 2> "$BUILDALL_DIR"/"${PKG}".err
BUILD_END=$(date "+%s") BUILD_END=$(date "+%s")
BUILD_SECONDS=$(( BUILD_END - BUILD_START )) BUILD_SECONDS=$(( BUILD_END - BUILD_START ))

View File

@ -219,8 +219,12 @@ termux_step_create_subpkg_debscripts() {
} }
# Create all subpackages. Run from termux_step_massage # Create all subpackages. Run from termux_step_massage
# shellcheck source=scripts/build/termux_create_subpackages.sh # shellcheck source=scripts/build/termux_create_debian_subpackages.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_create_subpackages.sh" source "$TERMUX_SCRIPTDIR/scripts/build/termux_create_debian_subpackages.sh"
# Create all subpackages. Run from termux_step_massage
# shellcheck source=scripts/build/termux_create_pacman_subpackages.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_create_pacman_subpackages.sh"
# Function to run various cleanup/fixes # Function to run various cleanup/fixes
# shellcheck source=scripts/build/termux_step_massage.sh # shellcheck source=scripts/build/termux_step_massage.sh
@ -231,18 +235,23 @@ termux_step_post_massage() {
return return
} }
# Create data.tar.gz with files to package. Not to be overridden by package scripts.
# shellcheck source=scripts/build/termux_step_create_datatar.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_datatar.sh"
# Hook function to create {pre,post}install, {pre,post}rm-scripts and similar # Hook function to create {pre,post}install, {pre,post}rm-scripts and similar
termux_step_create_debscripts() { termux_step_create_debscripts() {
return return
} }
# Convert Debian maintainer scripts into pacman-compatible installation hooks.
# This is used only when creating pacman packages.
# shellcheck source=scripts/build/termux_step_create_pacman_install_hook.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_pacman_install_hook.sh"
# Create the build deb file. Not to be overridden by package scripts. # Create the build deb file. Not to be overridden by package scripts.
# shellcheck source=scripts/build/termux_step_create_debfile.sh # shellcheck source=scripts/build/termux_step_create_debian_package.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_debfile.sh" source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_debian_package.sh"
# Create the build .pkg.tar.xz file. Not to be overridden by package scripts.
# shellcheck source=scripts/build/termux_step_create_pacman_package.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_pacman_package.sh"
# Finish the build. Not to be overridden by package scripts. # Finish the build. Not to be overridden by package scripts.
# shellcheck source=scripts/build/termux_step_finish_build.sh # shellcheck source=scripts/build/termux_step_finish_build.sh
@ -280,41 +289,78 @@ _show_usage() {
echo " -I Download and extract dependencies instead of building them, keep existing $TERMUX_BASE_DIR files." echo " -I Download and extract dependencies instead of building them, keep existing $TERMUX_BASE_DIR files."
echo " -q Quiet build." echo " -q Quiet build."
echo " -s Skip dependency check." echo " -s Skip dependency check."
echo " -o Specify deb directory. Default: debs/." echo " -o Specify directory where to put built packages. Default: output/."
echo " --format Specify package output format (debian, pacman)."
exit 1 exit 1
} }
while getopts :a:hdDfiIqso:c option; do declare -a PACKAGE_LIST=()
case "$option" in
a) if [ "$#" -lt 1 ]; then _show_usage; fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then while (($# >= 1)); do
termux_error_exit "./build-package.sh: option '-a' is not available for on-device builds" case "$1" in
--) shift 1; break;;
-h|--help) _show_usage;;
--format)
if [ $# -ge 2 ]; then
shift 1
if [ -z "$1" ]; then
termux_error_exit "./build-package.sh: argument to '--format' should not be empty"
fi
case "$1" in
debian|pacman) TERMUX_PACKAGE_FORMAT="$1";;
*) termux_error_exit "./build-package.sh: only 'debian' and 'pacman' formats are supported";;
esac
else else
export TERMUX_ARCH="$OPTARG" termux_error_exit "./build-package.sh: option '--format' requires an argument"
fi fi
;; ;;
h) _show_usage;; -a)
d) export TERMUX_DEBUG_BUILD=true;; if [ $# -ge 2 ]; then
D) TERMUX_IS_DISABLED=true;; shift 1
f) TERMUX_FORCE_BUILD=true;; if [ -z "$1" ]; then
i) termux_error_exit "Argument to '-a' should not be empty."
fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
termux_error_exit "./build-package.sh: option '-a' is not available for on-device builds"
else
export TERMUX_ARCH="$1"
fi
else
termux_error_exit "./build-package.sh: option '-a' requires an argument"
fi
;;
-d) export TERMUX_DEBUG_BUILD=true;;
-D) TERMUX_IS_DISABLED=true;;
-f) TERMUX_FORCE_BUILD=true;;
-i)
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
termux_error_exit "./build-package.sh: option '-i' is not available for on-device builds" termux_error_exit "./build-package.sh: option '-i' is not available for on-device builds"
else else
export TERMUX_INSTALL_DEPS=true export TERMUX_INSTALL_DEPS=true
fi fi
;; ;;
I) export TERMUX_INSTALL_DEPS=true && export TERMUX_NO_CLEAN=true;; -I) export TERMUX_INSTALL_DEPS=true && export TERMUX_NO_CLEAN=true;;
q) export TERMUX_QUIET_BUILD=true;; -q) export TERMUX_QUIET_BUILD=true;;
s) export TERMUX_SKIP_DEPCHECK=true;; -s) export TERMUX_SKIP_DEPCHECK=true;;
o) TERMUX_DEBDIR=$(realpath -m "$OPTARG");; -o)
c) TERMUX_CONTINUE_BUILD="true";; if [ $# -ge 2 ]; then
?) termux_error_exit "./build-package.sh: illegal option -$OPTARG";; shift 1
if [ -z "$1" ]; then
termux_error_exit "./build-package.sh: argument to '-o' should not be empty"
fi
TERMUX_OUTPUT_DIR=$(realpath -m "$1")
else
termux_error_exit "./build-package.sh: option '-o' requires an argument"
fi
;;
-c) TERMUX_CONTINUE_BUILD=true;;
-*) termux_error_exit "./build-package.sh: illegal option '$1'";;
*) PACKAGE_LIST+=("$1");;
esac esac
shift 1
done done
shift $((OPTIND-1))
if [ "$#" -lt 1 ]; then _show_usage; fi
unset -f _show_usage unset -f _show_usage
if [ "${TERMUX_INSTALL_DEPS-false}" = "true" ]; then if [ "${TERMUX_INSTALL_DEPS-false}" = "true" ]; then
@ -338,7 +384,7 @@ if [ "${TERMUX_INSTALL_DEPS-false}" = "true" ]; then
} }
fi fi
while (($# > 0)); do for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do
# Following commands must be executed under lock to prevent running # Following commands must be executed under lock to prevent running
# multiple instances of "./build-package.sh". # multiple instances of "./build-package.sh".
# #
@ -354,18 +400,19 @@ while (($# > 0)); do
for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do
env TERMUX_ARCH="$arch" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh \ env TERMUX_ARCH="$arch" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh \
${TERMUX_FORCE_BUILD+-f} ${TERMUX_INSTALL_DEPS+-i} ${TERMUX_IS_DISABLED+-D} \ ${TERMUX_FORCE_BUILD+-f} ${TERMUX_INSTALL_DEPS+-i} ${TERMUX_IS_DISABLED+-D} \
${TERMUX_DEBUG_BUILD+-d} ${TERMUX_DEBDIR+-o $TERMUX_DEBDIR} "$1" ${TERMUX_DEBUG_BUILD+-d} ${TERMUX_OUTPUT_DIR+-o $TERMUX_OUTPUT_DIR} \
--format ${TERMUX_PACKAGE_FORMAT} "${PACKAGE_LIST[i]}"
done done
exit exit
fi fi
# Check the package to build: # Check the package to build:
TERMUX_PKG_NAME=$(basename "$1") TERMUX_PKG_NAME=$(basename "${PACKAGE_LIST[i]}")
if [[ $1 == *"/"* ]]; then if [[ ${PACKAGE_LIST[i]} == *"/"* ]]; then
# Path to directory which may be outside this repo: # Path to directory which may be outside this repo:
if [ ! -d "$1" ]; then termux_error_exit "'$1' seems to be a path but is not a directory"; fi if [ ! -d "${PACKAGE_LIST[i]}" ]; then termux_error_exit "'${PACKAGE_LIST[i]}' seems to be a path but is not a directory"; fi
export TERMUX_PKG_BUILDER_DIR export TERMUX_PKG_BUILDER_DIR
TERMUX_PKG_BUILDER_DIR=$(realpath "$1") TERMUX_PKG_BUILDER_DIR=$(realpath "${PACKAGE_LIST[i]}")
else else
# Package name: # Package name:
if [ -n "${TERMUX_IS_DISABLED=""}" ]; then if [ -n "${TERMUX_IS_DISABLED=""}" ]; then
@ -434,10 +481,13 @@ while (($# > 0)); do
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX" cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
termux_step_post_massage termux_step_post_massage
cd "$TERMUX_PKG_MASSAGEDIR" cd "$TERMUX_PKG_MASSAGEDIR"
termux_step_create_datatar if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ]; then
termux_step_create_debfile termux_step_create_debian_package
elif [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
termux_step_create_pacman_package
else
termux_error_exit "Unknown packaging format '$TERMUX_PACKAGE_FORMAT'."
fi
termux_step_finish_build termux_step_finish_build
) 5< "$TERMUX_BUILD_LOCK_FILE" ) 5< "$TERMUX_BUILD_LOCK_FILE"
shift 1
done done

View File

@ -110,7 +110,7 @@ termux_step_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ]; then
if [ ! -e "$TERMUX_PREFIX/etc/xml/catalog" ]; then if [ ! -e "$TERMUX_PREFIX/etc/xml/catalog" ]; then
xmlcatalog --noout --create "$TERMUX_PREFIX/etc/xml/catalog" xmlcatalog --noout --create "$TERMUX_PREFIX/etc/xml/catalog"
else else
@ -138,7 +138,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "remove" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "remove" ]; then
xmlcatalog --noout --del "file://$TERMUX_PREFIX/etc/xml/docbook-xml" \ xmlcatalog --noout --del "file://$TERMUX_PREFIX/etc/xml/docbook-xml" \
$TERMUX_PREFIX/etc/xml/catalog $TERMUX_PREFIX/etc/xml/catalog
fi fi

View File

@ -60,7 +60,7 @@ termux_step_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ]; then
if [ ! -e "$TERMUX_PREFIX/etc/xml/catalog" ]; then if [ ! -e "$TERMUX_PREFIX/etc/xml/catalog" ]; then
xmlcatalog --noout --create "$TERMUX_PREFIX/etc/xml/catalog" xmlcatalog --noout --create "$TERMUX_PREFIX/etc/xml/catalog"
else else
@ -88,7 +88,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "remove" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "remove" ]; then
xmlcatalog --noout --del "$TERMUX_PREFIX/share/xml/docbook/xsl-stylesheets-$TERMUX_PKG_VERSION" \ xmlcatalog --noout --del "$TERMUX_PREFIX/share/xml/docbook/xsl-stylesheets-$TERMUX_PKG_VERSION" \
"$TERMUX_PREFIX/etc/xml/catalog" "$TERMUX_PREFIX/etc/xml/catalog"
fi fi

View File

@ -119,7 +119,7 @@ termux_step_post_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/emacs 40 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/emacs 40
@ -133,7 +133,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/emacs update-alternatives --remove editor $TERMUX_PREFIX/bin/emacs
fi fi

View File

@ -13,6 +13,7 @@ termux_step_make_install() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
[ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] && return 0
echo "#!$TERMUX_PREFIX/bin/sh" > postinst echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "echo Downloading updated package list ..." >> postinst echo "echo Downloading updated package list ..." >> postinst
echo "apt update" >> postinst echo "apt update" >> postinst

View File

@ -13,7 +13,7 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-termcap"
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/joe 10 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/joe 10
@ -23,7 +23,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/joe update-alternatives --remove editor $TERMUX_PREFIX/bin/joe
fi fi

View File

@ -22,7 +22,7 @@ termux_step_post_get_source() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/jupp 10 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/jupp 10
@ -32,7 +32,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/jupp update-alternatives --remove editor $TERMUX_PREFIX/bin/jupp
fi fi

View File

@ -12,7 +12,7 @@ TERMUX_PKG_EXTRA_MAKE_ARGS=" -C src debug=no "
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/kak 45 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/kak 45
@ -22,7 +22,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/kak update-alternatives --remove editor $TERMUX_PREFIX/bin/kak
fi fi

View File

@ -50,9 +50,9 @@ termux_step_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat > prerm <<- EOF cat > prerm <<- EOF
#!${TERMUX_PREFIX}/bin/bash #!${TERMUX_PREFIX}/bin/bash
if [ "\$1" != "remove" ]; then exit 0; fi if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then exit 0; fi
# since lsp creates log file, therefore not removed automatically # since lsp creates log file, therefore not removed automatically
rm -rf "${TERMUX_PREFIX}/lib/lua-language-server" rm -rf "${TERMUX_PREFIX}/lib/lua-language-server"
EOF EOF
} }

View File

@ -25,8 +25,8 @@ termux_step_pre_configure() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
echo "interest-noawait $TERMUX_PREFIX/share/man" > triggers [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && echo "interest-noawait $TERMUX_PREFIX/share/man" > triggers
echo "#!$TERMUX_PREFIX/bin/sh" >> postinst echo "#!$TERMUX_PREFIX/bin/sh" >> postinst
echo "makewhatis -Q" >> postinst echo "makewhatis -Q" >> postinst
echo "exit 0" >> postinst echo "exit 0" >> postinst

View File

@ -20,7 +20,7 @@ termux_step_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/mg 30 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/mg 30
@ -30,7 +30,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/mg update-alternatives --remove editor $TERMUX_PREFIX/bin/mg
fi fi

View File

@ -27,7 +27,7 @@ termux_step_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/micro 25 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/micro 25
@ -37,7 +37,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/micro update-alternatives --remove editor $TERMUX_PREFIX/bin/micro
fi fi

View File

@ -32,7 +32,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "remove" ]; then if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then
exit 0 exit 0
fi fi
rm -rf $TERMUX_PREFIX/var/cache/minidlna rm -rf $TERMUX_PREFIX/var/cache/minidlna

View File

@ -28,7 +28,7 @@ termux_step_post_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/nano 20 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/nano 20
@ -38,7 +38,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/nano update-alternatives --remove editor $TERMUX_PREFIX/bin/nano
fi fi

View File

@ -16,7 +16,7 @@ termux_step_pre_configure() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/ne 15 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/ne 15
@ -26,7 +26,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/ne update-alternatives --remove editor $TERMUX_PREFIX/bin/ne
fi fi

View File

@ -69,7 +69,7 @@ termux_step_post_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/nvim 40 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/nvim 40
@ -81,7 +81,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/nvim update-alternatives --remove editor $TERMUX_PREFIX/bin/nvim
update-alternatives --remove vi $TERMUX_PREFIX/bin/nvim update-alternatives --remove vi $TERMUX_PREFIX/bin/nvim

View File

@ -97,7 +97,7 @@ termux_step_create_debscripts() {
cat <<- PRERM_EOF > ./prerm cat <<- PRERM_EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "remove" ]; then if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then
exit 0 exit 0
fi fi

View File

@ -101,7 +101,7 @@ termux_step_create_debscripts() {
## PRE RM: ## PRE RM:
# Avoid running on update # Avoid running on update
echo "#!$TERMUX_PREFIX/bin/sh" > prerm: echo "#!$TERMUX_PREFIX/bin/sh" > prerm:
echo 'if [ $1 != "remove" ]; then exit 0; fi' >> prerm echo "if [ \"$TERMUX_PACKAGE_FORMAT\" = \"pacman\" ] && [ \"\$1\" != \"remove\" ]; then exit 0; fi" >> prerm
# Uninstall everything installed through pip: # Uninstall everything installed through pip:
echo "pip2 freeze 2> /dev/null | xargs pip2 uninstall -y > /dev/null 2> /dev/null" >> prerm echo "pip2 freeze 2> /dev/null | xargs pip2 uninstall -y > /dev/null 2> /dev/null" >> prerm
# Cleanup *.pyc files # Cleanup *.pyc files

View File

@ -13,6 +13,7 @@ termux_step_make_install() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
[ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] && return 0
echo "#!$TERMUX_PREFIX/bin/sh" > postinst echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "echo Downloading updated package list ..." >> postinst echo "echo Downloading updated package list ..." >> postinst
echo "apt update" >> postinst echo "apt update" >> postinst

View File

@ -13,6 +13,7 @@ termux_step_make_install() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
[ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] && return 0
echo "#!$TERMUX_PREFIX/bin/sh" > postinst echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "echo Downloading updated package list ..." >> postinst echo "echo Downloading updated package list ..." >> postinst
echo "apt update" >> postinst echo "apt update" >> postinst

View File

@ -13,6 +13,7 @@ termux_step_make_install() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
[ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] && return 0
echo "#!$TERMUX_PREFIX/bin/sh" > postinst echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "echo Downloading updated package list ..." >> postinst echo "echo Downloading updated package list ..." >> postinst
echo "apt update" >> postinst echo "apt update" >> postinst

View File

@ -79,7 +79,7 @@ termux_step_post_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vim 50 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vim 50
@ -91,7 +91,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/vim update-alternatives --remove editor $TERMUX_PREFIX/bin/vim
update-alternatives --remove vi $TERMUX_PREFIX/bin/vim update-alternatives --remove vi $TERMUX_PREFIX/bin/vim

View File

@ -65,7 +65,7 @@ termux_step_post_make_install() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vim 50 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vim 50
@ -77,7 +77,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/vim update-alternatives --remove editor $TERMUX_PREFIX/bin/vim
update-alternatives --remove vi $TERMUX_PREFIX/bin/vim update-alternatives --remove vi $TERMUX_PREFIX/bin/vim

View File

@ -15,7 +15,7 @@ termux_step_pre_configure() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vis 30 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/vis 30
@ -27,7 +27,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/vis update-alternatives --remove editor $TERMUX_PREFIX/bin/vis
update-alternatives --remove vi $TERMUX_PREFIX/bin/vis update-alternatives --remove vi $TERMUX_PREFIX/bin/vis

View File

@ -13,6 +13,7 @@ termux_step_make_install() {
} }
termux_step_create_debscripts() { termux_step_create_debscripts() {
[ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] && return 0
echo "#!$TERMUX_PREFIX/bin/sh" > postinst echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo "echo Downloading updated package list ..." >> postinst echo "echo Downloading updated package list ..." >> postinst
echo "apt update" >> postinst echo "apt update" >> postinst

View File

@ -21,7 +21,7 @@ termux_step_post_configure() {
termux_step_create_debscripts() { termux_step_create_debscripts() {
cat <<- EOF > ./postinst cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --install \ update-alternatives --install \
$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/zile 35 $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/zile 35
@ -31,7 +31,7 @@ termux_step_create_debscripts() {
cat <<- EOF > ./prerm cat <<- EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh #!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "upgrade" ]; then if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
update-alternatives --remove editor $TERMUX_PREFIX/bin/zile update-alternatives --remove editor $TERMUX_PREFIX/bin/zile
fi fi

View File

@ -1,4 +1,4 @@
termux_create_subpackages() { termux_create_debian_subpackages() {
# Sub packages: # Sub packages:
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo lib/**/*.a) ]]; then if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo lib/**/*.a) ]]; then
# Add virtual -static sub package if there are include files: # Add virtual -static sub package if there are include files:
@ -91,7 +91,7 @@ termux_create_subpackages() {
tar -cJf "$SUB_PKG_PACKAGE_DIR/control.tar.xz" -H gnu . tar -cJf "$SUB_PKG_PACKAGE_DIR/control.tar.xz" -H gnu .
# Create the actual .deb file: # Create the actual .deb file:
TERMUX_SUBPKG_DEBFILE=$TERMUX_DEBDIR/${SUB_PKG_NAME}${DEBUG}_${TERMUX_PKG_FULLVERSION}_${SUB_PKG_ARCH}.deb TERMUX_SUBPKG_DEBFILE=$TERMUX_OUTPUT_DIR/${SUB_PKG_NAME}${DEBUG}_${TERMUX_PKG_FULLVERSION}_${SUB_PKG_ARCH}.deb
test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary" test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary"
ar cr "$TERMUX_SUBPKG_DEBFILE" \ ar cr "$TERMUX_SUBPKG_DEBFILE" \
"$TERMUX_COMMON_CACHEDIR/debian-binary" \ "$TERMUX_COMMON_CACHEDIR/debian-binary" \

View File

@ -0,0 +1,169 @@
termux_create_pacman_subpackages() {
# Sub packages:
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo lib/**/*.a) ]]; then
# Add virtual -static sub package if there are include files:
local _STATIC_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-static.subpackage.sh
echo TERMUX_SUBPKG_INCLUDE=\"lib/**/*.a lib/**/*.la\" > "$_STATIC_SUBPACKAGE_FILE"
echo "TERMUX_SUBPKG_DESCRIPTION=\"Static libraries for ${TERMUX_PKG_NAME}\"" >> "$_STATIC_SUBPACKAGE_FILE"
fi
# Now build all sub packages
rm -Rf "$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages"
for subpackage in $TERMUX_PKG_BUILDER_DIR/*.subpackage.sh $TERMUX_PKG_TMPDIR/*subpackage.sh; do
test ! -f "$subpackage" && continue
local SUB_PKG_NAME
SUB_PKG_NAME=$(basename "$subpackage" .subpackage.sh)
# Default value is same as main package, but sub package may override:
local TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT
local SUB_PKG_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages/$SUB_PKG_NAME
local TERMUX_SUBPKG_ESSENTIAL=false
local TERMUX_SUBPKG_BREAKS=""
local TERMUX_SUBPKG_DEPENDS=""
local TERMUX_SUBPKG_CONFLICTS=""
local TERMUX_SUBPKG_REPLACES=""
local TERMUX_SUBPKG_CONFFILES=""
local TERMUX_SUBPKG_DEPEND_ON_PARENT=""
local SUB_PKG_MASSAGE_DIR=$SUB_PKG_DIR/massage/$TERMUX_PREFIX
local SUB_PKG_PACKAGE_DIR=$SUB_PKG_DIR/package
mkdir -p "$SUB_PKG_MASSAGE_DIR" "$SUB_PKG_PACKAGE_DIR"
# shellcheck source=/dev/null
source "$subpackage"
# Allow globstar (i.e. './**/') patterns.
shopt -s globstar
for includeset in $TERMUX_SUBPKG_INCLUDE; do
local _INCLUDE_DIRSET
_INCLUDE_DIRSET=$(dirname "$includeset")
test "$_INCLUDE_DIRSET" = "." && _INCLUDE_DIRSET=""
if [ -e "$includeset" ] || [ -L "$includeset" ]; then
# Add the -L clause to handle relative symbolic links:
mkdir -p "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
mv "$includeset" "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
fi
done
shopt -u globstar
local SUB_PKG_ARCH=$TERMUX_ARCH
[ "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" = "true" ] && SUB_PKG_ARCH=any
cd "$SUB_PKG_DIR/massage"
local SUB_PKG_INSTALLSIZE
SUB_PKG_INSTALLSIZE=$(du -bs . | cut -f 1)
local BUILD_DATE
BUILD_DATE=$(date +%s)
local PKG_DEPS_SPC=" ${TERMUX_PKG_DEPENDS//,/} "
if [ -z "$TERMUX_SUBPKG_DEPEND_ON_PARENT" ] && [ "${PKG_DEPS_SPC/ $SUB_PKG_NAME /}" = "$PKG_DEPS_SPC" ]; then
# Does pacman supports versioned dependencies?
#TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_NAME (= $TERMUX_PKG_FULLVERSION)"
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_NAME"
elif [ "$TERMUX_SUBPKG_DEPEND_ON_PARENT" = unversioned ]; then
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_NAME"
elif [ "$TERMUX_SUBPKG_DEPEND_ON_PARENT" = deps ]; then
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_DEPENDS"
fi
# Package metadata.
{
echo "pkgname = $SUB_PKG_NAME"
echo "pkgbase = $TERMUX_PKG_NAME"
if [ -n "$TERMUX_PKG_REVISION" ]; then
echo "pkgver = $TERMUX_PKG_VERSION-${TERMUX_PKG_REVISION}"
else
echo "pkgver = $TERMUX_PKG_VERSION-0"
fi
echo "pkgdesc = $(echo "$TERMUX_SUBPKG_DESCRIPTION" | tr '\n' ' ')"
echo "url = $TERMUX_PKG_HOMEPAGE"
echo "builddate = $BUILD_DATE"
echo "packager = $TERMUX_PKG_MAINTAINER"
echo "size = $SUB_PKG_INSTALLSIZE"
echo "arch = $SUB_PKG_ARCH"
if [ -n "$TERMUX_SUBPKG_REPLACES" ]; then
tr ',' '\n' <<< "$TERMUX_SUBPKG_REPLACES" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "replaces = %s\n", $1 }'
fi
if [ -n "$TERMUX_SUBPKG_CONFLICTS" ]; then
tr ',' '\n' <<< "$TERMUX_SUBPKG_CONFLICTS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "conflict = %s\n", $1 }'
fi
if [ -n "$TERMUX_SUBPKG_BREAKS" ]; then
tr ',' '\n' <<< "$TERMUX_SUBPKG_BREAKS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "conflict = %s\n", $1 }'
fi
if [ -n "$TERMUX_SUBPKG_DEPENDS" ]; then
tr ',' '\n' <<< "${TERMUX_SUBPKG_DEPENDS/#, /}" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "depend = %s\n", $1 }'
fi
if [ -n "$TERMUX_SUBPKG_CONFFILES" ]; then
tr ',' '\n' <<< "$TERMUX_SUBPKG_CONFFILES" | awk '{ printf "backup = '"${TERMUX_PREFIX:1}"'/%s\n", $1 }'
fi
} > .PKGINFO
# Build metadata.
{
echo "format = 2"
echo "pkgname = $SUB_PKG_NAME"
echo "pkgbase = $TERMUX_PKG_NAME"
if [ -n "$TERMUX_PKG_REVISION" ]; then
echo "pkgver = $TERMUX_PKG_VERSION-${TERMUX_PKG_REVISION}"
else
echo "pkgver = $TERMUX_PKG_VERSION-0"
fi
echo "pkgarch = $SUB_PKG_ARCH"
echo "packager = $TERMUX_PKG_MAINTAINER"
echo "builddate = $BUILD_DATE"
} > .BUILDINFO
# Write package installation hooks.
termux_step_create_subpkg_debscripts
termux_step_create_pacman_install_hook
# Configuring the selection of a copress for a batch.
local COMPRESS
local PKG_FORMAT
case $TERMUX_PACMAN_PACKAGE_COMPRESSION in
"gzip")
COMPRESS=(gzip -c -f -n)
PKG_FORMAT="gz";;
"bzip2")
COMPRESS=(bzip2 -c -f)
PKG_FORMAT="bz2";;
"zstd")
COMPRESS=(zstd -c -z -q -)
PKG_FORMAT="zst";;
"lrzip")
COMPRESS=(lrzip -q)
PKG_FORMAT="lrz";;
"lzop")
COMPRESS=(lzop -q)
PKG_FORMAT="lzop";;
"lz4")
COMPRESS=(lz4 -q)
PKG_FORMAT="lz4";;
"lzip")
COMPRESS=(lzip -c -f)
PKG_FORMAT="lz";;
"xz" | *)
COMPRESS=(xz -c -z -)
PKG_FORMAT="xz";;
esac
# Create the actual .pkg file:
local TERMUX_SUBPKG_PACMAN_FILE=$TERMUX_OUTPUT_DIR/${SUB_PKG_NAME}${DEBUG}-${TERMUX_PKG_FULLVERSION}-${SUB_PKG_ARCH}.pkg.tar.${PKG_FORMAT}
shopt -s dotglob globstar
printf '%s\0' **/* | bsdtar -cnf - --format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
--null --files-from - --exclude .MTREE | \
gzip -c -f -n > .MTREE
printf '%s\0' **/* | bsdtar --no-fflags -cnf - --null --files-from - | \
$COMPRESS > "$TERMUX_SUBPKG_PACMAN_FILE"
shopt -u dotglob globstar
# Go back to main package:
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
done
}

View File

@ -1,8 +0,0 @@
termux_step_create_datatar() {
if [ "$TERMUX_PKG_METAPACKAGE" = "true" ]; then
# Metapackage doesn't have data inside.
rm -rf data
fi
tar -cJf "$TERMUX_PKG_PACKAGEDIR/data.tar.xz" -H gnu .
}

View File

@ -1,4 +1,10 @@
termux_step_create_debfile() { termux_step_create_debian_package() {
if [ "$TERMUX_PKG_METAPACKAGE" = "true" ]; then
# Metapackage doesn't have data inside.
rm -rf data
fi
tar -cJf "$TERMUX_PKG_PACKAGEDIR/data.tar.xz" -H gnu .
# Get install size. This will be written as the "Installed-Size" deb field so is measured in 1024-byte blocks: # Get install size. This will be written as the "Installed-Size" deb field so is measured in 1024-byte blocks:
local TERMUX_PKG_INSTALLSIZE local TERMUX_PKG_INSTALLSIZE
TERMUX_PKG_INSTALLSIZE=$(du -sk . | cut -f 1) TERMUX_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
@ -38,7 +44,7 @@ termux_step_create_debfile() {
tar -cJf "$TERMUX_PKG_PACKAGEDIR/control.tar.xz" -H gnu . tar -cJf "$TERMUX_PKG_PACKAGEDIR/control.tar.xz" -H gnu .
test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary" test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary"
TERMUX_PKG_DEBFILE=$TERMUX_DEBDIR/${TERMUX_PKG_NAME}${DEBUG}_${TERMUX_PKG_FULLVERSION}_${TERMUX_ARCH}.deb TERMUX_PKG_DEBFILE=$TERMUX_OUTPUT_DIR/${TERMUX_PKG_NAME}${DEBUG}_${TERMUX_PKG_FULLVERSION}_${TERMUX_ARCH}.deb
# Create the actual .deb file: # Create the actual .deb file:
ar cr "$TERMUX_PKG_DEBFILE" \ ar cr "$TERMUX_PKG_DEBFILE" \
"$TERMUX_COMMON_CACHEDIR/debian-binary" \ "$TERMUX_COMMON_CACHEDIR/debian-binary" \

View File

@ -0,0 +1,32 @@
termux_step_create_pacman_install_hook() {
# Unlike dpkg, pacman doesn't use separate scripts for package installation
# hooks. Instead it uses a single script with functions.
if [ -f "./preinst" ]; then
echo "pre_install() {" >> .INSTALL
cat preinst | grep -v '^#' >> .INSTALL
echo "}" >> .INSTALL
rm -f preinst
fi
if [ -f "./postinst" ]; then
echo "post_install() {" >> .INSTALL
cat postinst | grep -v '^#' >> .INSTALL
echo "}" >> .INSTALL
rm -f postinst
fi
if [ -f "./prerm" ]; then
echo "pre_remove() {" >> .INSTALL
cat prerm | grep -v '^#' >> .INSTALL
echo "}" >> .INSTALL
rm -f prerm
fi
if [ -f "./postrm" ]; then
echo "post_remove() {" >> .INSTALL
cat postrm | grep -v '^#' >> .INSTALL
echo "}" >> .INSTALL
rm -f postrm
fi
# Conversion from dpkg triggers to libalpm hooks is not supported
# currently. Delete unneeded triggers file.
rm -f triggers
}

View File

@ -0,0 +1,128 @@
termux_step_create_pacman_package() {
local TERMUX_PKG_INSTALLSIZE
TERMUX_PKG_INSTALLSIZE=$(du -bs . | cut -f 1)
# From here on TERMUX_ARCH is set to "all" if TERMUX_PKG_PLATFORM_INDEPENDENT is set by the package
[ "$TERMUX_PKG_PLATFORM_INDEPENDENT" = "true" ] && TERMUX_ARCH=any
# Configuring the selection of a copress for a batch.
local COMPRESS
local PKG_FORMAT
case $TERMUX_PACMAN_PACKAGE_COMPRESSION in
"gzip")
COMPRESS=(gzip -c -f -n)
PKG_FORMAT="gz";;
"bzip2")
COMPRESS=(bzip2 -c -f)
PKG_FORMAT="bz2";;
"zstd")
COMPRESS=(zstd -c -z -q -)
PKG_FORMAT="zst";;
"lrzip")
COMPRESS=(lrzip -q)
PKG_FORMAT="lrz";;
"lzop")
COMPRESS=(lzop -q)
PKG_FORMAT="lzop";;
"lz4")
COMPRESS=(lz4 -q)
PKG_FORMAT="lz4";;
"lzip")
COMPRESS=(lzip -c -f)
PKG_FORMAT="lz";;
"xz" | *)
COMPRESS=(xz -c -z -)
PKG_FORMAT="xz";;
esac
local PACMAN_FILE=$TERMUX_OUTPUT_DIR/${TERMUX_PKG_NAME}${DEBUG}-${TERMUX_PKG_FULLVERSION}-${TERMUX_ARCH}.pkg.tar.${PKG_FORMAT}
local BUILD_DATE
BUILD_DATE=$(date +%s)
# Package metadata.
{
echo "pkgname = $TERMUX_PKG_NAME"
echo "pkgbase = $TERMUX_PKG_NAME"
if [ -n "$TERMUX_PKG_REVISION" ]; then
echo "pkgver = $TERMUX_PKG_VERSION-${TERMUX_PKG_REVISION}"
else
echo "pkgver = $TERMUX_PKG_VERSION-0"
fi
echo "pkgdesc = $(echo "$TERMUX_PKG_DESCRIPTION" | tr '\n' ' ')"
echo "url = $TERMUX_PKG_HOMEPAGE"
echo "builddate = $BUILD_DATE"
echo "packager = $TERMUX_PKG_MAINTAINER"
echo "size = $TERMUX_PKG_INSTALLSIZE"
echo "arch = $TERMUX_ARCH"
if [ -n "$TERMUX_PKG_LICENSE" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_LICENSE" | awk '{ printf "license = %s\n", $0 }'
fi
if [ -n "$TERMUX_PKG_REPLACES" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_REPLACES" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "replaces = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_CONFLICTS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_CONFLICTS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "conflict = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_BREAKS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_BREAKS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "conflict = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_PROVIDES" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_PROVIDES" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "provides = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_DEPENDS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_DEPENDS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "depend = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_RECOMMENDS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_RECOMMENDS" | awk '{ printf "optdepend = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_SUGGESTS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_SUGGESTS" | awk '{ printf "optdepend = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_BUILD_DEPENDS" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_BUILD_DEPENDS" | sed 's|(||g; s|)||g; s| ||g; s|>>|>|g; s|<<|<|g' | awk '{ printf "makedepend = %s\n", $1 }'
fi
if [ -n "$TERMUX_PKG_CONFFILES" ]; then
tr ',' '\n' <<< "$TERMUX_PKG_CONFFILES" | awk '{ printf "backup = '"${TERMUX_PREFIX:1}"'/%s\n", $1 }'
fi
} > .PKGINFO
# Build metadata.
{
echo "format = 2"
echo "pkgname = $TERMUX_PKG_NAME"
echo "pkgbase = $TERMUX_PKG_NAME"
if [ -n "$TERMUX_PKG_REVISION" ]; then
echo "pkgver = $TERMUX_PKG_VERSION-${TERMUX_PKG_REVISION}"
else
echo "pkgver = $TERMUX_PKG_VERSION-0"
fi
echo "pkgarch = $TERMUX_ARCH"
echo "packager = $TERMUX_PKG_MAINTAINER"
echo "builddate = $BUILD_DATE"
} > .BUILDINFO
# Write installation hooks.
termux_step_create_debscripts
termux_step_create_pacman_install_hook
# Create package
shopt -s dotglob globstar
printf '%s\0' **/* | bsdtar -cnf - --format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
--null --files-from - --exclude .MTREE | \
gzip -c -f -n > .MTREE
printf '%s\0' **/* | bsdtar --no-fflags -cnf - --null --files-from - | \
$COMPRESS > "$PACMAN_FILE"
shopt -u dotglob globstar
}

View File

@ -29,7 +29,7 @@ termux_step_get_dependencies() {
if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then
echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead" echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead"
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I "${PKG_DIR}" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I --format $TERMUX_PACKAGE_FORMAT "${PKG_DIR}"
continue continue
fi fi
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
@ -62,8 +62,8 @@ termux_step_get_dependencies() {
termux_error_exit "Obtaining buildorder failed" termux_error_exit "Obtaining buildorder failed"
fi fi
echo "Building dependency $PKG if necessary..." echo "Building dependency $PKG if necessary..."
# Built dependencies are put in the default TERMUX_DEBDIR instead of the specified one # Built dependencies are put in the default TERMUX_OUTPUT_DIR instead of the specified one
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -s "${PKG_DIR}" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -s --format $TERMUX_PACKAGE_FORMAT "${PKG_DIR}"
done<<<$(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR") done<<<$(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR" $TERMUX_PACKAGES_DIRECTORIES || echo "ERROR")
fi fi
} }

View File

@ -79,7 +79,11 @@ termux_step_massage() {
termux_error_exit "Package contains hard links: $HARDLINKS" termux_error_exit "Package contains hard links: $HARDLINKS"
fi fi
termux_create_subpackages if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ]; then
termux_create_debian_subpackages
elif [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
termux_create_pacman_subpackages
fi
# .. remove empty directories (NOTE: keep this last): # .. remove empty directories (NOTE: keep this last):
find . -type d -empty -delete find . -type d -empty -delete

View File

@ -29,7 +29,7 @@ termux_step_setup_build_folders() {
mkdir -p "$TERMUX_COMMON_CACHEDIR" \ mkdir -p "$TERMUX_COMMON_CACHEDIR" \
"$TERMUX_COMMON_CACHEDIR-$TERMUX_ARCH" \ "$TERMUX_COMMON_CACHEDIR-$TERMUX_ARCH" \
"$TERMUX_COMMON_CACHEDIR-all" \ "$TERMUX_COMMON_CACHEDIR-all" \
"$TERMUX_DEBDIR" \ "$TERMUX_OUTPUT_DIR" \
"$TERMUX_PKG_BUILDDIR" \ "$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_PACKAGEDIR" \ "$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \ "$TERMUX_PKG_TMPDIR" \

View File

@ -1,6 +1,7 @@
termux_step_setup_variables() { termux_step_setup_variables() {
: "${TERMUX_PACKAGE_FORMAT:="debian"}" # debian, pacman
: "${TERMUX_ARCH:="aarch64"}" # arm, aarch64, i686 or x86_64. : "${TERMUX_ARCH:="aarch64"}" # arm, aarch64, i686 or x86_64.
: "${TERMUX_DEBDIR:="${TERMUX_SCRIPTDIR}/debs"}" : "${TERMUX_OUTPUT_DIR:="${TERMUX_SCRIPTDIR}/output"}"
: "${TERMUX_DEBUG_BUILD:="false"}" : "${TERMUX_DEBUG_BUILD:="false"}"
: "${TERMUX_FORCE_BUILD:="false"}" : "${TERMUX_FORCE_BUILD:="false"}"
: "${TERMUX_INSTALL_DEPS:="false"}" : "${TERMUX_INSTALL_DEPS:="false"}"
@ -12,6 +13,7 @@ termux_step_setup_variables() {
: "${TERMUX_QUIET_BUILD:="false"}" : "${TERMUX_QUIET_BUILD:="false"}"
: "${TERMUX_SKIP_DEPCHECK:="false"}" : "${TERMUX_SKIP_DEPCHECK:="false"}"
: "${TERMUX_TOPDIR:="$HOME/.termux-build"}" : "${TERMUX_TOPDIR:="$HOME/.termux-build"}"
: "${TERMUX_PACMAN_PACKAGE_COMPRESSION:="xz"}"
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
# For on-device builds cross-compiling is not supported so we can # For on-device builds cross-compiling is not supported so we can