build-package.sh: setting up to work with pacman (#8451)
This commit is contained in:
parent
daad590b41
commit
ece5419863
@ -96,8 +96,8 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_handle_buildarch.sh"
|
||||
source "$TERMUX_SCRIPTDIR/scripts/build/termux_extract_dep_info.sh"
|
||||
|
||||
# Function that downloads a .deb (using the termux_download function)
|
||||
# shellcheck source=scripts/build/termux_download_deb.sh
|
||||
source "$TERMUX_SCRIPTDIR/scripts/build/termux_download_deb.sh"
|
||||
# shellcheck source=scripts/build/termux_download_deb_pac.sh
|
||||
source "$TERMUX_SCRIPTDIR/scripts/build/termux_download_deb_pac.sh"
|
||||
|
||||
# Script to download InRelease, verify it's signature and then download Packages.xz by hash
|
||||
# shellcheck source=scripts/build/termux_get_repo_files.sh
|
||||
@ -269,7 +269,7 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_finish_build.sh"
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
||||
# For on device builds cross compiling is not supported.
|
||||
# Target architecture must be same as for environment used currently.
|
||||
TERMUX_ARCH=$(dpkg --print-architecture)
|
||||
TERMUX_ARCH=$(dpkg --print-architecture 2>/dev/null || pacman-conf | grep Architecture | sed 's/Architecture = //g')
|
||||
export TERMUX_ARCH
|
||||
fi
|
||||
|
||||
|
@ -25,12 +25,15 @@ termux_setup_cmake() {
|
||||
|
||||
export PATH=$TERMUX_CMAKE_FOLDER/bin:$PATH
|
||||
else
|
||||
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' cmake 2>/dev/null)" != "installed" ]; then
|
||||
if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' cmake 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q cmake 2>/dev/null)" ]]; then
|
||||
echo "Package 'cmake' is not installed."
|
||||
echo "You can install it with"
|
||||
echo
|
||||
echo " pkg install cmake"
|
||||
echo
|
||||
echo " pacman -S cmake"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -32,7 +32,8 @@ termux_setup_ghc() {
|
||||
|
||||
rm -Rf "$TERMUX_GHC_TEMP_FOLDER"
|
||||
else
|
||||
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]; then
|
||||
if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q ghc 2>/dev/null)" ]]; then
|
||||
echo "Package 'ghc' is not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -40,12 +40,15 @@ termux_setup_gn() {
|
||||
fi
|
||||
export PATH=$GN_FOLDER/out:$PATH
|
||||
else
|
||||
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' gn 2>/dev/null)" != "installed" ]; then
|
||||
if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' gn 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q gn 2>/dev/null)" ]]; then
|
||||
echo "Package 'gn' is not installed."
|
||||
echo "You can install it with"
|
||||
echo
|
||||
echo " pkg install gn"
|
||||
echo
|
||||
echo " pacman -S gn"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -24,12 +24,15 @@ termux_setup_golang() {
|
||||
|
||||
( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" )
|
||||
else
|
||||
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]; then
|
||||
if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' golang 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q golang 2>/dev/null)" ]]; then
|
||||
echo "Package 'golang' is not installed."
|
||||
echo "You can install it with"
|
||||
echo
|
||||
echo " pkg install golang"
|
||||
echo
|
||||
echo " pacman -S golang"
|
||||
echo
|
||||
echo "or build it from source with"
|
||||
echo
|
||||
echo " ./build-package.sh golang"
|
||||
|
@ -23,12 +23,15 @@ termux_setup_ninja() {
|
||||
local NINJA_PKG_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/ninja/build.sh; echo \$TERMUX_PKG_VERSION")
|
||||
if ([ ! -e "$TERMUX_BUILT_PACKAGES_DIRECTORY/ninja" ] ||
|
||||
[ "$(cat "$TERMUX_BUILT_PACKAGES_DIRECTORY/ninja")" != "$NINJA_PKG_VERSION" ]) &&
|
||||
[ "$(dpkg-query -W -f '${db:Status-Status}\n' ninja 2>/dev/null)" != "installed" ]; then
|
||||
([[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' ninja 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q ninja 2>/dev/null)" ]]); then
|
||||
echo "Package 'ninja' is not installed."
|
||||
echo "You can install it with"
|
||||
echo
|
||||
echo " pkg install ninja"
|
||||
echo
|
||||
echo " pacman -S ninja"
|
||||
echo
|
||||
echo "or build it from source with"
|
||||
echo
|
||||
echo " ./build-package.sh ninja"
|
||||
|
@ -6,12 +6,15 @@ termux_setup_rust() {
|
||||
fi
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
||||
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]; then
|
||||
if [[ "$(dpkg --version 2>/dev/null)" && "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]] ||
|
||||
[[ "$(pacman -V 2>/dev/null)" && ! "$(pacman -Q rust 2>/dev/null)" ]]; then
|
||||
echo "Package 'rust' is not installed."
|
||||
echo "You can install it with"
|
||||
echo
|
||||
echo " pkg install rust"
|
||||
echo
|
||||
echo " pacman -S rust"
|
||||
echo
|
||||
echo "or build it from source with"
|
||||
echo
|
||||
echo " ./build-package.sh rust"
|
||||
|
@ -67,24 +67,11 @@ termux_create_pacman_subpackages() {
|
||||
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_DEPENDS"
|
||||
fi
|
||||
|
||||
# Version view revisions.
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION//-/.}
|
||||
local INCORRECT_SYMBOLS=$(echo $TERMUX_PKG_VERSION_EDITED | grep -o '[0-9][a-z]')
|
||||
if [ -n "$INCORRECT_SYMBOLS" ]; then
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION_EDITED//${INCORRECT_SYMBOLS:0:1}${INCORRECT_SYMBOLS:1:1}/${INCORRECT_SYMBOLS:0:1}.${INCORRECT_SYMBOLS:1:1}}
|
||||
fi
|
||||
local TERMUX_PKG_FULLVERSION="${TERMUX_PKG_VERSION_EDITED}"
|
||||
if [ -n "$TERMUX_PKG_REVISION" ]; then
|
||||
TERMUX_PKG_FULLVERSION+="-${TERMUX_PKG_REVISION}"
|
||||
else
|
||||
TERMUX_PKG_FULLVERSION+="-0"
|
||||
fi
|
||||
|
||||
# Package metadata.
|
||||
{
|
||||
echo "pkgname = $SUB_PKG_NAME"
|
||||
echo "pkgbase = $TERMUX_PKG_NAME"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION_FOR_PACMAN"
|
||||
echo "pkgdesc = $(echo "$TERMUX_SUBPKG_DESCRIPTION" | tr '\n' ' ')"
|
||||
echo "url = $TERMUX_PKG_HOMEPAGE"
|
||||
echo "builddate = $BUILD_DATE"
|
||||
@ -122,7 +109,7 @@ termux_create_pacman_subpackages() {
|
||||
echo "format = 2"
|
||||
echo "pkgname = $SUB_PKG_NAME"
|
||||
echo "pkgbase = $TERMUX_PKG_NAME"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION_FOR_PACMAN"
|
||||
echo "pkgarch = $SUB_PKG_ARCH"
|
||||
echo "packager = $TERMUX_PKG_MAINTAINER"
|
||||
echo "builddate = $BUILD_DATE"
|
||||
@ -163,7 +150,7 @@ termux_create_pacman_subpackages() {
|
||||
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}
|
||||
local TERMUX_SUBPKG_PACMAN_FILE=$TERMUX_OUTPUT_DIR/${SUB_PKG_NAME}${DEBUG}-${TERMUX_PKG_FULLVERSION_FOR_PACMAN}-${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' \
|
||||
|
@ -1,10 +1,11 @@
|
||||
termux_download_deb() {
|
||||
termux_download_deb_pac() {
|
||||
local PACKAGE=$1
|
||||
local PACKAGE_ARCH=$2
|
||||
local VERSION=$3
|
||||
local VERSION_PACMAN=$4
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
||||
apt install -y "${PACKAGE}=${VERSION}"
|
||||
apt install -y "${PACKAGE}=${VERSION}" 2>/dev/null || pacman -S "${PACKAGE}=${VERSION_PACMAN}" --needed --noconfirm
|
||||
return "$?"
|
||||
fi
|
||||
|
@ -33,13 +33,25 @@ termux_extract_dep_info() {
|
||||
)
|
||||
fi
|
||||
(
|
||||
# debian version
|
||||
TERMUX_PKG_REVISION="0"
|
||||
source ${PKG_DIR}/build.sh
|
||||
if [ "$TERMUX_PKG_REVISION" != "0" ] || \
|
||||
[ "$TERMUX_PKG_VERSION" != "${TERMUX_PKG_VERSION/-/}" ]; then
|
||||
TERMUX_PKG_VERSION+="-$TERMUX_PKG_REVISION"
|
||||
fi
|
||||
echo ${TERMUX_ARCH} ${TERMUX_PKG_VERSION}
|
||||
echo -n "${TERMUX_ARCH} ${TERMUX_PKG_VERSION} "
|
||||
)
|
||||
(
|
||||
# pacman version
|
||||
TERMUX_PKG_REVISION="0"
|
||||
source ${PKG_DIR}/build.sh
|
||||
TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION//-/.}
|
||||
INCORRECT_SYMBOLS=$(echo $TERMUX_PKG_VERSION_EDITED | grep -o '[0-9][a-z]')
|
||||
if [ -n "$INCORRECT_SYMBOLS" ]; then
|
||||
TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION_EDITED//${INCORRECT_SYMBOLS:0:1}${INCORRECT_SYMBOLS:1:1}/${INCORRECT_SYMBOLS:0:1}.${INCORRECT_SYMBOLS:1:1}}
|
||||
fi
|
||||
echo "${TERMUX_PKG_VERSION_EDITED}-${TERMUX_PKG_REVISION}"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -35,20 +35,7 @@ termux_step_create_pacman_package() {
|
||||
PKG_FORMAT="xz";;
|
||||
esac
|
||||
|
||||
# Version view revisions.
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION//-/.}
|
||||
local INCORRECT_SYMBOLS=$(echo $TERMUX_PKG_VERSION_EDITED | grep -o '[0-9][a-z]')
|
||||
if [ -n "$INCORRECT_SYMBOLS" ]; then
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION_EDITED//${INCORRECT_SYMBOLS:0:1}${INCORRECT_SYMBOLS:1:1}/${INCORRECT_SYMBOLS:0:1}.${INCORRECT_SYMBOLS:1:1}}
|
||||
fi
|
||||
local TERMUX_PKG_FULLVERSION="${TERMUX_PKG_VERSION_EDITED}"
|
||||
if [ -n "$TERMUX_PKG_REVISION" ]; then
|
||||
TERMUX_PKG_FULLVERSION+="-${TERMUX_PKG_REVISION}"
|
||||
else
|
||||
TERMUX_PKG_FULLVERSION+="-0"
|
||||
fi
|
||||
|
||||
local PACMAN_FILE=$TERMUX_OUTPUT_DIR/${TERMUX_PKG_NAME}${DEBUG}-${TERMUX_PKG_FULLVERSION}-${TERMUX_ARCH}.pkg.tar.${PKG_FORMAT}
|
||||
local PACMAN_FILE=$TERMUX_OUTPUT_DIR/${TERMUX_PKG_NAME}${DEBUG}-${TERMUX_PKG_FULLVERSION_FOR_PACMAN}-${TERMUX_ARCH}.pkg.tar.${PKG_FORMAT}
|
||||
|
||||
local BUILD_DATE
|
||||
BUILD_DATE=$(date +%s)
|
||||
@ -57,7 +44,7 @@ termux_step_create_pacman_package() {
|
||||
{
|
||||
echo "pkgname = $TERMUX_PKG_NAME"
|
||||
echo "pkgbase = $TERMUX_PKG_NAME"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION_FOR_PACMAN"
|
||||
echo "pkgdesc = $(echo "$TERMUX_PKG_DESCRIPTION" | tr '\n' ' ')"
|
||||
echo "url = $TERMUX_PKG_HOMEPAGE"
|
||||
echo "builddate = $BUILD_DATE"
|
||||
@ -115,7 +102,7 @@ termux_step_create_pacman_package() {
|
||||
echo "format = 2"
|
||||
echo "pkgname = $TERMUX_PKG_NAME"
|
||||
echo "pkgbase = $TERMUX_PKG_NAME"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION"
|
||||
echo "pkgver = $TERMUX_PKG_FULLVERSION_FOR_PACMAN"
|
||||
echo "pkgarch = $TERMUX_ARCH"
|
||||
echo "packager = $TERMUX_PKG_MAINTAINER"
|
||||
echo "builddate = $BUILD_DATE"
|
||||
|
@ -4,7 +4,7 @@ termux_step_get_dependencies() {
|
||||
termux_get_repo_files
|
||||
|
||||
# When doing build on device, ensure that apt lists are up-to-date.
|
||||
[ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && apt update
|
||||
[ "$TERMUX_ON_DEVICE_BUILD" = "true" ] && (apt update 2>/dev/null || pacman -Sy)
|
||||
|
||||
# Download dependencies
|
||||
while read PKG PKG_DIR; do
|
||||
@ -15,7 +15,7 @@ termux_step_get_dependencies() {
|
||||
fi
|
||||
# llvm doesn't build if ndk-sysroot is installed:
|
||||
if [ "$PKG" = "ndk-sysroot" ]; then continue; fi
|
||||
read DEP_ARCH DEP_VERSION <<< $(termux_extract_dep_info $PKG "${PKG_DIR}")
|
||||
read DEP_ARCH DEP_VERSION DEP_VERSION_PAC <<< $(termux_extract_dep_info $PKG "${PKG_DIR}")
|
||||
|
||||
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
|
||||
echo "Downloading dependency $PKG@$DEP_VERSION if necessary..."
|
||||
@ -27,7 +27,7 @@ termux_step_get_dependencies() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! termux_download_deb $PKG $DEP_ARCH $DEP_VERSION; then
|
||||
if ! termux_download_deb_pac $PKG $DEP_ARCH $DEP_VERSION $DEP_VERSION_PAC; then
|
||||
echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead"
|
||||
TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I --format $TERMUX_PACKAGE_FORMAT "${PKG_DIR}"
|
||||
continue
|
||||
|
@ -25,6 +25,18 @@ termux_step_start_build() {
|
||||
# "0" is the default revision, so only include it if the upstream versions contains "-" itself
|
||||
TERMUX_PKG_FULLVERSION+="-$TERMUX_PKG_REVISION"
|
||||
fi
|
||||
# full format version for pacman
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION//-/.}
|
||||
local INCORRECT_SYMBOLS=$(echo $TERMUX_PKG_VERSION_EDITED | grep -o '[0-9][a-z]')
|
||||
if [ -n "$INCORRECT_SYMBOLS" ]; then
|
||||
local TERMUX_PKG_VERSION_EDITED=${TERMUX_PKG_VERSION_EDITED//${INCORRECT_SYMBOLS:0:1}${INCORRECT_SYMBOLS:1:1}/${INCORRECT_SYMBOLS:0:1}.${INCORRECT_SYMBOLS:1:1}}
|
||||
fi
|
||||
TERMUX_PKG_FULLVERSION_FOR_PACMAN="${TERMUX_PKG_VERSION_EDITED}"
|
||||
if [ -n "$TERMUX_PKG_REVISION" ]; then
|
||||
TERMUX_PKG_FULLVERSION_FOR_PACMAN+="-${TERMUX_PKG_REVISION}"
|
||||
else
|
||||
TERMUX_PKG_FULLVERSION_FOR_PACMAN+="-0"
|
||||
fi
|
||||
|
||||
if [ "$TERMUX_DEBUG_BUILD" = "true" ]; then
|
||||
if [ "$TERMUX_PKG_HAS_DEBUG" = "true" ]; then
|
||||
@ -43,7 +55,8 @@ termux_step_start_build() {
|
||||
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm $TERMUX_BUILT_PACKAGES_DIRECTORY/$TERMUX_PKG_NAME to force rebuild)"
|
||||
exit 0
|
||||
elif [ "$TERMUX_ON_DEVICE_BUILD" = "true" ] &&
|
||||
[ "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ]; then
|
||||
([ "$(dpkg-query -W -f '${db:Status-Status} ${Version}\n' "$TERMUX_PKG_NAME" 2>/dev/null)" = "installed $TERMUX_PKG_FULLVERSION" ] ||
|
||||
[ "$(pacman -Q $TERMUX_PKG_NAME 2>/dev/null)" = "$TERMUX_PKG_NAME $TERMUX_PKG_FULLVERSION_FOR_PACMAN" ]); then
|
||||
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION installed - skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user