termux-packages/build-package.sh

1115 lines
42 KiB
Bash
Raw Normal View History

2015-06-13 01:03:31 +02:00
#!/bin/bash
2018-08-27 22:27:42 +02:00
# shellcheck disable=SC1117
2015-06-13 01:03:31 +02:00
set -e -o pipefail -u
# Utility function to log an error message and exit with an error code.
source scripts/build/termux_error_exit.sh
# Utility function to download a resource with an expected checksum.
source scripts/build/termux_download.sh
# Utility function for golang-using packages to setup a go toolchain.
source scripts/build/setup/termux_setup_golang.sh
# Utility function for rust-using packages to setup a rust toolchain.
source scripts/build/setup/termux_setup_rust.sh
2017-11-07 02:26:49 +01:00
# Utility function to setup a current ninja build system.
source scripts/build/setup/termux_setup_ninja.sh
2017-11-07 02:26:49 +01:00
# Utility function to setup a current meson build system.
source scripts/build/setup/termux_setup_meson.sh
2017-11-07 02:26:49 +01:00
# Utility function to setup a current cmake build system
source scripts/build/setup/termux_setup_cmake.sh
# First step is to handle command-line arguments. Not to be overridden by packages.
source scripts/build/termux_step_handle_arguments.sh
# Setup variables used by the build. Not to be overridden by packages.
source scripts/build/termux_step_setup_variables.sh
# Save away and restore build setups which may change between builds.
source scripts/build/termux_step_handle_buildarch.sh
# Function to get TERMUX_PKG_VERSION from build.sh
source scripts/build/termux_extract_dep_info.sh
termux_download_deb() {
local package=$1
local package_arch=$2
local version=$3
local deb_file=${package}_${version}_${package_arch}.deb
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"
read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-$arch/$PACKAGE_FILE_PATH" $package $version)
if ! [ "$PKG_HASH" = "" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Found $package in ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}"
fi
break
fi
done
if [ "$PKG_HASH" = "" ]; then
return 1
else
termux_download ${TERMUX_REPO_URL[$idx-1]}/${PKG_PATH} \
$TERMUX_COMMON_CACHEDIR-$package_arch/${deb_file} \
$PKG_HASH
return 0
fi
}
# Script to download InRelease, verify it's signature and then download Packages.xz by hash
termux_step_get_repo_files() {
# Ensure folders present (but not $TERMUX_PKG_SRCDIR, it will be created in build)
mkdir -p "$TERMUX_COMMON_CACHEDIR" \
"$TERMUX_COMMON_CACHEDIR-$TERMUX_ARCH" \
"$TERMUX_COMMON_CACHEDIR-all" \
"$TERMUX_DEBDIR" \
"$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_TMPDIR" \
"$TERMUX_PKG_CACHEDIR" \
"$TERMUX_PKG_MASSAGEDIR" \
$TERMUX_PREFIX/{bin,etc,lib,libexec,share,tmp,include}
if [ "$TERMUX_INSTALL_DEPS" = true ]; then
if [ "$TERMUX_NO_CLEAN" = false ]; then
# Remove all previously extracted/built files from $TERMUX_PREFIX:
rm -rf $TERMUX_PREFIX
rm -f /data/data/.built-packages/*
# Setup bootstrap
if [ $TERMUX_ARCH == aarch64 ]; then
local bootstrap_sha256=2944ad699814329007d1f9c056e7c8323243c8b4a257cbd05904216f89fc3746
elif [ $TERMUX_ARCH == i686 ]; then
local bootstrap_sha256=8f4dee0b1e161689b60f330ac0cc813b56ab479f2cd789eb8459165a3be13bdb
elif [ $TERMUX_ARCH == arm ]; then
local bootstrap_sha256=f471c0af326677d87ca4926d54860d10d751dd4f8d615d5b1de902841601b41e
elif [ $TERMUX_ARCH == x86_64 ]; then
local bootstrap_sha256=93384f0343c13f604dbacd069276291bd7042fc6d42c6d7514c7e573d968c614
fi
termux_download https://termux.net/bootstrap/bootstrap-${TERMUX_ARCH}.zip \
${TERMUX_COMMON_CACHEDIR}/bootstrap-${TERMUX_ARCH}.zip \
$bootstrap_sha256
unzip -qo ${TERMUX_COMMON_CACHEDIR}/bootstrap-${TERMUX_ARCH}.zip -d $TERMUX_PREFIX
(
cd $TERMUX_PREFIX
while read link; do
ln -sf ${link/←/ }
done<SYMLINKS.txt
rm SYMLINKS.txt
)
fi
# Import signing keys from files
gpg --import ${TERMUX_REPO_SIGNING_KEYS}
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')
curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/InRelease" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease \
|| curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release.gpg" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release.gpg \
&& curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release \
|| termux_error_exit "Download of InRelease and Release.gpg from ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]} failed"
if [ -f ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease ]; then
local RELEASE_FILE=${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease
gpg --verify $RELEASE_FILE
else
local RELEASE_FILE=${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release
gpg --verify ${RELEASE_FILE}.gpg $RELEASE_FILE
fi
for arch in all $TERMUX_ARCH; do
local packages_hash=$(./scripts/get_hash_from_file.py ${RELEASE_FILE} $arch ${TERMUX_REPO_COMPONENT[$idx-1]})
# If packages_hash = "" then the repo probably doesn't contain debs for $arch
if ! [ "$packages_hash" = "" ]; then
termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/${TERMUX_REPO_COMPONENT[$idx-1]}/binary-$arch/Packages" \
"${TERMUX_COMMON_CACHEDIR}-$arch/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages" \
$packages_hash
fi
done
done
fi
}
# Source the package build script and start building. No to be overridden by packages.
termux_step_start_build() {
# shellcheck source=/dev/null
source "$TERMUX_PKG_BUILDER_SCRIPT"
TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_COMMON_CACHEDIR/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}"
# Bump the below version if a change is made in toolchain setup to ensure
# that everyone gets an updated toolchain:
2019-02-17 21:34:26 +01:00
TERMUX_STANDALONE_TOOLCHAIN+="-v1"
2017-10-02 16:54:53 +02: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
if [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = true ]; then
# Download dependencies
local PKG DEP_ARCH DEP_VERSION DEB_FILE _PKG_DEPENDS _PKG_BUILD_DEPENDS _SUBPKG_DEPENDS=""
# remove (>= 1.0) and similar version tags:
_PKG_DEPENDS=$(echo ${TERMUX_PKG_DEPENDS// /} | sed "s/[(][^)]*[)]//g")
_PKG_BUILD_DEPENDS=${TERMUX_PKG_BUILD_DEPENDS// /}
# Also download subpackages dependencies (except the mother package):
for SUBPKG in packages/$TERMUX_PKG_NAME/*.subpackage.sh; do
2019-02-25 03:39:27 +01:00
test -e $SUBPKG || continue
_SUBPKG_DEPENDS+=" $(. $SUBPKG; echo $TERMUX_SUBPKG_DEPENDS | sed s%$TERMUX_PKG_NAME%%g)"
done
for PKG in $(echo ${_PKG_DEPENDS//,/ } ${_SUBPKG_DEPENDS//,/ } ${_PKG_BUILD_DEPENDS//,/ } | tr ' ' '\n' | sort -u); do
# handle "or" in dependencies (use first one):
if [ ! "$PKG" = "${PKG/|/}" ]; then PKG=$(echo "$PKG" | sed "s%|.*%%"); 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")
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Downloading dependency $PKG@$DEP_VERSION if necessary..."
fi
if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then
echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead"
./build-package.sh -a $TERMUX_ARCH -I "$PKG"
continue
else
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
tar -xf data.tar.xz --no-overwrite-dir -C /
)
fi
if termux_download_deb $PKG-dev $DEP_ARCH $DEP_VERSION; then
(
cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH
ar x $PKG-dev_${DEP_VERSION}_${DEP_ARCH}.deb data.tar.xz
tar xf data.tar.xz --no-overwrite-dir -C /
)
else
echo "Download of $PKG-dev@$DEP_VERSION from $TERMUX_REPO_URL failed"
fi
mkdir -p /data/data/.built-packages
echo "$DEP_VERSION" > "/data/data/.built-packages/$PKG"
done
elif [ "$TERMUX_SKIP_DEPCHECK" = false ] && [ "$TERMUX_INSTALL_DEPS" = false ]; then
# Build dependencies
for PKG in $(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR"); do
echo "Building dependency $PKG if necessary..."
# Built dependencies are put in the default TERMUX_DEBDIR instead of the specified one
./build-package.sh -a $TERMUX_ARCH -s "$PKG"
done
fi
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
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_DEBUG" = true ]; then
Add fixes for debug builds (#2296) * build-package.sh: add possibility for debug patches and TERMUX_PKG_HAS_DEBUG Setting TERMUX_PKG_HAS_DEBUG=no disables attempt to build debug build of package. Useful for example if a debug build doesn't make sense, as for python-packages and texlive. * aapt: skip D_FORTIFY_SOURCE=2 for libandroid-cutils when doing debug build * lftp: skip D_FORTIFY_SOURCE=2 for debug build * libflac: don't use -g3 for debug build Configure script removes it otherwise. * nano: skip -D_FORTIFY_SOURCE=2 for debug build * vifm: skip -D_FORTIFY_SOURCE=2 for debug build * mc: skip -D_FORTIFY_SOURCE=2 for debug build * dropbear: add __attribute__((overloadable)) to XMEMSET and XMEMCPY if debug * gdb: add __attribute__((overloadable)) to strchr if debug * gnuit: add __attribute__((overloadable)) to strchr and strcpy if debug * gperf: add __attribute__((overloadable)) to strlen if debug * inetutils: add __attribute__((overloadable)) to strrchr and strchr if debug * readline: add __attribute__((overloadable)) to strchr if debug * tsocks: add __attribute__((overloadable)) to poll if debug * units: add __attribute__((overloadable)) to strchr if debug * liblua: fix bug in loslib.c that emerged in debug build Use strncpy instead of strcpy. Original error message: loslib.c:169:3: error: 'strcpy' called with string bigger than buffer lua_tmpnam(buff, err); ^ loslib.c:122:37: note: expanded from macro 'lua_tmpnam' strcpy(b, LUA_TMPNAMTEMPLATE); \ ^ * alpine: include our getpass.h in imap's mtest.c to declare getpass Debug build complained about the previous implicit declaration. * nginx: use --with-debug instead of --debug * cboard: skip -D_FORTIFY_SOURCE=2 for debug build * gettext: add __attribute__((overloadable)) to getcwd if debug * oathtool: skip -D_FORTIFY_SOURCE=2 for debug build * php: add __attribute__((overloadable)) to strlcpy and strlcat if debug * expect: add __attribute__((overloadable)) to strchr if debug * texlive: set TERMUX_PKG_HAS_DEBUG=no * asciinema: set TERMUX_PKG_HAS_DEBUG=no * libllvm: set TERMUX_PKG_HAS_DEBUG=no Debug build fails with: home/builder/.termux-build/libllvm/src/lib/Support/Unix/Path.inc:740:19: error: no matching function for call to 'RetryAfterSignal' if ((ResultFD = sys::RetryAfterSignal(-1, open, P.begin(), OpenFlags)) < 0) * build-package.sh: set TERMUX_PKG_REPLACES=package if debug build Hopefully allows us to install debug packages without breaking dependecies. Should be looked over and be made more similar to how debian does this in any case * Update build.sh
2018-06-13 02:12:36 +02:00
if [ "$TERMUX_PKG_HAS_DEBUG" == "yes" ]; then
DEBUG="-dbg"
else
echo "Skipping building debug build for $TERMUX_PKG_NAME"
exit 0
fi
else
DEBUG=""
fi
if [ -z "$TERMUX_DEBUG" ] &&
[ -z "${TERMUX_FORCE_BUILD+x}" ] &&
[ -e "/data/data/.built-packages/$TERMUX_PKG_NAME" ]; then
if [ "$(cat "/data/data/.built-packages/$TERMUX_PKG_NAME")" = "$TERMUX_PKG_FULLVERSION" ]; then
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm /data/data/.built-packages/$TERMUX_PKG_NAME to force rebuild)"
exit 0
fi
fi
# Cleanup old state:
rm -Rf "$TERMUX_PKG_BUILDDIR" \
"$TERMUX_PKG_PACKAGEDIR" \
"$TERMUX_PKG_SRCDIR" \
"$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,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:
ln -f -s /bin/sh "$TERMUX_PREFIX/bin/sh"
local TERMUX_ELF_CLEANER_SRC=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner.cpp
2018-08-27 22:27:42 +02:00
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 \
2018-08-27 22:27:42 +02:00
"https://raw.githubusercontent.com/termux/termux-elf-cleaner/v$TERMUX_ELF_CLEANER_VERSION/termux-elf-cleaner.cpp" \
"$TERMUX_ELF_CLEANER_SRC" \
2019-02-25 00:59:26 +01:00
690991371101cd1dadf73f07f73d1db72fe1cd646dcccf11cd252e194bd5de76
if [ "$TERMUX_ELF_CLEANER_SRC" -nt "$TERMUX_ELF_CLEANER" ]; then
2019-02-25 00:59:26 +01:00
g++ -std=c++11 -Wall -Wextra -pedantic -Os -D__ANDROID_API__=$TERMUX_PKG_API_LEVEL \
"$TERMUX_ELF_CLEANER_SRC" -o "$TERMUX_ELF_CLEANER"
fi
if [ -n "$TERMUX_PKG_BUILD_IN_SRC" ]; then
echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set" > "$TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt"
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR
fi
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.
export TERMUX_PKG_CONFIG_LIBDIR=$TERMUX_PREFIX/lib/pkgconfig
# Add a pkg-config file for the system zlib.
mkdir -p "$TERMUX_PKG_CONFIG_LIBDIR"
cat > "$TERMUX_PKG_CONFIG_LIBDIR/zlib.pc" <<-HERE
Name: zlib
Description: zlib compression library
Version: 1.2.8
Requires:
Libs: -lz
HERE
2019-02-17 01:34:52 +01:00
ln -sf $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/libz.so $TERMUX_PREFIX/lib/libz.so
# Keep track of when build started so we can see what files have been created.
# We start by sleeping so that any generated files above (such as zlib.pc) get
# an older timestamp than the TERMUX_BUILD_TS_FILE.
sleep 1
TERMUX_BUILD_TS_FILE=$TERMUX_PKG_TMPDIR/timestamp_$TERMUX_PKG_NAME
touch "$TERMUX_BUILD_TS_FILE"
}
# Run just after sourcing $TERMUX_PKG_BUILDER_SCRIPT. May be overridden by packages.
2017-01-10 12:35:05 +01:00
termux_step_extract_package() {
if [ -z "${TERMUX_PKG_SRCURL:=""}" ] || [ -n "${TERMUX_PKG_SKIP_SRC_EXTRACT:=""}" ]; then
mkdir -p "$TERMUX_PKG_SRCDIR"
return
fi
cd "$TERMUX_PKG_TMPDIR"
local PKG_SRCURL=(${TERMUX_PKG_SRCURL[@]})
local PKG_SHA256=(${TERMUX_PKG_SHA256[@]})
if [ ! ${#PKG_SRCURL[@]} == ${#PKG_SHA256[@]} ] && [ ! ${#PKG_SHA256[@]} == 0 ]; then
termux_error_exit "Error: length of TERMUX_PKG_SRCURL isn't equal to length of TERMUX_PKG_SHA256."
2015-06-13 01:03:31 +02:00
fi
# STRIP=1 extracts archives straight into TERMUX_PKG_SRCDIR while STRIP=0 puts them in subfolders. zip has same behaviour per default
2018-06-26 04:53:02 +02:00
# If this isn't desired then this can be fixed in termux_step_post_extract_package.
local STRIP=1
for i in $(seq 0 $(( ${#PKG_SRCURL[@]}-1 ))); do
2018-08-27 22:27:42 +02:00
test "$i" -gt 0 && STRIP=0
local filename
filename=$(basename "${PKG_SRCURL[$i]}")
local file="$TERMUX_PKG_CACHEDIR/$filename"
# Allow TERMUX_PKG_SHA256 to be empty:
set +u
termux_download "${PKG_SRCURL[$i]}" "$file" "${PKG_SHA256[$i]}"
set -u
local folder
set +o pipefail
if [ "${file##*.}" = zip ]; then
2019-02-12 09:41:30 +01:00
folder=$(unzip -qql "$file" | head -n1 | tr -s ' ' | cut -d' ' -f5-)
rm -Rf $folder
unzip -q "$file"
mv $folder "$TERMUX_PKG_SRCDIR"
else
mkdir -p "$TERMUX_PKG_SRCDIR"
tar xf "$file" -C "$TERMUX_PKG_SRCDIR" --strip-components=$STRIP
fi
set -o pipefail
done
2015-06-13 01:03:31 +02:00
}
# Hook for packages to act just after the package has been extracted.
# Invoked in $TERMUX_PKG_SRCDIR.
2017-01-10 12:35:05 +01:00
termux_step_post_extract_package() {
2019-02-12 09:23:21 +01:00
return
2015-06-13 01:03:31 +02:00
}
# Optional host build. Not to be overridden by packages.
source scripts/build/termux_step_handle_hostbuild.sh
2015-06-13 01:03:31 +02:00
# Perform a host build. Will be called in $TERMUX_PKG_HOSTBUILD_DIR.
# After termux_step_post_extract_package() and before termux_step_patch_package()
source scripts/build/termux_step_host_build.sh
2015-06-13 01:03:31 +02:00
# Setup a standalone Android NDK toolchain. Not to be overridden by packages.
termux_step_setup_toolchain() {
# We put this after system PATH to avoid picking up toolchain stripped python
export PATH=$PATH:$TERMUX_STANDALONE_TOOLCHAIN/bin
export CFLAGS=""
2017-01-17 15:51:59 +01:00
export LDFLAGS="-L${TERMUX_PREFIX}/lib"
export AS=${TERMUX_HOST_PLATFORM}-clang
export CC=$TERMUX_HOST_PLATFORM-clang
export CXX=$TERMUX_HOST_PLATFORM-clang++
2019-02-17 01:34:52 +01:00
export CCTERMUX_HOST_PLATFORM=$TERMUX_HOST_PLATFORM$TERMUX_PKG_API_LEVEL
if [ $TERMUX_ARCH = arm ]; then
CCTERMUX_HOST_PLATFORM=armv7a-linux-androideabi$TERMUX_PKG_API_LEVEL
fi
2017-01-17 15:51:59 +01:00
export AR=$TERMUX_HOST_PLATFORM-ar
export CPP=${TERMUX_HOST_PLATFORM}-cpp
export CC_FOR_BUILD=gcc
export LD=$TERMUX_HOST_PLATFORM-ld
export OBJDUMP=$TERMUX_HOST_PLATFORM-objdump
# Setup pkg-config for cross-compiling:
export PKG_CONFIG=$TERMUX_STANDALONE_TOOLCHAIN/bin/${TERMUX_HOST_PLATFORM}-pkg-config
export RANLIB=$TERMUX_HOST_PLATFORM-ranlib
export READELF=$TERMUX_HOST_PLATFORM-readelf
export STRIP=$TERMUX_HOST_PLATFORM-strip
# Android 7 started to support DT_RUNPATH (but not DT_RPATH), so we may want
# LDFLAGS+="-Wl,-rpath=$TERMUX_PREFIX/lib -Wl,--enable-new-dtags"
# and no longer remove DT_RUNPATH in termux-elf-cleaner.
if [ "$TERMUX_ARCH" = "arm" ]; then
2017-01-19 03:58:44 +01:00
# https://developer.android.com/ndk/guides/standalone_toolchain.html#abi_compatibility:
# "We recommend using the -mthumb compiler flag to force the generation of 16-bit Thumb-2 instructions".
# With r13 of the ndk ruby 2.4.0 segfaults when built on arm with clang without -mthumb.
CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb"
2017-07-15 09:59:30 +02:00
LDFLAGS+=" -march=armv7-a"
elif [ "$TERMUX_ARCH" = "i686" ]; then
# From $NDK/docs/CPU-ARCH-ABIS.html:
CFLAGS+=" -march=i686 -msse3 -mstackrealign -mfpmath=sse"
elif [ "$TERMUX_ARCH" = "aarch64" ]; then
2017-01-18 04:03:55 +01:00
:
elif [ "$TERMUX_ARCH" = "x86_64" ]; then
:
else
termux_error_exit "Invalid arch '$TERMUX_ARCH' - support arches are 'arm', 'i686', 'aarch64', 'x86_64'"
fi
if [ -n "$TERMUX_DEBUG" ]; then
CFLAGS+=" -g3 -O1 -fstack-protector --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
else
if [ $TERMUX_ARCH = arm ]; then
CFLAGS+=" -Os"
else
CFLAGS+=" -Oz"
fi
fi
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="-I${TERMUX_PREFIX}/include"
# If libandroid-support is declared as a dependency, link to it explicitly:
if [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libandroid-support/}" ]; then
LDFLAGS+=" -landroid-support"
fi
export ac_cv_func_getpwent=no
export ac_cv_func_getpwnam=no
export ac_cv_func_getpwuid=no
export ac_cv_func_sigsetmask=no
export ac_cv_c_bigendian=no
if [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then
# Do not put toolchain in place until we are done with setup, to avoid having a half setup
# toolchain left in place if something goes wrong (or process is just aborted):
local _TERMUX_TOOLCHAIN_TMPDIR=${TERMUX_STANDALONE_TOOLCHAIN}-tmp
rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR
local _NDK_ARCHNAME=$TERMUX_ARCH
if [ "$TERMUX_ARCH" = "aarch64" ]; then
_NDK_ARCHNAME=arm64
elif [ "$TERMUX_ARCH" = "i686" ]; then
_NDK_ARCHNAME=x86
fi
"$NDK/build/tools/make_standalone_toolchain.py" \
--api "$TERMUX_PKG_API_LEVEL" \
--arch $_NDK_ARCHNAME \
--stl=libc++ \
--install-dir $_TERMUX_TOOLCHAIN_TMPDIR
# Remove android-support header wrapping not needed on android-21:
rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/local
if [ "$TERMUX_ARCH" = "aarch64" ]; then
2017-01-18 04:03:55 +01:00
# Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
$_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
2017-01-19 02:51:17 +01:00
cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
$_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
fi
if [ "$TERMUX_ARCH" = "arm" ]; then
# Linker wrapper script to add '--exclude-libs libgcc.a', see
# https://github.com/android-ndk/ndk/issues/379
# https://android-review.googlesource.com/#/c/389852/
local linker
for linker in ld ld.bfd ld.gold; do
local wrap_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker
local real_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker.real
cp $wrap_linker $real_linker
echo '#!/bin/bash' > $wrap_linker
2019-02-12 09:41:30 +01:00
echo -n '$(dirname $0)/' >> $wrap_linker
echo -n $linker.real >> $wrap_linker
echo ' --exclude-libs libgcc.a "$@"' >> $wrap_linker
done
fi
2018-09-19 23:29:39 +02:00
# Setup the cpp preprocessor:
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-clang \
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-cpp
2019-01-18 23:16:17 +01:00
sed -i 's/clang80/clang80 -E/' \
2018-09-19 23:29:39 +02:00
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-cpp
cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot
for f in $TERMUX_SCRIPTDIR/ndk-patches/*.patch; do
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$f" | \
sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
patch --silent -p1;
done
# elf.h: Taken from glibc since the elf.h in the NDK is lacking.
# ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now.
# langinfo.h: Inline implementation of nl_langinfo().
# iconv.h: Header for iconv, implemented in libandroid-support.
cp "$TERMUX_SCRIPTDIR"/ndk-patches/{ifaddrs.h,libintl.h,langinfo.h,iconv.h} usr/include
# Remove <sys/shm.h> from the NDK in favour of that from the libandroid-shmem.
# Remove <sys/sem.h> as it doesn't work for non-root.
# Remove <glob.h> as we currently provide it from libandroid-glob.
# Remove <spawn.h> as it's only for future (later than android-27).
rm usr/include/sys/{shm.h,sem.h} usr/include/{glob.h,spawn.h}
sed -i "s/define __ANDROID_API__ __ANDROID_API_FUTURE__/define __ANDROID_API__ $TERMUX_PKG_API_LEVEL/" \
usr/include/android/api-level.h
2019-01-18 23:16:17 +01:00
$TERMUX_ELF_CLEANER usr/lib/*/*/*.so
# zlib is really version 1.2.8 in the Android platform (at least
# starting from Android 5), not older as the NDK headers claim.
for file in zconf.h zlib.h; do
curl -o usr/include/$file \
2019-02-12 09:23:21 +01:00
https://raw.githubusercontent.com/madler/zlib/v1.2.8/$file
done
unset file
2019-02-17 21:34:26 +01:00
grep -lrw $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/include/c++/v1 -e '<version>' | xargs -n 1 sed -i 's/<version>/\"version\"/g'
mv $_TERMUX_TOOLCHAIN_TMPDIR $TERMUX_STANDALONE_TOOLCHAIN
fi
local _STL_LIBFILE_NAME=libc++_shared.so
if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ]; then
2017-11-19 14:38:48 +01:00
# Setup libc++_shared.so in $PREFIX/lib and libstdc++.so as a link to it,
# so that other C++ using packages links to it instead of the default android
# C++ library which does not support exceptions or STL:
# https://developer.android.com/ndk/guides/cpp-support.html
# We do however want to avoid installing this, to avoid problems where e.g.
# libm.so on some i686 devices links against libstdc++.so.
2017-11-19 14:38:48 +01:00
# The libc++_shared.so library will be packaged in the libc++ package
# which is part of the base Termux installation.
mkdir -p "$TERMUX_PREFIX/lib"
cd "$TERMUX_PREFIX/lib"
2019-01-18 23:16:17 +01:00
local _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/${TERMUX_HOST_PLATFORM}/$_STL_LIBFILE_NAME
cp "$_STL_LIBFILE" .
$STRIP --strip-unneeded $_STL_LIBFILE_NAME
$TERMUX_ELF_CLEANER $_STL_LIBFILE_NAME
if [ $TERMUX_ARCH = "arm" ]; then
# Use a linker script to get libunwind.a.
echo 'INPUT(-lunwind -lc++_shared)' > libstdc++.so
else
ln -f $_STL_LIBFILE_NAME libstdc++.so
fi
fi
export PKG_CONFIG_LIBDIR="$TERMUX_PKG_CONFIG_LIBDIR"
# Create a pkg-config wrapper. We use path to host pkg-config to
# avoid picking up a cross-compiled pkg-config later on.
local _HOST_PKGCONFIG
_HOST_PKGCONFIG=$(which pkg-config)
mkdir -p $TERMUX_STANDALONE_TOOLCHAIN/bin "$PKG_CONFIG_LIBDIR"
cat > "$PKG_CONFIG" <<-HERE
#!/bin/sh
export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR
exec $_HOST_PKGCONFIG "\$@"
HERE
chmod +x "$PKG_CONFIG"
}
# Apply all *.patch files for the package. Not to be overridden by packages.
2017-01-10 12:35:05 +01:00
termux_step_patch_package() {
cd "$TERMUX_PKG_SRCDIR"
Add fixes for debug builds (#2296) * build-package.sh: add possibility for debug patches and TERMUX_PKG_HAS_DEBUG Setting TERMUX_PKG_HAS_DEBUG=no disables attempt to build debug build of package. Useful for example if a debug build doesn't make sense, as for python-packages and texlive. * aapt: skip D_FORTIFY_SOURCE=2 for libandroid-cutils when doing debug build * lftp: skip D_FORTIFY_SOURCE=2 for debug build * libflac: don't use -g3 for debug build Configure script removes it otherwise. * nano: skip -D_FORTIFY_SOURCE=2 for debug build * vifm: skip -D_FORTIFY_SOURCE=2 for debug build * mc: skip -D_FORTIFY_SOURCE=2 for debug build * dropbear: add __attribute__((overloadable)) to XMEMSET and XMEMCPY if debug * gdb: add __attribute__((overloadable)) to strchr if debug * gnuit: add __attribute__((overloadable)) to strchr and strcpy if debug * gperf: add __attribute__((overloadable)) to strlen if debug * inetutils: add __attribute__((overloadable)) to strrchr and strchr if debug * readline: add __attribute__((overloadable)) to strchr if debug * tsocks: add __attribute__((overloadable)) to poll if debug * units: add __attribute__((overloadable)) to strchr if debug * liblua: fix bug in loslib.c that emerged in debug build Use strncpy instead of strcpy. Original error message: loslib.c:169:3: error: 'strcpy' called with string bigger than buffer lua_tmpnam(buff, err); ^ loslib.c:122:37: note: expanded from macro 'lua_tmpnam' strcpy(b, LUA_TMPNAMTEMPLATE); \ ^ * alpine: include our getpass.h in imap's mtest.c to declare getpass Debug build complained about the previous implicit declaration. * nginx: use --with-debug instead of --debug * cboard: skip -D_FORTIFY_SOURCE=2 for debug build * gettext: add __attribute__((overloadable)) to getcwd if debug * oathtool: skip -D_FORTIFY_SOURCE=2 for debug build * php: add __attribute__((overloadable)) to strlcpy and strlcat if debug * expect: add __attribute__((overloadable)) to strchr if debug * texlive: set TERMUX_PKG_HAS_DEBUG=no * asciinema: set TERMUX_PKG_HAS_DEBUG=no * libllvm: set TERMUX_PKG_HAS_DEBUG=no Debug build fails with: home/builder/.termux-build/libllvm/src/lib/Support/Unix/Path.inc:740:19: error: no matching function for call to 'RetryAfterSignal' if ((ResultFD = sys::RetryAfterSignal(-1, open, P.begin(), OpenFlags)) < 0) * build-package.sh: set TERMUX_PKG_REPLACES=package if debug build Hopefully allows us to install debug packages without breaking dependecies. Should be looked over and be made more similar to how debian does this in any case * Update build.sh
2018-06-13 02:12:36 +02:00
local DEBUG_PATCHES=""
if [ "$TERMUX_DEBUG" == "true" ] && [ -f $TERMUX_PKG_BUILDER_DIR/*.patch.debug ] ; then
DEBUG_PATCHES="$(ls $TERMUX_PKG_BUILDER_DIR/*.patch.debug)"
fi
2015-06-25 12:36:03 +02:00
# Suffix patch with ".patch32" or ".patch64" to only apply for these bitnesses:
shopt -s nullglob
Add fixes for debug builds (#2296) * build-package.sh: add possibility for debug patches and TERMUX_PKG_HAS_DEBUG Setting TERMUX_PKG_HAS_DEBUG=no disables attempt to build debug build of package. Useful for example if a debug build doesn't make sense, as for python-packages and texlive. * aapt: skip D_FORTIFY_SOURCE=2 for libandroid-cutils when doing debug build * lftp: skip D_FORTIFY_SOURCE=2 for debug build * libflac: don't use -g3 for debug build Configure script removes it otherwise. * nano: skip -D_FORTIFY_SOURCE=2 for debug build * vifm: skip -D_FORTIFY_SOURCE=2 for debug build * mc: skip -D_FORTIFY_SOURCE=2 for debug build * dropbear: add __attribute__((overloadable)) to XMEMSET and XMEMCPY if debug * gdb: add __attribute__((overloadable)) to strchr if debug * gnuit: add __attribute__((overloadable)) to strchr and strcpy if debug * gperf: add __attribute__((overloadable)) to strlen if debug * inetutils: add __attribute__((overloadable)) to strrchr and strchr if debug * readline: add __attribute__((overloadable)) to strchr if debug * tsocks: add __attribute__((overloadable)) to poll if debug * units: add __attribute__((overloadable)) to strchr if debug * liblua: fix bug in loslib.c that emerged in debug build Use strncpy instead of strcpy. Original error message: loslib.c:169:3: error: 'strcpy' called with string bigger than buffer lua_tmpnam(buff, err); ^ loslib.c:122:37: note: expanded from macro 'lua_tmpnam' strcpy(b, LUA_TMPNAMTEMPLATE); \ ^ * alpine: include our getpass.h in imap's mtest.c to declare getpass Debug build complained about the previous implicit declaration. * nginx: use --with-debug instead of --debug * cboard: skip -D_FORTIFY_SOURCE=2 for debug build * gettext: add __attribute__((overloadable)) to getcwd if debug * oathtool: skip -D_FORTIFY_SOURCE=2 for debug build * php: add __attribute__((overloadable)) to strlcpy and strlcat if debug * expect: add __attribute__((overloadable)) to strchr if debug * texlive: set TERMUX_PKG_HAS_DEBUG=no * asciinema: set TERMUX_PKG_HAS_DEBUG=no * libllvm: set TERMUX_PKG_HAS_DEBUG=no Debug build fails with: home/builder/.termux-build/libllvm/src/lib/Support/Unix/Path.inc:740:19: error: no matching function for call to 'RetryAfterSignal' if ((ResultFD = sys::RetryAfterSignal(-1, open, P.begin(), OpenFlags)) < 0) * build-package.sh: set TERMUX_PKG_REPLACES=package if debug build Hopefully allows us to install debug packages without breaking dependecies. Should be looked over and be made more similar to how debian does this in any case * Update build.sh
2018-06-13 02:12:36 +02:00
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,} $DEBUG_PATCHES; do
test -f "$patch" && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$patch" | \
sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
patch --silent -p1
2015-06-13 01:03:31 +02:00
done
2017-03-05 11:49:01 +01:00
shopt -u nullglob
}
2015-06-13 01:03:31 +02:00
# Replace autotools build-aux/config.{sub,guess} with ours to add android targets.
termux_step_replace_guess_scripts() {
cd "$TERMUX_PKG_SRCDIR"
find . -name config.sub -exec chmod u+w '{}' \; -exec cp "$TERMUX_SCRIPTDIR/scripts/config.sub" '{}' \;
find . -name config.guess -exec chmod u+w '{}' \; -exec cp "$TERMUX_SCRIPTDIR/scripts/config.guess" '{}' \;
2015-06-13 01:03:31 +02:00
}
# For package scripts to override. Called in $TERMUX_PKG_BUILDDIR.
2017-01-10 12:35:05 +01:00
termux_step_pre_configure() {
return
2015-06-13 01:03:31 +02:00
}
termux_step_configure_autotools() {
if [ ! -e "$TERMUX_PKG_SRCDIR/configure" ]; then return; fi
2015-06-13 01:03:31 +02:00
local DISABLE_STATIC="--disable-static"
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-static/}" ]; then
# Do not --disable-static if package explicitly enables it (e.g. gdb needs enable-static to build)
DISABLE_STATIC=""
fi
local DISABLE_NLS="--disable-nls"
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-nls/}" ]; then
# Do not --disable-nls if package explicitly enables it (for gettext itself)
DISABLE_NLS=""
fi
local ENABLE_SHARED="--enable-shared"
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--disable-shared/}" ]; then
ENABLE_SHARED=""
fi
local HOST_FLAG="--host=$TERMUX_HOST_PLATFORM"
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--host=/}" ]; then
HOST_FLAG=""
fi
local LIBEXEC_FLAG="--libexecdir=$TERMUX_PREFIX/libexec"
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--libexecdir=/}" ]; then
LIBEXEC_FLAG=""
fi
local QUIET_BUILD=
if [ $TERMUX_QUIET_BUILD = true ]; then
2018-02-20 01:49:45 +01:00
QUIET_BUILD="--enable-silent-rules --silent --quiet"
fi
2015-06-13 01:03:31 +02:00
# Some packages provides a $PKG-config script which some configure scripts pickup instead of pkg-config:
mkdir "$TERMUX_PKG_TMPDIR/config-scripts"
2015-06-13 01:03:31 +02:00
for f in $TERMUX_PREFIX/bin/*config; do
test -f "$f" && cp "$f" "$TERMUX_PKG_TMPDIR/config-scripts"
2015-06-13 01:03:31 +02:00
done
export PATH=$TERMUX_PKG_TMPDIR/config-scripts:$PATH
# Avoid gnulib wrapping of functions when cross compiling. See
# http://wiki.osdev.org/Cross-Porting_Software#Gnulib
# https://gitlab.com/sortix/sortix/wikis/Gnulib
# https://github.com/termux/termux-packages/issues/76
local AVOID_GNULIB=""
AVOID_GNULIB+=" ac_cv_func_nl_langinfo=yes"
AVOID_GNULIB+=" ac_cv_func_calloc_0_nonnull=yes"
AVOID_GNULIB+=" ac_cv_func_chown_works=yes"
AVOID_GNULIB+=" ac_cv_func_getgroups_works=yes"
AVOID_GNULIB+=" ac_cv_func_malloc_0_nonnull=yes"
AVOID_GNULIB+=" ac_cv_func_realloc_0_nonnull=yes"
AVOID_GNULIB+=" am_cv_func_working_getline=yes"
AVOID_GNULIB+=" gl_cv_func_dup2_works=yes"
AVOID_GNULIB+=" gl_cv_func_fcntl_f_dupfd_cloexec=yes"
AVOID_GNULIB+=" gl_cv_func_fcntl_f_dupfd_works=yes"
2017-04-02 12:38:18 +02:00
AVOID_GNULIB+=" gl_cv_func_fnmatch_posix=yes"
AVOID_GNULIB+=" gl_cv_func_getcwd_abort_bug=no"
AVOID_GNULIB+=" gl_cv_func_getcwd_null=yes"
AVOID_GNULIB+=" gl_cv_func_getcwd_path_max=yes"
AVOID_GNULIB+=" gl_cv_func_getcwd_posix_signature=yes"
AVOID_GNULIB+=" gl_cv_func_gettimeofday_clobber=no"
AVOID_GNULIB+=" gl_cv_func_gettimeofday_posix_signature=yes"
AVOID_GNULIB+=" gl_cv_func_link_works=yes"
AVOID_GNULIB+=" gl_cv_func_lstat_dereferences_slashed_symlink=yes"
2017-04-02 12:38:18 +02:00
AVOID_GNULIB+=" gl_cv_func_malloc_0_nonnull=yes"
AVOID_GNULIB+=" gl_cv_func_memchr_works=yes"
AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_dot_works=yes"
AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_slash_works=yes"
AVOID_GNULIB+=" gl_cv_func_mkfifo_works=yes"
2017-12-29 00:07:39 +01:00
AVOID_GNULIB+=" gl_cv_func_mknod_works=yes"
AVOID_GNULIB+=" gl_cv_func_realpath_works=yes"
AVOID_GNULIB+=" gl_cv_func_select_detects_ebadf=yes"
2017-04-02 12:38:18 +02:00
AVOID_GNULIB+=" gl_cv_func_snprintf_posix=yes"
AVOID_GNULIB+=" gl_cv_func_snprintf_retval_c99=yes"
2017-04-02 12:38:18 +02:00
AVOID_GNULIB+=" gl_cv_func_snprintf_truncation_c99=yes"
AVOID_GNULIB+=" gl_cv_func_stat_dir_slash=yes"
AVOID_GNULIB+=" gl_cv_func_stat_file_slash=yes"
AVOID_GNULIB+=" gl_cv_func_strerror_0_works=yes"
AVOID_GNULIB+=" gl_cv_func_symlink_works=yes"
AVOID_GNULIB+=" gl_cv_func_tzset_clobber=no"
AVOID_GNULIB+=" gl_cv_func_unlink_honors_slashes=yes"
AVOID_GNULIB+=" gl_cv_func_unlink_honors_slashes=yes"
2017-04-02 12:38:18 +02:00
AVOID_GNULIB+=" gl_cv_func_vsnprintf_posix=yes"
AVOID_GNULIB+=" gl_cv_func_vsnprintf_zerosize_c99=yes"
AVOID_GNULIB+=" gl_cv_func_wcwidth_works=yes"
AVOID_GNULIB+=" gl_cv_func_working_getdelim=yes"
AVOID_GNULIB+=" gl_cv_func_working_mkstemp=yes"
AVOID_GNULIB+=" gl_cv_func_working_mktime=yes"
AVOID_GNULIB+=" gl_cv_func_working_strerror=yes"
AVOID_GNULIB+=" gl_cv_header_working_fcntl_h=yes"
AVOID_GNULIB+=" gl_cv_C_locale_sans_EILSEQ=yes"
# NOTE: We do not want to quote AVOID_GNULIB as we want word expansion.
2018-08-27 22:36:11 +02:00
# shellcheck disable=SC2086
env $AVOID_GNULIB "$TERMUX_PKG_SRCDIR/configure" \
2015-06-13 01:03:31 +02:00
--disable-dependency-tracking \
--prefix=$TERMUX_PREFIX \
--libdir=$TERMUX_PREFIX/lib \
--disable-rpath --disable-rpath-hack \
2015-06-13 01:03:31 +02:00
$HOST_FLAG \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS \
$DISABLE_NLS \
$ENABLE_SHARED \
$DISABLE_STATIC \
$LIBEXEC_FLAG \
$QUIET_BUILD
2015-06-13 01:03:31 +02:00
}
termux_step_configure_cmake() {
2017-01-15 13:48:05 +01:00
termux_setup_cmake
local TOOLCHAIN_ARGS="-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=$TERMUX_STANDALONE_TOOLCHAIN"
local BUILD_TYPE=MinSizeRel
test -n "$TERMUX_DEBUG" && BUILD_TYPE=Debug
local CMAKE_PROC=$TERMUX_ARCH
test $CMAKE_PROC == "arm" && CMAKE_PROC='armv7-a'
2018-08-27 22:27:42 +02:00
local MAKE_PROGRAM_PATH
if [ $TERMUX_CMAKE_BUILD = Ninja ]; then
termux_setup_ninja
2019-02-12 09:41:30 +01:00
MAKE_PROGRAM_PATH=$(which ninja)
2018-08-27 22:27:42 +02:00
else
2019-02-12 09:41:30 +01:00
MAKE_PROGRAM_PATH=$(which make)
fi
2019-02-26 03:12:35 +01:00
CFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM -fno-addrsig"
CXXFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM -fno-addrsig"
2019-02-17 01:34:52 +01:00
LDFLAGS+=" --target=$CCTERMUX_HOST_PLATFORM"
2017-01-15 13:48:05 +01:00
# XXX: CMAKE_{AR,RANLIB} needed for at least jsoncpp build to not
# pick up cross compiled binutils tool in $PREFIX/bin:
cmake -G "$TERMUX_CMAKE_BUILD" "$TERMUX_PKG_SRCDIR" \
-DCMAKE_AR="$(which $AR)" \
-DCMAKE_UNAME="$(which uname)" \
-DCMAKE_RANLIB="$(which $RANLIB)" \
2017-01-15 13:48:05 +01:00
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS $CPPFLAGS" \
2017-01-15 13:48:05 +01:00
-DCMAKE_LINKER="$TERMUX_STANDALONE_TOOLCHAIN/bin/$LD $LDFLAGS" \
-DCMAKE_FIND_ROOT_PATH=$TERMUX_PREFIX \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX \
-DCMAKE_MAKE_PROGRAM=$MAKE_PROGRAM_PATH \
2017-01-15 13:48:05 +01:00
-DCMAKE_SYSTEM_PROCESSOR=$CMAKE_PROC \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_SYSTEM_VERSION=$TERMUX_PKG_API_LEVEL \
2017-01-15 13:48:05 +01:00
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DCMAKE_USE_SYSTEM_LIBRARIES=True \
-DDOXYGEN_EXECUTABLE= \
2017-01-15 13:48:05 +01:00
-DBUILD_TESTING=OFF \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS $TOOLCHAIN_ARGS
}
termux_step_configure_meson() {
termux_setup_meson
CC=gcc CXX=g++ $TERMUX_MESON \
$TERMUX_PKG_SRCDIR \
$TERMUX_PKG_BUILDDIR \
--cross-file $TERMUX_MESON_CROSSFILE \
--prefix $TERMUX_PREFIX \
--libdir lib \
--buildtype minsize \
--strip \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS
}
termux_step_configure() {
if [ "$TERMUX_PKG_FORCE_CMAKE" == 'no' ] && [ -f "$TERMUX_PKG_SRCDIR/configure" ]; then
2017-01-15 13:48:05 +01:00
termux_step_configure_autotools
elif [ -f "$TERMUX_PKG_SRCDIR/CMakeLists.txt" ]; then
termux_step_configure_cmake
elif [ -f "$TERMUX_PKG_SRCDIR/meson.build" ]; then
termux_step_configure_meson
2017-01-15 13:48:05 +01:00
fi
}
termux_step_post_configure() {
return
2015-06-13 01:03:31 +02:00
}
2017-01-10 12:35:05 +01:00
termux_step_make() {
local QUIET_BUILD=
if [ $TERMUX_QUIET_BUILD = true ]; then
2018-02-19 15:34:32 +01:00
QUIET_BUILD="-s"
fi
if test -f build.ninja; then
ninja -w dupbuild=warn -j $TERMUX_MAKE_PROCESSES
elif ls ./*akefile &> /dev/null || [ ! -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
2018-02-19 15:34:32 +01:00
make -j $TERMUX_MAKE_PROCESSES $QUIET_BUILD
else
2018-02-19 15:34:32 +01:00
make -j $TERMUX_MAKE_PROCESSES $QUIET_BUILD ${TERMUX_PKG_EXTRA_MAKE_ARGS}
fi
fi
2015-06-13 01:03:31 +02:00
}
2017-01-10 12:35:05 +01:00
termux_step_make_install() {
if test -f build.ninja; then
ninja -w dupbuild=warn -j $TERMUX_MAKE_PROCESSES install
elif ls ./*akefile &> /dev/null || [ ! -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
: "${TERMUX_PKG_MAKE_INSTALL_TARGET:="install"}"
# Some packages have problem with parallell install, and it does not buy much, so use -j 1.
if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
make -j 1 ${TERMUX_PKG_MAKE_INSTALL_TARGET}
else
make -j 1 ${TERMUX_PKG_EXTRA_MAKE_ARGS} ${TERMUX_PKG_MAKE_INSTALL_TARGET}
fi
elif test -f Cargo.toml; then
termux_setup_rust
cargo install \
--path . \
--force \
--target $CARGO_TARGET_NAME \
--root $TERMUX_PREFIX \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS
# https://github.com/rust-lang/cargo/issues/3316:
rm $TERMUX_PREFIX/.crates.toml
fi
2015-06-13 01:03:31 +02:00
}
# Hook function for package scripts to override.
2017-01-10 12:35:05 +01:00
termux_step_post_make_install() {
return
2015-06-13 01:03:31 +02:00
}
2017-01-10 12:35:05 +01:00
termux_step_extract_into_massagedir() {
local TARBALL_ORIG=$TERMUX_PKG_PACKAGEDIR/${TERMUX_PKG_NAME}_orig.tar.gz
2015-06-13 01:03:31 +02:00
# Build diff tar with what has changed during the build:
cd $TERMUX_PREFIX
tar -N "$TERMUX_BUILD_TS_FILE" \
--exclude='lib/libc++_shared.so' --exclude='lib/libstdc++.so' \
-czf "$TARBALL_ORIG" .
2015-06-13 01:03:31 +02:00
# Extract tar in order to massage it
mkdir -p "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
tar xf "$TARBALL_ORIG"
rm "$TARBALL_ORIG"
2015-06-13 01:03:31 +02:00
}
2017-01-10 12:35:05 +01:00
termux_step_massage() {
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
2015-06-13 01:03:31 +02:00
# Remove lib/charset.alias which is installed by gettext-using packages:
rm -f lib/charset.alias
2015-06-13 01:03:31 +02:00
# Remove non-english man pages:
2019-02-12 09:41:30 +01:00
test -d share/man && (cd share/man; for f in $(ls | grep -v man); do rm -Rf $f; done )
if [ -z "${TERMUX_PKG_KEEP_INFOPAGES+x}" ]; then
# Remove info pages:
rm -Rf share/info
fi
# Remove locale files we're not interested in::
rm -Rf share/locale
if [ -z "${TERMUX_PKG_KEEP_SHARE_DOC+x}" ]; then
# Remove info pages:
rm -Rf share/doc
fi
2015-06-13 01:03:31 +02:00
# Remove old kept libraries (readline):
find . -name '*.old' -delete
# Remove static libraries:
2015-06-13 01:03:31 +02:00
if [ $TERMUX_PKG_KEEP_STATIC_LIBRARIES = "false" ]; then
find . -name '*.a' -delete
find . -name '*.la' -delete
fi
2016-10-06 23:21:04 +02:00
# Move over sbin to bin:
for file in sbin/*; do if test -f "$file"; then mv "$file" bin/; fi; done
2015-06-13 01:03:31 +02:00
# Remove world permissions and add write permissions.
# The -f flag is used to suppress warnings about dangling symlinks (such
# as ones to /system/... which may not exist on the build machine):
2019-02-12 09:23:21 +01:00
find . -exec chmod -f u+w,g-rwx,o-rwx \{\} \;
2015-06-13 01:03:31 +02:00
if [ "$TERMUX_DEBUG" = "" ]; then
# Strip binaries. file(1) may fail for certain unusual files, so disable pipefail.
set +e +o pipefail
find . -type f | xargs -r file | grep -E "(executable|shared object)" | grep ELF | cut -f 1 -d : | \
xargs -r "$STRIP" --strip-unneeded --preserve-dates
set -e -o pipefail
2015-06-13 01:03:31 +02:00
fi
2016-10-06 23:21:04 +02:00
# Remove DT_ entries which the android 5.1 linker warns about:
find . -type f -print0 | xargs -r -0 "$TERMUX_ELF_CLEANER"
2016-10-06 23:21:04 +02:00
# Fix shebang paths:
while IFS= read -r -d '' file
do
head -c 100 "$file" | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && sed --follow-symlinks -i -E "1 s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" "$file"
done < <(find -L . -type f -print0)
2015-06-13 01:03:31 +02:00
test ! -z "$TERMUX_PKG_RM_AFTER_INSTALL" && rm -Rf $TERMUX_PKG_RM_AFTER_INSTALL
find . -type d -empty -delete # Remove empty directories
if [ -d share/man ]; then
# Compress man pages with gzip:
find share/man -type f -print0 | xargs -r -0 gzip
# Update man page symlinks, e.g. unzstd.1 -> zstd.1:
while IFS= read -r -d '' file
do
local _link_value
_link_value=$(readlink $file)
rm $file
ln -s $_link_value.gz $file.gz
done < <(find share/man -type l -print0)
fi
# Sub packages:
if [ -d include ] && [ -z "${TERMUX_PKG_NO_DEVELSPLIT}" ]; then
# Add virtual -dev sub package if there are include files:
local _DEVEL_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-dev.subpackage.sh
2017-03-22 00:21:00 +01:00
echo TERMUX_SUBPKG_INCLUDE=\"include share/vala share/man/man3 lib/pkgconfig share/aclocal lib/cmake $TERMUX_PKG_INCLUDE_IN_DEVPACKAGE\" > "$_DEVEL_SUBPACKAGE_FILE"
echo "TERMUX_SUBPKG_DESCRIPTION=\"Development files for ${TERMUX_PKG_NAME}\"" >> "$_DEVEL_SUBPACKAGE_FILE"
2016-07-20 00:48:39 +02:00
if [ -n "$TERMUX_PKG_DEVPACKAGE_DEPENDS" ]; then
echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME,$TERMUX_PKG_DEVPACKAGE_DEPENDS\"" >> "$_DEVEL_SUBPACKAGE_FILE"
2016-07-20 00:48:39 +02:00
else
2017-01-10 12:35:05 +01:00
echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME\"" >> "$_DEVEL_SUBPACKAGE_FILE"
2016-07-20 00:48:39 +02:00
fi
fi
# Now build all sub packages
rm -Rf "$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages"
2015-06-13 01:03:31 +02:00
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_DEPENDS=""
local TERMUX_SUBPKG_CONFLICTS=""
local TERMUX_SUBPKG_REPLACES=""
local TERMUX_SUBPKG_CONFFILES=""
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
2018-08-27 22:27:42 +02:00
source "$subpackage"
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
2015-06-13 01:03:31 +02:00
local SUB_PKG_ARCH=$TERMUX_ARCH
test -n "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" && SUB_PKG_ARCH=all
2015-06-13 01:03:31 +02:00
cd "$SUB_PKG_DIR/massage"
local SUB_PKG_INSTALLSIZE
SUB_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
tar -cJf "$SUB_PKG_PACKAGE_DIR/data.tar.xz" .
2015-06-13 01:03:31 +02:00
mkdir -p DEBIAN
2015-06-13 01:03:31 +02:00
cd DEBIAN
cat > control <<-HERE
Package: $SUB_PKG_NAME
Architecture: ${SUB_PKG_ARCH}
Installed-Size: ${SUB_PKG_INSTALLSIZE}
Maintainer: $TERMUX_PKG_MAINTAINER
Version: $TERMUX_PKG_FULLVERSION
Homepage: $TERMUX_PKG_HOMEPAGE
HERE
test ! -z "$TERMUX_SUBPKG_DEPENDS" && echo "Depends: $TERMUX_SUBPKG_DEPENDS" >> control
test ! -z "$TERMUX_SUBPKG_CONFLICTS" && echo "Conflicts: $TERMUX_SUBPKG_CONFLICTS" >> control
test ! -z "$TERMUX_SUBPKG_REPLACES" && echo "Replaces: $TERMUX_SUBPKG_REPLACES" >> control
echo "Description: $TERMUX_SUBPKG_DESCRIPTION" >> control
tar -czf "$SUB_PKG_PACKAGE_DIR/control.tar.gz" .
for f in $TERMUX_SUBPKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> conffiles; done
# Create the actual .deb file:
TERMUX_SUBPKG_DEBFILE=$TERMUX_DEBDIR/${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"
ar cr "$TERMUX_SUBPKG_DEBFILE" \
"$TERMUX_COMMON_CACHEDIR/debian-binary" \
"$SUB_PKG_PACKAGE_DIR/control.tar.gz" \
"$SUB_PKG_PACKAGE_DIR/data.tar.xz"
# Go back to main package:
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
2015-06-13 01:03:31 +02:00
done
# .. remove empty directories (NOTE: keep this last):
find . -type d -empty -delete
# Make sure user can read and write all files (problem with dpkg otherwise):
chmod -R u+rw .
2015-06-13 01:03:31 +02:00
}
2017-01-10 12:35:05 +01:00
termux_step_post_massage() {
return
2015-06-13 01:03:31 +02:00
}
# Create data.tar.gz with files to package. Not to be overridden by package scripts.
termux_step_create_datatar() {
# Create data tarball containing files to package:
cd "$TERMUX_PKG_MASSAGEDIR"
2018-08-27 22:27:42 +02:00
local HARDLINKS
HARDLINKS="$(find . -type f -links +1)"
if [ -n "$HARDLINKS" ]; then
termux_error_exit "Package contains hard links: $HARDLINKS"
fi
if [ -z "${TERMUX_PKG_METAPACKAGE+x}" ] && [ "$(find . -type f)" = "" ]; then
termux_error_exit "No files in package"
2016-01-11 01:45:41 +01:00
fi
tar -cJf "$TERMUX_PKG_PACKAGEDIR/data.tar.xz" .
}
2016-01-11 01:45:41 +01:00
2017-01-10 12:35:05 +01:00
termux_step_create_debscripts() {
return
}
# Create the build deb file. Not to be overridden by package scripts.
termux_step_create_debfile() {
# Get install size. This will be written as the "Installed-Size" deb field so is measured in 1024-byte blocks:
local TERMUX_PKG_INSTALLSIZE
TERMUX_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
# From here on TERMUX_ARCH is set to "all" if TERMUX_PKG_PLATFORM_INDEPENDENT is set by the package
test -n "$TERMUX_PKG_PLATFORM_INDEPENDENT" && TERMUX_ARCH=all
mkdir -p DEBIAN
cat > DEBIAN/control <<-HERE
Package: $TERMUX_PKG_NAME
Architecture: ${TERMUX_ARCH}
Installed-Size: ${TERMUX_PKG_INSTALLSIZE}
Maintainer: $TERMUX_PKG_MAINTAINER
Version: $TERMUX_PKG_FULLVERSION
Homepage: $TERMUX_PKG_HOMEPAGE
HERE
test ! -z "$TERMUX_PKG_BREAKS" && echo "Breaks: $TERMUX_PKG_BREAKS" >> DEBIAN/control
test ! -z "$TERMUX_PKG_DEPENDS" && echo "Depends: $TERMUX_PKG_DEPENDS" >> DEBIAN/control
test ! -z "$TERMUX_PKG_ESSENTIAL" && echo "Essential: yes" >> DEBIAN/control
test ! -z "$TERMUX_PKG_CONFLICTS" && echo "Conflicts: $TERMUX_PKG_CONFLICTS" >> DEBIAN/control
test ! -z "$TERMUX_PKG_RECOMMENDS" && echo "Recommends: $TERMUX_PKG_RECOMMENDS" >> DEBIAN/control
test ! -z "$TERMUX_PKG_REPLACES" && echo "Replaces: $TERMUX_PKG_REPLACES" >> DEBIAN/control
test ! -z "$TERMUX_PKG_PROVIDES" && echo "Provides: $TERMUX_PKG_PROVIDES" >> DEBIAN/control
test ! -z "$TERMUX_PKG_SUGGESTS" && echo "Suggests: $TERMUX_PKG_SUGGESTS" >> DEBIAN/control
echo "Description: $TERMUX_PKG_DESCRIPTION" >> DEBIAN/control
# Create DEBIAN/conffiles (see https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html):
for f in $TERMUX_PKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> DEBIAN/conffiles; done
# Allow packages to create arbitrary control files.
# XXX: Should be done in a better way without a function?
cd DEBIAN
termux_step_create_debscripts
# Create control.tar.gz
tar -czf "$TERMUX_PKG_PACKAGEDIR/control.tar.gz" .
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
# Create the actual .deb file:
ar cr "$TERMUX_PKG_DEBFILE" \
"$TERMUX_COMMON_CACHEDIR/debian-binary" \
"$TERMUX_PKG_PACKAGEDIR/control.tar.gz" \
"$TERMUX_PKG_PACKAGEDIR/data.tar.xz"
}
2015-06-13 01:03:31 +02:00
termux_step_compare_debs() {
if [ "${TERMUX_INSTALL_DEPS}" = true ]; then
cd ${TERMUX_SCRIPTDIR}
for DEB in $TERMUX_PKG_NAME $(basename $TERMUX_PKG_BUILDER_DIR/*.subpackage.sh | sed 's%\.subpackage\.sh%%g') $(basename $TERMUX_PKG_TMPDIR/*.subpackage.sh | sed 's%\.subpackage\.sh%%g'); do
read DEB_ARCH DEB_VERSION <<< $(termux_extract_dep_info "$DEB")
termux_download_deb $DEB $DEB_ARCH $DEB_VERSION \
&& (
DEB_FILE=${DEB}_${DEB_VERSION}_${DEB_ARCH}.deb
# `|| true` to prevent debdiff's exit code from stopping build
debdiff $TERMUX_DEBDIR/$DEB_FILE $TERMUX_COMMON_CACHEDIR-$TERMUX_ARCH/$DEB_FILE || true
) || echo "Download of ${DEB}@${DEB_VERSION} failed, not comparing debs"
echo ""
done
fi
}
2017-10-02 16:54:53 +02:00
# Finish the build. Not to be overridden by package scripts.
termux_step_finish_build() {
echo "termux - build of '$TERMUX_PKG_NAME' done"
test -t 1 && printf "\033]0;%s - DONE\007" "$TERMUX_PKG_NAME"
mkdir -p /data/data/.built-packages
echo "$TERMUX_PKG_FULLVERSION" > "/data/data/.built-packages/$TERMUX_PKG_NAME"
exit 0
}
termux_step_handle_arguments "$@"
termux_step_setup_variables
termux_step_handle_buildarch
termux_step_get_repo_files
termux_step_start_build
2015-06-13 01:03:31 +02:00
termux_step_extract_package
cd "$TERMUX_PKG_SRCDIR"
2015-06-13 01:03:31 +02:00
termux_step_post_extract_package
termux_step_handle_hostbuild
termux_step_setup_toolchain
2015-06-13 01:03:31 +02:00
termux_step_patch_package
termux_step_replace_guess_scripts
cd "$TERMUX_PKG_SRCDIR"
2015-06-13 01:03:31 +02:00
termux_step_pre_configure
cd "$TERMUX_PKG_BUILDDIR"
2015-06-13 01:03:31 +02:00
termux_step_configure
cd "$TERMUX_PKG_BUILDDIR"
2015-06-13 01:03:31 +02:00
termux_step_post_configure
cd "$TERMUX_PKG_BUILDDIR"
2015-06-13 01:03:31 +02:00
termux_step_make
cd "$TERMUX_PKG_BUILDDIR"
2015-06-13 01:03:31 +02:00
termux_step_make_install
cd "$TERMUX_PKG_BUILDDIR"
2015-06-13 01:03:31 +02:00
termux_step_post_make_install
cd "$TERMUX_PKG_MASSAGEDIR"
2015-06-13 01:03:31 +02:00
termux_step_extract_into_massagedir
cd "$TERMUX_PKG_MASSAGEDIR"
2015-06-13 01:03:31 +02:00
termux_step_massage
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
2015-06-13 01:03:31 +02:00
termux_step_post_massage
termux_step_create_datatar
termux_step_create_debfile
termux_step_compare_debs
termux_step_finish_build