2017-02-21 15:44:15 +00:00
|
|
|
#!/bin/ash -e
|
2023-10-17 13:54:31 +00:00
|
|
|
# vim: set filetype=sh:
|
2008-10-18 08:09:24 +00:00
|
|
|
|
2013-07-05 04:21:13 +00:00
|
|
|
# abuild - build apk packages (light version of makepkg)
|
2015-06-03 12:14:50 +00:00
|
|
|
# Copyright (c) 2008-2015 Natanael Copa <ncopa@alpinelinux.org>
|
2016-07-26 08:05:17 +00:00
|
|
|
# Copyright (c) 2016 Timo Teräs <timo.teras@iki.fi>
|
2008-10-18 08:09:24 +00:00
|
|
|
#
|
2020-10-23 14:39:18 +00:00
|
|
|
# Distributed under GPL-2.0-only
|
2008-10-18 08:09:24 +00:00
|
|
|
#
|
|
|
|
|
2013-10-25 07:26:05 +00:00
|
|
|
program_version=@VERSION@
|
2019-11-07 11:28:37 +00:00
|
|
|
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
|
2008-10-18 08:09:24 +00:00
|
|
|
|
2009-10-24 20:37:20 +00:00
|
|
|
abuild_path=$(readlink -f $0)
|
2022-06-15 12:24:42 +00:00
|
|
|
|
|
|
|
: ${git:=$(command -v git || echo true)}
|
|
|
|
export git
|
2008-10-18 08:09:24 +00:00
|
|
|
|
2019-11-07 11:21:32 +00:00
|
|
|
if ! [ -f "$sharedir/functions.sh" ]; then
|
|
|
|
echo "$sharedir/functions.sh: not found" >&2
|
2013-10-25 07:07:50 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-07 11:21:32 +00:00
|
|
|
. "$sharedir/functions.sh"
|
2013-10-25 07:07:50 +00:00
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
# defaults
|
2013-10-25 07:07:50 +00:00
|
|
|
: ${FAKEROOT:="fakeroot"}
|
|
|
|
: ${SUDO_APK:="abuild-apk"}
|
|
|
|
: ${APK:="apk"}
|
|
|
|
: ${ADDUSER:="abuild-adduser"}
|
|
|
|
: ${ADDGROUP:="abuild-addgroup"}
|
2019-07-20 01:14:20 +00:00
|
|
|
: ${CC:="gcc"}
|
|
|
|
: ${CXX:="g++"}
|
2021-04-28 08:33:23 +00:00
|
|
|
: ${SETFATTR:="setfattr"}
|
2012-02-17 13:48:11 +00:00
|
|
|
|
2011-03-30 09:10:11 +00:00
|
|
|
apk_opt_wait="--wait 30"
|
2023-06-03 10:55:12 +00:00
|
|
|
doc_threshold=$((2 * 1024 * 1024)) # 2 MiB
|
2009-02-02 15:48:19 +00:00
|
|
|
|
2016-03-17 13:20:34 +00:00
|
|
|
umask 022
|
|
|
|
|
2019-05-30 08:54:10 +00:00
|
|
|
shell_escape() {
|
|
|
|
echo \'${1/\'/\'\\\'\'}\'
|
|
|
|
}
|
|
|
|
|
2013-04-19 09:22:32 +00:00
|
|
|
# run optional log command for remote logging
|
|
|
|
logcmd() {
|
|
|
|
${ABUILD_LOG_CMD:-true} "$@"
|
|
|
|
return 0
|
|
|
|
}
|
2009-05-08 13:33:34 +00:00
|
|
|
|
2013-10-25 07:07:50 +00:00
|
|
|
# we override the default msg, warning and error as we want the pkgname
|
2009-05-08 13:33:34 +00:00
|
|
|
msg() {
|
2012-02-13 07:37:06 +00:00
|
|
|
[ -n "$quiet" ] && return 0
|
2009-05-08 13:33:34 +00:00
|
|
|
local prompt="$GREEN>>>${NORMAL}"
|
|
|
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
|
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
2012-02-13 07:37:06 +00:00
|
|
|
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
|
|
|
|
}
|
|
|
|
|
2009-05-08 13:33:34 +00:00
|
|
|
warning() {
|
|
|
|
local prompt="${YELLOW}>>> WARNING:${NORMAL}"
|
|
|
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
|
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
2012-02-13 07:37:06 +00:00
|
|
|
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
|
|
|
|
}
|
|
|
|
|
2009-05-08 13:33:34 +00:00
|
|
|
error() {
|
|
|
|
local prompt="${RED}>>> ERROR:${NORMAL}"
|
|
|
|
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
|
|
|
|
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
|
2012-02-13 07:37:06 +00:00
|
|
|
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
|
2013-04-19 09:22:32 +00:00
|
|
|
logcmd "ERROR: $pkgname: $1"
|
2012-02-13 07:37:06 +00:00
|
|
|
}
|
|
|
|
|
2019-10-01 15:25:45 +00:00
|
|
|
amove() {
|
|
|
|
[ -n "$subpkgdir" ] || return 1
|
|
|
|
|
|
|
|
# store directory
|
|
|
|
d="$(pwd -L)"
|
|
|
|
|
|
|
|
cd "$pkgdir"
|
2023-12-12 21:38:22 +00:00
|
|
|
local pattern f IFS=""
|
2019-10-01 15:25:45 +00:00
|
|
|
for pattern; do
|
|
|
|
for f in ${pattern#/}; do # let shell expand the pattern
|
2022-09-23 10:31:56 +00:00
|
|
|
# strip trailing /
|
|
|
|
f=${f%/}
|
2019-10-01 15:25:45 +00:00
|
|
|
if [ "${f%/*}" != "$f" ]; then
|
|
|
|
mkdir -p "$subpkgdir/${f%/*}"
|
2023-12-12 21:38:22 +00:00
|
|
|
mv -v "$pkgdir/$f" "$subpkgdir/${f%/*}"
|
2022-09-23 10:31:56 +00:00
|
|
|
else
|
|
|
|
mkdir -p "$subpkgdir"
|
2023-12-12 21:38:22 +00:00
|
|
|
mv -v "$pkgdir/$f" "$subpkgdir/"
|
2019-10-01 15:25:45 +00:00
|
|
|
fi
|
|
|
|
# cleanup
|
2020-02-23 19:14:38 +00:00
|
|
|
rmdir -p "$f" 2>/dev/null || rmdir -p "${f%/*}" 2>/dev/null || true
|
2019-10-01 15:25:45 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
cd "$d"
|
|
|
|
}
|
|
|
|
|
2017-02-23 11:31:49 +00:00
|
|
|
cross_creating() {
|
|
|
|
test "$CHOST" != "$CTARGET" -a -n "$CBUILDROOT"
|
|
|
|
}
|
|
|
|
|
2013-09-05 08:40:59 +00:00
|
|
|
cross_compiling() {
|
|
|
|
test "$CBUILD" != "$CHOST" -a -n "$CBUILDROOT"
|
|
|
|
}
|
|
|
|
|
2017-01-29 09:47:25 +00:00
|
|
|
want_check() {
|
2017-03-21 09:28:34 +00:00
|
|
|
[ -n "$ABUILD_BOOTSTRAP" ] && return 1
|
2017-01-29 09:47:25 +00:00
|
|
|
cross_compiling && return 1
|
|
|
|
options_has "!check" && return 1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-11-13 17:15:28 +00:00
|
|
|
set_source_date() {
|
2019-12-05 08:32:30 +00:00
|
|
|
# dont error out if APKBUILD is not in git
|
|
|
|
if ! $git rev-parse --show-toplevel >/dev/null 2>&1; then
|
|
|
|
git=true
|
|
|
|
fi
|
2019-11-13 17:15:28 +00:00
|
|
|
# set time stamp for reproducible builds
|
2019-11-26 18:41:32 +00:00
|
|
|
if [ -z "$ABUILD_LAST_COMMIT" ]; then
|
|
|
|
export ABUILD_LAST_COMMIT="$(git_last_commit)$(git_dirty)"
|
|
|
|
fi
|
2019-11-13 17:15:28 +00:00
|
|
|
if [ -z "$SOURCE_DATE_EPOCH" ] && [ "${ABUILD_LAST_COMMIT%-dirty}" = "$ABUILD_LAST_COMMIT" ]; then
|
|
|
|
SOURCE_DATE_EPOCH=$(git_last_commit_epoch $ABUILD_LAST_COMMIT)
|
|
|
|
fi
|
|
|
|
if [ -z "$SOURCE_DATE_EPOCH" ]; then
|
2022-06-20 09:52:00 +00:00
|
|
|
SOURCE_DATE_EPOCH=$(stat -c "%Y" "$APKBUILD")
|
2019-11-13 17:15:28 +00:00
|
|
|
fi
|
|
|
|
export SOURCE_DATE_EPOCH
|
|
|
|
}
|
|
|
|
|
2018-12-08 18:22:44 +00:00
|
|
|
default_cleanup_srcdir() {
|
2019-04-29 21:26:47 +00:00
|
|
|
if options_has "chmod-clean" && test -d "$srcdir"; then
|
2019-03-03 18:15:00 +00:00
|
|
|
chmod -R +w "$srcdir"
|
|
|
|
fi
|
2018-12-08 18:22:44 +00:00
|
|
|
rm -rf "$srcdir"
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_srcdir() {
|
|
|
|
default_cleanup_srcdir
|
|
|
|
}
|
|
|
|
|
2008-11-08 13:45:30 +00:00
|
|
|
cleanup() {
|
2013-08-01 12:16:57 +00:00
|
|
|
local i=
|
2016-07-27 06:49:09 +00:00
|
|
|
[ -z "$subpkgdir" ] && set_xterm_title ""
|
2017-03-24 11:30:57 +00:00
|
|
|
if [ -n "$keep_build" ]; then
|
|
|
|
return 0
|
2012-01-20 08:19:39 +00:00
|
|
|
fi
|
2013-08-01 12:16:57 +00:00
|
|
|
for i; do
|
|
|
|
case $i in
|
2017-04-05 13:28:13 +00:00
|
|
|
bldroot)
|
|
|
|
if [ "$BUILD_ROOT" ]; then
|
|
|
|
msg "Cleaning up build chroot"
|
|
|
|
abuild-rmtemp "$BUILD_ROOT"
|
|
|
|
fi;;
|
2013-08-01 12:16:57 +00:00
|
|
|
pkgdir) msg "Cleaning up pkgdir"; rm -rf "$pkgbasedir";;
|
2018-12-08 18:22:44 +00:00
|
|
|
srcdir) msg "Cleaning up srcdir"; cleanup_srcdir;;
|
2023-06-22 03:33:59 +00:00
|
|
|
tmpdir) msg "Cleaning up tmpdir"; rm -rf "$tmpdir";;
|
2013-08-01 12:16:57 +00:00
|
|
|
deps)
|
2019-05-22 12:53:37 +00:00
|
|
|
if [ -n "$uninstall_after" ]; then
|
2013-08-01 12:16:57 +00:00
|
|
|
msg "Uninstalling dependencies..."
|
2016-07-27 10:17:19 +00:00
|
|
|
undeps
|
2013-08-01 12:16:57 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2008-11-08 13:45:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
die() {
|
2017-04-17 11:44:04 +00:00
|
|
|
trap - EXIT
|
2008-11-08 11:05:45 +00:00
|
|
|
error "$@"
|
2013-08-01 12:16:57 +00:00
|
|
|
cleanup $ERROR_CLEANUP
|
2008-10-18 08:09:24 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-07-02 06:16:18 +00:00
|
|
|
spell_error() {
|
|
|
|
die "APKBUILD contains '$1'. It should be '$2'"
|
|
|
|
}
|
|
|
|
|
2022-01-17 14:44:10 +00:00
|
|
|
verify_pkgname() {
|
2024-03-22 10:48:28 +00:00
|
|
|
case $1 in
|
|
|
|
''|*[!a-zA-Z0-9._+-]*|[!a-zA-Z0-9]*) return 1;;
|
2022-01-17 14:44:10 +00:00
|
|
|
esac
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-07-24 11:53:11 +00:00
|
|
|
# check if apkbuild is basically sane
|
2011-12-14 09:54:43 +00:00
|
|
|
default_sanitycheck() {
|
2024-03-28 14:08:24 +00:00
|
|
|
local i= j=
|
2008-11-08 10:26:09 +00:00
|
|
|
msg "Checking sanity of $APKBUILD..."
|
2008-11-06 14:23:04 +00:00
|
|
|
[ -z "$pkgver" ] && die "Missing pkgver in APKBUILD"
|
2024-03-22 11:20:54 +00:00
|
|
|
$APK version --check --quiet -- "$pkgver"-r0 || \
|
2024-03-22 11:18:34 +00:00
|
|
|
die "$pkgver is not a valid version"
|
2010-05-04 11:28:44 +00:00
|
|
|
[ -z "$pkgrel" ] && die "Missing pkgrel in APKBUILD"
|
2020-12-13 14:23:19 +00:00
|
|
|
# give 0 as it is always valid and give the pkgrel
|
|
|
|
$APK version --check --quiet 0-r"$pkgrel" || \
|
|
|
|
die "$pkgrel is not a valid pkgrel"
|
2024-03-28 14:08:24 +00:00
|
|
|
# digit+letter+digit passes the apk2 version check
|
|
|
|
case $pkgver in
|
|
|
|
*[0-9][a-z][0-9]*)
|
|
|
|
die "the digit+letter+digit version format is invalid. Use suffixes instead"
|
|
|
|
;;
|
|
|
|
esac
|
2024-03-13 10:43:10 +00:00
|
|
|
|
2008-11-06 14:23:04 +00:00
|
|
|
[ -z "$pkgdesc" ] && die "Missing pkgdesc in APKBUILD"
|
|
|
|
[ -z "$url" ] && die "Missing url in APKBUILD"
|
2017-09-28 06:40:01 +00:00
|
|
|
[ -z "$license" ] && die "Missing license in APKBUILD"
|
2013-02-07 14:54:36 +00:00
|
|
|
if [ $(echo "$pkgdesc" | wc -c) -gt 128 ]; then
|
|
|
|
die "pkgdesc is too long"
|
|
|
|
fi
|
2023-02-10 00:03:24 +00:00
|
|
|
if [ $(echo "$pkgdesc" | wc -l) -gt 1 ]; then
|
|
|
|
die "pkgdesc is not a single line"
|
|
|
|
fi
|
2018-10-03 11:10:55 +00:00
|
|
|
is_function package || die "Missing package() function in APKBUILD"
|
2008-11-06 14:23:04 +00:00
|
|
|
|
2012-02-22 14:23:16 +00:00
|
|
|
if [ -n "$replaces_priority" ] \
|
2022-09-12 15:06:21 +00:00
|
|
|
&& ! echo $replaces_priority | grep -E -q '^[0-9]+$'; then
|
2012-02-17 14:16:35 +00:00
|
|
|
die "replaces_priority must be a number"
|
|
|
|
fi
|
2017-11-02 04:51:51 +00:00
|
|
|
|
|
|
|
if [ -n "$provider_priority" ] \
|
2022-09-12 15:06:21 +00:00
|
|
|
&& ! echo $provider_priority | grep -E -q '^[0-9]+$'; then
|
2017-11-02 04:51:51 +00:00
|
|
|
die "provider_priority must be a number"
|
|
|
|
fi
|
|
|
|
|
2022-01-17 14:44:10 +00:00
|
|
|
# check pkgname and subpkgnames
|
|
|
|
for i in "$pkgname" $subpackages; do
|
|
|
|
verify_pkgname "${i%%:*}" || die "${i%%:*} is not a valid package name"
|
2011-11-01 08:50:20 +00:00
|
|
|
done
|
|
|
|
|
2009-08-13 19:33:12 +00:00
|
|
|
for i in $install; do
|
2011-06-27 18:44:07 +00:00
|
|
|
local n=${i%.*}
|
2011-06-30 07:52:46 +00:00
|
|
|
local suff=${i##*.}
|
2011-06-27 18:44:07 +00:00
|
|
|
case "$suff" in
|
|
|
|
pre-install|post-install|pre-upgrade|post-upgrade|pre-deinstall|post-deinstall);;
|
|
|
|
*) die "$i: unknown install script suffix"
|
|
|
|
esac
|
|
|
|
if ! subpackages_has "$n" && [ "$n" != "$pkgname" ]; then
|
2011-06-27 20:13:20 +00:00
|
|
|
die "$i: install script does not match pkgname or any subpackage"
|
2011-06-27 18:44:07 +00:00
|
|
|
fi
|
2011-06-27 20:13:20 +00:00
|
|
|
[ -e "$startdir/$i" ] || die "install script $i is missing"
|
2012-02-13 07:37:56 +00:00
|
|
|
for j in chown chmod chgrp; do
|
|
|
|
if grep -q $j "$startdir"/$i; then
|
|
|
|
warning "$i: found $j"
|
|
|
|
warning2 "Permissions should be fixed in APKBUILD package()"
|
|
|
|
fi
|
|
|
|
done
|
2009-08-13 19:33:12 +00:00
|
|
|
done
|
2013-07-02 06:16:18 +00:00
|
|
|
|
2011-06-27 20:13:20 +00:00
|
|
|
for i in $triggers; do
|
|
|
|
local f=${i%=*}
|
|
|
|
local p=${f%.trigger}
|
2013-07-02 07:18:11 +00:00
|
|
|
[ "$f" = "$i" ] && die "$f: triggers must contain '='"
|
2011-06-27 20:13:20 +00:00
|
|
|
[ "$p" = "$f" ] && die "$f: triggers scripts must have .trigger suffix"
|
|
|
|
if ! subpackages_has "$p" && [ "$p" != "$pkgname" ]; then
|
|
|
|
die "$p: trigger script does not match pkgname or any subpackage"
|
|
|
|
fi
|
2009-08-13 19:33:12 +00:00
|
|
|
|
2018-03-11 14:20:39 +00:00
|
|
|
if source_has "$f"; then
|
|
|
|
warning "You should not have \$triggers in source"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2011-06-27 20:13:20 +00:00
|
|
|
[ -e "$startdir"/$f ] || die "trigger script $f is missing"
|
|
|
|
done
|
2009-02-20 09:08:26 +00:00
|
|
|
if [ -n "$source" ]; then
|
|
|
|
for i in $source; do
|
2009-08-13 19:33:12 +00:00
|
|
|
if install_has "$i"; then
|
|
|
|
warning "You should not have \$install in source"
|
|
|
|
continue
|
|
|
|
fi
|
2009-03-26 09:13:46 +00:00
|
|
|
case "$i" in
|
2013-02-20 13:38:22 +00:00
|
|
|
*::*) i=${i%%::*};;
|
2012-02-17 13:51:01 +00:00
|
|
|
https://*) makedepends_has wget && warning "wget no longer need to be in makedepends when source has https://" ;;
|
2009-03-26 09:13:46 +00:00
|
|
|
esac
|
2013-02-20 13:38:22 +00:00
|
|
|
list_has ${i##*/} $md5sums $sha256sums $sha512sums \
|
|
|
|
|| die "${i##*/} is missing in checksums"
|
2015-04-28 14:03:54 +00:00
|
|
|
|
|
|
|
# verify that our source does not have git tag version
|
2021-07-24 11:53:11 +00:00
|
|
|
# name as tarball (typically github)
|
2015-04-28 14:03:54 +00:00
|
|
|
if is_remote "$i" && [ "${i#*::}" = "$i" ]; then
|
|
|
|
case ${i##*/} in
|
|
|
|
v$pkgver.tar.*|$pkgver.tar.*)
|
|
|
|
die "source ${i##*/} needs to be renamed to avoid possible collisions"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2009-02-20 09:08:26 +00:00
|
|
|
done
|
|
|
|
fi
|
2009-02-08 21:02:22 +00:00
|
|
|
|
2012-11-29 12:09:57 +00:00
|
|
|
# verify that things listed in checksum also is listed in source
|
|
|
|
local algo=
|
|
|
|
for algo in md5 sha256 sha512; do
|
|
|
|
eval set -- \$${algo}sums
|
|
|
|
while [ $# -gt 1 ]; do
|
|
|
|
local file="$2"
|
|
|
|
shift 2
|
2018-01-23 13:45:30 +00:00
|
|
|
source_has $file || die "$file exists in ${algo}sums but is missing in \$source"
|
2009-02-20 09:08:26 +00:00
|
|
|
done
|
2012-11-29 12:09:57 +00:00
|
|
|
done
|
2008-11-06 16:08:30 +00:00
|
|
|
|
2008-11-06 14:23:04 +00:00
|
|
|
# common spelling errors
|
2013-07-02 06:16:18 +00:00
|
|
|
[ -n "$depend" ] && spell_error depend depends
|
|
|
|
[ -n "$makedepend" ] && spell_error makedepend makedepends
|
|
|
|
[ -n "$pkguser" ] && spell_error pkguser pkgusers
|
|
|
|
[ -n "$pkggroup" ] && spell_error pkggroup pkggroups
|
|
|
|
[ -n "$subpackage" ] && spell_error subpackage subpackages
|
2017-01-29 09:47:25 +00:00
|
|
|
[ -n "$checkdepend" ] && spell_error checkdepend checkdepends
|
2022-07-20 21:52:57 +00:00
|
|
|
[ -n "$conflicts" ] && die "APKBUILD contains \$conflicts. Explicit conflicts should be added as '!pkgname' to depends"
|
2009-02-08 21:02:22 +00:00
|
|
|
|
2015-09-16 20:58:27 +00:00
|
|
|
check_maintainer || die "Provide a valid RFC822 maintainer address"
|
2020-07-08 11:05:04 +00:00
|
|
|
[ $(grep '^# *Maintainer:' "$APKBUILD" | wc -l) -gt 1 ] \
|
|
|
|
&& die "More than one maintainer"
|
2018-01-02 10:26:51 +00:00
|
|
|
check_license || warning "Please use valid SPDX license identifiers found at: https://spdx.org/licenses"
|
2009-06-03 20:55:45 +00:00
|
|
|
|
2015-09-28 11:08:16 +00:00
|
|
|
check_depends_dev || warning "depends_dev found but no development subpackage found"
|
2017-07-20 07:56:11 +00:00
|
|
|
check_secfixes_comment || return 1
|
2015-09-28 11:08:16 +00:00
|
|
|
|
2017-02-17 07:20:58 +00:00
|
|
|
makedepends_has 'g++' && ! options_has toolchain && warning "g++ should not be in makedepends"
|
2023-12-18 13:50:27 +00:00
|
|
|
if makedepends_has 'go' && ! options_has 'net'; then
|
|
|
|
warning "Go packages require network connection to build. Maybe add 'net' to options"
|
|
|
|
fi
|
2017-10-24 12:48:52 +00:00
|
|
|
|
|
|
|
if ! options_has "!check" && [ -n "$REQUIRE_CHECK" ]; then
|
|
|
|
(unset check; . "$APKBUILD"; type check >/dev/null 2>&1) || \
|
2018-03-18 10:03:14 +00:00
|
|
|
die "Testsuites (abuild check) are required or need to be explicitly disabled!"
|
2017-10-24 12:48:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-02 13:22:42 +00:00
|
|
|
check_provides || die "provides must not contain $pkgname"
|
|
|
|
|
2008-11-06 14:23:04 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-12-14 09:54:43 +00:00
|
|
|
sanitycheck() {
|
|
|
|
default_sanitycheck
|
|
|
|
}
|
|
|
|
|
2012-11-29 10:09:47 +00:00
|
|
|
sumcheck() {
|
|
|
|
local algo="$1" sums="$2"
|
2010-11-06 12:25:06 +00:00
|
|
|
local dummy f endreturnval originalparams origin file
|
2012-11-29 10:09:47 +00:00
|
|
|
|
|
|
|
# get number of checksums
|
|
|
|
set -- $sums
|
|
|
|
local numsums=$(( $# / 2 ))
|
|
|
|
|
|
|
|
set -- $source
|
|
|
|
if [ $# -ne $numsums ]; then
|
|
|
|
die "Number of ${algo}sums($numsums) does not correspond to number of sources($#)"
|
2008-11-06 14:23:04 +00:00
|
|
|
fi
|
2009-01-17 09:58:50 +00:00
|
|
|
fetch || return 1
|
2012-11-29 10:09:47 +00:00
|
|
|
msg "Checking ${algo}sums..."
|
2011-03-29 13:06:03 +00:00
|
|
|
cd "$srcdir" || return 1
|
2010-11-06 12:25:06 +00:00
|
|
|
IFS=$'\n'
|
|
|
|
endreturnval=0
|
2012-11-29 10:09:47 +00:00
|
|
|
for src in $sums; do
|
2010-11-06 12:25:06 +00:00
|
|
|
origin=$1; shift
|
2017-02-21 15:44:15 +00:00
|
|
|
if ! echo "$src" | ${algo}sum -c; then
|
2011-04-01 12:24:40 +00:00
|
|
|
endreturnval=1
|
2010-11-06 12:25:06 +00:00
|
|
|
is_remote $origin || continue
|
2016-07-08 10:44:31 +00:00
|
|
|
|
|
|
|
local csum="${src:0:8}"
|
|
|
|
local file="$SRCDEST/$(filename_from_uri $origin)"
|
|
|
|
|
|
|
|
echo "Because the remote file above failed the ${algo}sum check it will be renamed."
|
2010-11-06 12:25:06 +00:00
|
|
|
echo "Rebuilding will cause it to re-download which in some cases may fix the problem."
|
2016-07-08 10:44:31 +00:00
|
|
|
echo "Renaming: ${file##*/} to ${file##*/}.$csum"
|
|
|
|
mv "$file" "$file.$csum"
|
2010-11-06 12:25:06 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
unset IFS
|
|
|
|
return $endreturnval
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-29 10:09:47 +00:00
|
|
|
# for compatibility
|
|
|
|
md5check() {
|
|
|
|
warning "'md5check' is deprecated. Use 'verify' instead"
|
|
|
|
sumcheck md5 "$md5sums"
|
|
|
|
}
|
|
|
|
|
|
|
|
# verify checksums
|
|
|
|
verify() {
|
|
|
|
local verified=false algo=
|
2013-07-19 10:39:24 +00:00
|
|
|
for algo in sha512 sha256 sha1 md5; do
|
2012-11-29 10:09:47 +00:00
|
|
|
local sums=
|
|
|
|
eval sums=\"\$${algo}sums\"
|
|
|
|
if [ -z "$sums" ] || [ -z "$source" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
sumcheck "$algo" "$sums" || return 1
|
|
|
|
verified=true
|
2013-07-19 10:39:24 +00:00
|
|
|
break
|
2012-11-29 10:09:47 +00:00
|
|
|
done
|
|
|
|
if [ -n "$source" ] && ! $verified; then
|
|
|
|
die "Use 'abuild checksum' to generate/update the checksum(s)"
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-01-03 15:38:40 +00:00
|
|
|
# verify upstream sources
|
|
|
|
sourcecheck() {
|
2011-01-03 15:59:52 +00:00
|
|
|
local uri
|
|
|
|
for uri in $source; do
|
|
|
|
is_remote $uri || continue
|
|
|
|
case "$uri" in
|
2013-02-20 13:38:22 +00:00
|
|
|
*::*)
|
|
|
|
uri=${uri##*::}
|
|
|
|
;;
|
2011-01-03 15:59:52 +00:00
|
|
|
esac
|
2017-07-15 14:48:30 +00:00
|
|
|
wget --spider -q "$uri" || return 1
|
2011-01-03 15:38:40 +00:00
|
|
|
done
|
2011-01-03 15:59:52 +00:00
|
|
|
return 0
|
2011-01-03 15:38:40 +00:00
|
|
|
}
|
2011-01-03 15:59:52 +00:00
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
uri_fetch() {
|
|
|
|
local uri="$1"
|
|
|
|
mkdir -p "$SRCDEST"
|
2017-07-20 07:58:02 +00:00
|
|
|
msg "Fetching $uri"
|
2018-10-03 09:23:16 +00:00
|
|
|
abuild-fetch -d "$SRCDEST" "$uri"
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 11:00:29 +00:00
|
|
|
is_remote() {
|
2013-02-20 13:38:22 +00:00
|
|
|
case "${1#*::}" in
|
2017-07-15 14:48:30 +00:00
|
|
|
http://*|ftp://*|https://*)
|
2008-11-25 11:00:29 +00:00
|
|
|
return 0;;
|
|
|
|
esac
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:38:22 +00:00
|
|
|
filename_from_uri() {
|
|
|
|
local uri="$1"
|
|
|
|
local filename="${uri##*/}" # $(basename $uri)
|
|
|
|
case "$uri" in
|
|
|
|
*::*) filename=${uri%%::*};;
|
|
|
|
esac
|
|
|
|
echo "$filename"
|
|
|
|
}
|
|
|
|
|
2010-04-15 15:52:38 +00:00
|
|
|
# try download from file from mirror first
|
|
|
|
uri_fetch_mirror() {
|
|
|
|
local uri="$1"
|
|
|
|
if [ -n "$DISTFILES_MIRROR" ]; then
|
2010-05-18 09:52:44 +00:00
|
|
|
if is_remote "$DISTFILES_MIRROR"; then
|
2013-02-20 13:38:22 +00:00
|
|
|
uri_fetch "$DISTFILES_MIRROR"/$(filename_from_uri $uri)\
|
|
|
|
&& return 0
|
2010-05-18 09:52:44 +00:00
|
|
|
else
|
2013-02-20 13:38:22 +00:00
|
|
|
cp "$DISTFILES_MIRROR"/$(filename_from_uri $uri) \
|
|
|
|
"$SRCDEST" && return 0
|
2010-05-18 09:52:44 +00:00
|
|
|
fi
|
2010-04-15 15:52:38 +00:00
|
|
|
fi
|
|
|
|
uri_fetch "$uri"
|
|
|
|
}
|
|
|
|
|
2017-01-31 08:23:56 +00:00
|
|
|
symlinksrc() {
|
|
|
|
local s
|
|
|
|
mkdir -p "$srcdir"
|
|
|
|
for s in $source; do
|
|
|
|
if is_remote "$s"; then
|
|
|
|
ln -sf "$SRCDEST/$(filename_from_uri $s)" "$srcdir"/
|
|
|
|
else
|
|
|
|
ln -sf "$startdir/$s" "$srcdir/"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-11-24 10:53:58 +00:00
|
|
|
default_fetch() {
|
2008-10-18 08:09:24 +00:00
|
|
|
local s
|
|
|
|
mkdir -p "$srcdir"
|
2008-11-25 11:00:29 +00:00
|
|
|
for s in $source; do
|
|
|
|
if is_remote "$s"; then
|
2010-04-19 13:48:57 +00:00
|
|
|
uri_fetch_mirror "$s" || return 1
|
2013-02-20 13:38:22 +00:00
|
|
|
ln -sf "$SRCDEST/$(filename_from_uri $s)" "$srcdir"/
|
2013-07-02 07:18:11 +00:00
|
|
|
else
|
2008-11-25 11:00:29 +00:00
|
|
|
ln -sf "$startdir/$s" "$srcdir/"
|
|
|
|
fi
|
2008-10-18 08:09:24 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-11-24 10:53:58 +00:00
|
|
|
fetch() {
|
|
|
|
default_fetch
|
|
|
|
}
|
|
|
|
|
2011-01-04 09:05:54 +00:00
|
|
|
# verify that all init.d scripts are openrc runscripts
|
|
|
|
initdcheck() {
|
2015-04-28 13:20:29 +00:00
|
|
|
local i line
|
2011-01-04 09:05:54 +00:00
|
|
|
for i in $source; do
|
|
|
|
case $i in
|
2022-01-17 14:44:10 +00:00
|
|
|
*.initd)
|
2021-10-11 14:46:43 +00:00
|
|
|
line=$(head -n 1 "$srcdir"/"$(filename_from_uri $i)")
|
|
|
|
;;
|
2015-04-28 13:20:29 +00:00
|
|
|
*) continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$line" in
|
|
|
|
*sbin/openrc-run)
|
|
|
|
;;
|
|
|
|
*sbin/runscript)
|
|
|
|
warning "$i is not an openrc #!/sbin/openrc-run"
|
|
|
|
;;
|
|
|
|
*) error "$i is not an openrc #!/sbin/openrc-run"
|
2011-01-04 09:05:54 +00:00
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
2013-07-02 07:18:11 +00:00
|
|
|
done
|
2011-01-04 09:05:54 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
# unpack the sources
|
2009-11-24 10:53:58 +00:00
|
|
|
default_unpack() {
|
2008-10-18 08:09:24 +00:00
|
|
|
local u
|
2018-01-30 21:29:54 +00:00
|
|
|
verify || return 1
|
|
|
|
initdcheck || return 1
|
2008-10-18 08:09:24 +00:00
|
|
|
mkdir -p "$srcdir"
|
2018-04-11 21:39:49 +00:00
|
|
|
local gunzip=$(command -v pigz || echo gunzip)
|
|
|
|
[ $gunzip = "/usr/bin/pigz" ] && gunzip="$gunzip -d"
|
2008-10-18 08:09:24 +00:00
|
|
|
for u in $source; do
|
2017-01-29 01:32:27 +00:00
|
|
|
local s
|
|
|
|
if is_remote "$u"; then
|
|
|
|
s="$SRCDEST/$(filename_from_uri $u)"
|
|
|
|
else
|
|
|
|
s="$startdir/$u"
|
|
|
|
fi
|
2008-10-18 08:09:24 +00:00
|
|
|
case "$s" in
|
2012-05-23 09:42:27 +00:00
|
|
|
*.tar)
|
|
|
|
msg "Unpacking $s..."
|
|
|
|
tar -C "$srcdir" -xf "$s" || return 1;;
|
2008-11-06 13:47:00 +00:00
|
|
|
*.tar.gz|*.tgz)
|
2008-11-08 10:26:09 +00:00
|
|
|
msg "Unpacking $s..."
|
2018-04-11 21:39:49 +00:00
|
|
|
$gunzip -c "$s" | tar -C "$srcdir" -x || return 1;;
|
2008-10-18 08:09:24 +00:00
|
|
|
*.tar.bz2)
|
2008-11-08 10:26:09 +00:00
|
|
|
msg "Unpacking $s..."
|
2008-10-18 08:09:24 +00:00
|
|
|
tar -C "$srcdir" -jxf "$s" || return 1;;
|
2017-04-05 13:28:07 +00:00
|
|
|
*.tar.lz)
|
|
|
|
msg "Unpacking $s..."
|
|
|
|
tar -C "$srcdir" --lzip -xf "$s" || return 1;;
|
2008-11-11 14:12:18 +00:00
|
|
|
*.tar.lzma)
|
|
|
|
msg "Unpacking $s..."
|
2018-04-11 21:39:49 +00:00
|
|
|
unlzma -T 0 -c "$s" | tar -C "$srcdir" -x \
|
2008-11-11 14:12:18 +00:00
|
|
|
|| return 1;;
|
2010-08-12 07:08:29 +00:00
|
|
|
*.tar.xz)
|
|
|
|
msg "Unpacking $s..."
|
2018-04-17 21:02:28 +00:00
|
|
|
local threads_opt
|
|
|
|
if [ $(readlink -f $(command -v unxz)) != "/bin/busybox" ]; then
|
|
|
|
threads_opt="--threads=0"
|
|
|
|
fi
|
|
|
|
unxz $threads_opt -c "$s" | tar -C "$srcdir" -x || return 1;;
|
2022-07-28 00:19:09 +00:00
|
|
|
*.tar.zst)
|
|
|
|
msg "Unpacking $s..."
|
|
|
|
tar -C "$srcdir" --zstd -xf "$s" || return 1;;
|
2009-01-26 11:00:45 +00:00
|
|
|
*.zip)
|
|
|
|
msg "Unpacking $s..."
|
2016-08-18 21:44:13 +00:00
|
|
|
unzip -n -q "$s" -d "$srcdir" || return 1;;
|
2008-10-18 08:09:24 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-11-24 10:53:58 +00:00
|
|
|
unpack() {
|
|
|
|
default_unpack
|
|
|
|
}
|
|
|
|
|
2023-06-22 03:33:59 +00:00
|
|
|
# cleanup source, package and temporary dir
|
2008-10-18 08:09:24 +00:00
|
|
|
clean() {
|
2018-12-08 18:22:43 +00:00
|
|
|
cleanup srcdir
|
|
|
|
cleanup pkgdir
|
2023-06-22 03:33:59 +00:00
|
|
|
cleanup tmpdir
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# cleanup fetched sources
|
|
|
|
cleancache() {
|
|
|
|
local s
|
|
|
|
for s in $source; do
|
2008-11-25 11:00:29 +00:00
|
|
|
if is_remote "$s"; then
|
2013-02-20 13:38:22 +00:00
|
|
|
s=$(filename_from_uri $s)
|
|
|
|
msg "Cleaning downloaded $s ..."
|
|
|
|
rm -f "$SRCDEST/$s"
|
2008-11-25 11:00:29 +00:00
|
|
|
fi
|
2008-10-18 08:09:24 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-07-23 06:18:27 +00:00
|
|
|
subpkg_unset() {
|
|
|
|
unset subpkgname subpkgsplit subpkgarch
|
|
|
|
}
|
|
|
|
|
|
|
|
subpkg_set() {
|
|
|
|
subpkgname=${1%%:*}
|
|
|
|
|
|
|
|
local _splitarch=${1#*:}
|
|
|
|
[ "$_splitarch" = "$1" ] && _splitarch=""
|
|
|
|
|
|
|
|
subpkgsplit=${_splitarch%%:*}
|
2019-05-02 19:14:46 +00:00
|
|
|
|
|
|
|
if [ -z "$subpkgsplit" ]; then
|
2024-04-08 12:59:32 +00:00
|
|
|
case $subpkgname in
|
|
|
|
*-bash-completion) subpkgsplit=bashcomp ;;
|
|
|
|
*-zsh-completion) subpkgsplit=zshcomp ;;
|
|
|
|
*-fish-completion) subpkgsplit=fishcomp ;;
|
|
|
|
*) subpkgsplit="${subpkgname##*-}" ;;
|
|
|
|
esac
|
2019-05-02 19:14:46 +00:00
|
|
|
fi
|
2016-07-23 06:18:27 +00:00
|
|
|
|
|
|
|
subpkgarch=${_splitarch#*:}
|
|
|
|
if [ "$subpkgarch" = "$_splitarch" -o -z "$subpkgarch" ]; then
|
|
|
|
case "$subpkgname" in
|
2023-04-18 16:36:23 +00:00
|
|
|
*-doc | *-openrc | *-lang | *-lang-* | *sh-completion | *-pyc) subpkgarch="noarch" ;;
|
2016-07-23 06:18:27 +00:00
|
|
|
*) subpkgarch="$pkgarch" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-01-11 21:04:32 +00:00
|
|
|
arch2dir() {
|
|
|
|
local arch="$1"
|
|
|
|
[ "$arch" = "noarch" -o "$arch" = "all" ] && arch="$CARCH"
|
|
|
|
printf '%s\n' "$arch"
|
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
cleanpkg() {
|
|
|
|
local i
|
2008-11-08 10:26:09 +00:00
|
|
|
msg "Cleaning built packages..."
|
2016-07-26 11:32:43 +00:00
|
|
|
rm -f "$REPODEST/$repo/src/$pkgname-$pkgver-r$pkgrel.src.tar.gz"
|
|
|
|
for i in $allpackages; do
|
|
|
|
subpkg_set "$i"
|
2024-01-11 21:04:32 +00:00
|
|
|
rm -f "$REPODEST/$repo/$(arch2dir "$subpkgarch")/$subpkgname-$pkgver-r$pkgrel.apk"
|
2008-10-18 08:09:24 +00:00
|
|
|
done
|
2016-07-26 11:32:43 +00:00
|
|
|
subpkg_unset
|
|
|
|
|
2009-05-14 14:41:12 +00:00
|
|
|
# remove given packages from index
|
2013-02-07 15:29:53 +00:00
|
|
|
update_abuildrepo_index
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 09:04:15 +00:00
|
|
|
# clean all packages except current
|
|
|
|
cleanoldpkg() {
|
|
|
|
local i j
|
|
|
|
msg "Cleaning all packages except $pkgver-r$pkgrel..."
|
2016-07-26 11:32:43 +00:00
|
|
|
for i in $allpackages; do
|
|
|
|
subpkg_set "$i"
|
2022-12-06 15:59:03 +00:00
|
|
|
for j in "$REPODEST"/$repo/$CARCH/$subpkgname-[0-9]*.apk ; do
|
2016-07-26 11:32:43 +00:00
|
|
|
[ "${j##*/}" = "$subpkgname-$pkgver-r$pkgrel.apk" ] \
|
2011-03-30 09:06:48 +00:00
|
|
|
&& continue
|
2016-07-26 08:05:17 +00:00
|
|
|
rm -f "$j"
|
2009-01-03 09:04:15 +00:00
|
|
|
done
|
|
|
|
done
|
2016-07-26 11:32:43 +00:00
|
|
|
subpkg_unset
|
2014-09-25 07:42:01 +00:00
|
|
|
update_abuildrepo_index
|
2009-01-03 09:04:15 +00:00
|
|
|
return 0
|
|
|
|
}
|
2009-08-21 07:54:53 +00:00
|
|
|
|
|
|
|
mkusers() {
|
|
|
|
local i
|
2012-04-24 09:01:59 +00:00
|
|
|
for i in $pkggroups; do
|
|
|
|
if ! getent group $i >/dev/null; then
|
|
|
|
msg "Creating group $i"
|
|
|
|
$ADDGROUP -S $i || return 1
|
|
|
|
fi
|
|
|
|
done
|
2009-08-21 07:54:53 +00:00
|
|
|
for i in $pkgusers; do
|
|
|
|
if ! getent passwd $i >/dev/null; then
|
2011-04-17 12:55:02 +00:00
|
|
|
local gopt=
|
2009-08-21 07:54:53 +00:00
|
|
|
msg "Creating user $i"
|
2011-04-17 12:55:02 +00:00
|
|
|
if getent group $i >/dev/null; then
|
|
|
|
gopt="-G $i"
|
|
|
|
fi
|
2012-02-17 13:48:11 +00:00
|
|
|
$ADDUSER -S -D -H $gopt $i || return 1
|
2009-08-21 07:54:53 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-07-26 11:40:42 +00:00
|
|
|
# helper to update config.sub to a recent version
|
|
|
|
update_config_sub() {
|
2017-04-04 13:12:48 +00:00
|
|
|
find . -name config.sub | (local changed=false; while read f; do
|
2024-03-02 07:15:17 +00:00
|
|
|
if ! ./$f loongarch64-alpine-linux-musl 2>/dev/null; then
|
2013-07-29 14:10:38 +00:00
|
|
|
msg "Updating $f"
|
2019-11-07 11:21:32 +00:00
|
|
|
cp "$sharedir"/${f##*/} "$f" || return 1
|
2013-07-29 07:31:39 +00:00
|
|
|
changed=true
|
|
|
|
else
|
2013-09-26 07:22:13 +00:00
|
|
|
msg "No update needed for $f"
|
2013-07-29 07:31:39 +00:00
|
|
|
fi
|
2017-04-04 13:12:48 +00:00
|
|
|
done; $changed)
|
2013-07-26 11:40:42 +00:00
|
|
|
}
|
2009-08-21 07:54:53 +00:00
|
|
|
|
2016-08-12 11:07:30 +00:00
|
|
|
# helper to update config.guess to a recent version
|
|
|
|
update_config_guess() {
|
2017-04-04 13:12:48 +00:00
|
|
|
find . -name config.guess | (local changed=false; while read f; do
|
2024-03-02 07:15:17 +00:00
|
|
|
if grep -q aarch64 "$f" && grep -q ppc64le "$f" && grep -q riscv64 "$f" && grep -q loongarch64 "$f"; then
|
2016-08-12 11:07:30 +00:00
|
|
|
msg "No update needed for $f"
|
|
|
|
else
|
|
|
|
msg "Updating $f"
|
2019-11-07 11:21:32 +00:00
|
|
|
cp "$sharedir"/${f##*/} "$f" || return 1
|
2016-08-12 11:07:30 +00:00
|
|
|
changed=true
|
|
|
|
fi
|
2017-04-04 13:12:48 +00:00
|
|
|
done; $changed)
|
2016-08-12 11:07:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
runpart() {
|
|
|
|
local part=$1
|
2008-11-08 10:26:09 +00:00
|
|
|
[ -n "$DEBUG" ] && msg "$part"
|
2017-03-21 08:05:44 +00:00
|
|
|
trap "die '$part failed'" EXIT
|
2018-10-03 11:48:11 +00:00
|
|
|
if [ -d "$builddir" ]; then
|
|
|
|
case "$part" in
|
|
|
|
prepare|build|package|check)
|
2022-03-19 09:15:06 +00:00
|
|
|
# exclude aports from git repo discovery
|
|
|
|
export GIT_CEILING_DIRECTORIES="$startdir"
|
2023-06-22 03:33:59 +00:00
|
|
|
|
|
|
|
# prevent using global cache directories
|
|
|
|
if [ -n "$MOVE_CACHES" ]; then
|
|
|
|
export GOCACHE="${GOCACHE:-"$tmpdir/go"}"
|
|
|
|
export GOMODCACHE="${GOCACHE:-"$tmpdir/gomod"}"
|
|
|
|
export GOTMPDIR="${GOTMPDIR:-"$tmpdir"}"
|
|
|
|
export CARGO_HOME="${CARGO_HOME:-"$tmpdir/cargo"}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$builddir"
|
|
|
|
;;
|
2018-10-03 11:48:11 +00:00
|
|
|
esac
|
|
|
|
fi
|
2017-03-21 08:05:44 +00:00
|
|
|
$part
|
|
|
|
trap - EXIT
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2016-04-05 20:35:34 +00:00
|
|
|
have_patches() {
|
|
|
|
local i
|
|
|
|
for i in $source; do
|
2017-01-12 14:36:41 +00:00
|
|
|
case ${i%::*} in
|
2020-02-10 11:58:02 +00:00
|
|
|
*.patch|*.patch.gz|*.patch.xz) return 0;;
|
2016-04-05 20:35:34 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-02-01 22:32:27 +00:00
|
|
|
default_prepare() {
|
2020-07-06 10:13:36 +00:00
|
|
|
local i failed=
|
2017-02-17 11:53:50 +00:00
|
|
|
[ -n "$builddir" -a -d "$builddir" ] && cd "$builddir"
|
2016-04-05 20:35:34 +00:00
|
|
|
if ! have_patches; then
|
|
|
|
return 0
|
|
|
|
fi
|
2017-02-17 11:53:50 +00:00
|
|
|
[ -d "$builddir" ] || { error "Is \$builddir set correctly?"; return 1; }
|
2016-02-01 22:32:27 +00:00
|
|
|
for i in $source; do
|
2017-01-12 14:36:41 +00:00
|
|
|
case ${i%::*} in
|
2016-02-01 22:32:27 +00:00
|
|
|
*.patch)
|
2017-01-12 14:36:41 +00:00
|
|
|
msg "${i%::*}"
|
2020-07-06 10:13:36 +00:00
|
|
|
patch ${patch_args:--p1} -i "$srcdir/$(filename_from_uri $i)" || failed="$failed $i"
|
2016-02-01 22:32:27 +00:00
|
|
|
;;
|
2020-02-10 11:58:02 +00:00
|
|
|
*.patch.gz)
|
|
|
|
msg "${i%::*}"
|
2020-07-06 10:13:36 +00:00
|
|
|
gunzip -c "$srcdir/$(filename_from_uri $i)" | patch ${patch_args:--p1} || failed="$failed $i"
|
2020-02-10 11:58:02 +00:00
|
|
|
;;
|
|
|
|
*.patch.xz)
|
|
|
|
msg "${i%::*}"
|
2020-07-06 10:13:36 +00:00
|
|
|
unxz -c "$srcdir/$(filename_from_uri $i)" | patch ${patch_args:--p1} || failed="$failed $i"
|
2020-02-10 11:58:02 +00:00
|
|
|
;;
|
2016-02-01 22:32:27 +00:00
|
|
|
esac
|
|
|
|
done
|
2020-07-06 10:13:36 +00:00
|
|
|
if [ -z "$failed" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
error "The following patches failed to apply:"
|
|
|
|
for i in $failed; do
|
2022-07-14 02:56:29 +00:00
|
|
|
printf " %s\n" "$i" >&2
|
2020-07-06 10:13:36 +00:00
|
|
|
done
|
|
|
|
return 1
|
2016-02-01 22:32:27 +00:00
|
|
|
}
|
|
|
|
|
2009-10-23 16:28:34 +00:00
|
|
|
prepare() {
|
2016-02-01 22:32:27 +00:00
|
|
|
default_prepare
|
2009-10-23 16:28:34 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
build() {
|
2009-10-23 13:12:32 +00:00
|
|
|
:
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2010-04-28 16:04:37 +00:00
|
|
|
# generate a simple tar.gz package of pkgdir
|
|
|
|
targz() {
|
|
|
|
cd "$pkgdir" || return 1
|
2016-07-26 08:05:17 +00:00
|
|
|
mkdir -p "$REPODEST"/src
|
|
|
|
tar -czf "$REPODEST"/src/$pkgname-$pkgver-r$pkgrel.tar.gz *
|
2010-04-28 16:04:37 +00:00
|
|
|
}
|
|
|
|
|
2012-02-13 10:05:11 +00:00
|
|
|
postcheck() {
|
2024-03-26 20:55:53 +00:00
|
|
|
local dir="$1" name="$2" i= j= e=0
|
2012-02-13 10:05:11 +00:00
|
|
|
msg "Running postcheck for $name"
|
2012-02-29 15:53:42 +00:00
|
|
|
# checking for FHS compat
|
2012-02-29 15:59:05 +00:00
|
|
|
if ! options_has "!fhs"; then
|
2024-04-21 08:35:19 +00:00
|
|
|
for i in srv usr/local opt tmp var/tmp var/lock var/empty home sys proc mnt dev; do
|
2024-03-26 20:55:53 +00:00
|
|
|
for j in "$dir"/"$i"/* "$dir"/"$i"/.[!.]* "$dir"/"$i"/..?*; do
|
|
|
|
if [ -L "$j" ] || [ -e "$j" ]; then
|
|
|
|
error "Packages must not put anything under /$i"
|
|
|
|
e=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2012-02-29 15:59:05 +00:00
|
|
|
done
|
2013-09-03 14:08:16 +00:00
|
|
|
if [ -d "$dir"/usr/var ]; then
|
|
|
|
error "Found /usr/var, localstatedir is most likely wrong"
|
2020-07-02 00:58:25 +00:00
|
|
|
e=1
|
2013-09-03 14:08:16 +00:00
|
|
|
fi
|
2012-02-29 15:59:05 +00:00
|
|
|
fi
|
2014-12-05 18:37:06 +00:00
|
|
|
|
2020-06-16 17:30:39 +00:00
|
|
|
# Alpine Linux as a musl libc distro does not use /lib64 or /usr/lib64 under
|
2021-07-24 11:53:11 +00:00
|
|
|
# any circumstance, packages installing to it are 100% sure a packaging error
|
2020-07-20 17:03:52 +00:00
|
|
|
# except when we are doing GNU Libc compatibility which should be rare enough
|
|
|
|
# to warrant a lib64 check
|
|
|
|
if ! options_has "lib64"; then
|
|
|
|
if [ -e "$dir"/lib64 ]; then
|
|
|
|
error "Packages must not put anything under /lib64, use /lib instead"
|
|
|
|
e=1
|
|
|
|
elif [ -e "$dir"/usr/lib64 ]; then
|
|
|
|
error "Packages must not put anything under /usr/lib64, use /usr/lib instead"
|
|
|
|
e=1
|
|
|
|
fi
|
2020-06-16 17:30:39 +00:00
|
|
|
fi
|
|
|
|
|
2014-12-05 18:37:06 +00:00
|
|
|
# remove *.la files if libtool is not set
|
|
|
|
if ! options_has "libtool"; then
|
|
|
|
find "$dir" -name '*.la' -type f -delete
|
2012-02-13 10:05:11 +00:00
|
|
|
fi
|
2014-12-05 18:37:06 +00:00
|
|
|
|
2013-07-26 07:22:45 +00:00
|
|
|
# look for /usr/lib/charset.alias
|
|
|
|
if [ -e "$dir"/usr/lib/charset.alias ] \
|
|
|
|
&& ! options_has "charset.alias"; then
|
|
|
|
error "Found /usr/lib/charset.alias"
|
2020-07-02 00:58:25 +00:00
|
|
|
e=1
|
2013-07-26 07:22:45 +00:00
|
|
|
fi
|
2018-03-11 15:17:30 +00:00
|
|
|
# look for /etc/init.d and /etc/conf.d
|
|
|
|
if [ -e "$dir"/etc/init.d -o -e "$dir"/etc/conf.d ] \
|
|
|
|
&& ! is_openrc_pkg "$name"; then
|
|
|
|
warning "Found OpenRC directory (/etc/conf.d or /etc/init.d) but name doesn't end with -openrc"
|
|
|
|
fi
|
2015-08-14 15:07:28 +00:00
|
|
|
# look for /usr/share/doc
|
|
|
|
if [ -e "$dir"/usr/share/doc ] \
|
2015-08-18 11:46:15 +00:00
|
|
|
&& ! is_doc_pkg "$name"; then
|
2015-08-14 15:07:28 +00:00
|
|
|
warning "Found /usr/share/doc but package name doesn't end with -doc"
|
|
|
|
fi
|
2022-08-29 11:47:38 +00:00
|
|
|
# look for /usr/share/devhelp
|
|
|
|
if [ -e "$dir"/usr/share/devhelp ] \
|
|
|
|
&& ! is_devhelp_pkg "$name"; then
|
|
|
|
warning "Found /usr/share/devhelp but package name doesn't end with -devhelp"
|
|
|
|
fi
|
2015-08-14 15:07:28 +00:00
|
|
|
# look for /usr/share/man
|
2015-08-17 11:10:14 +00:00
|
|
|
if [ -e "$dir"/usr/share/man ]; then
|
2015-08-18 11:46:15 +00:00
|
|
|
if ! is_doc_pkg "$name"; then
|
2015-08-17 11:10:14 +00:00
|
|
|
warning "Found /usr/share/man but package name doesn't end with -doc"
|
|
|
|
fi
|
2015-08-14 15:07:28 +00:00
|
|
|
# check for uncompressed man pages
|
2024-01-14 13:50:15 +00:00
|
|
|
i=$(find "$dir"/usr/share/man -name '*.[0-8]' -type f | sed -e 's/^/\t/')
|
2015-08-14 15:07:28 +00:00
|
|
|
if [ -n "$i" ]; then
|
|
|
|
error "Found uncompressed man pages:"
|
|
|
|
echo "$i"
|
2020-07-02 00:58:25 +00:00
|
|
|
e=1
|
2015-08-14 15:07:28 +00:00
|
|
|
fi
|
|
|
|
fi
|
2023-04-18 09:56:37 +00:00
|
|
|
# look for pycache
|
|
|
|
# wildcard should always get the system python dir, and this is faster than
|
|
|
|
# trying to calculate the python version.
|
2023-04-19 13:27:51 +00:00
|
|
|
local pycache="$(find "$dir"/usr/lib/python* \( -type d -a -name "__pycache__" \) 2>/dev/null )"
|
2023-04-18 09:56:37 +00:00
|
|
|
if [ -n "$pycache" ] && [ "${name%-pyc}" = "$name" ]; then
|
|
|
|
warning "Found __pycache__ but package name doesn't end with -pyc"
|
|
|
|
fi
|
|
|
|
|
2021-02-04 13:34:47 +00:00
|
|
|
# check that we don't have any files names with newline
|
|
|
|
i=$(find "$dir" -name $'*\n*')
|
|
|
|
if [ -n "$i" ]; then
|
|
|
|
error "Found filenames with newline:"
|
2022-06-15 12:47:29 +00:00
|
|
|
echo "$i" >&2
|
2021-02-04 13:34:47 +00:00
|
|
|
e=1
|
|
|
|
fi
|
2012-02-13 10:05:11 +00:00
|
|
|
# check directory permissions
|
2024-01-14 13:50:15 +00:00
|
|
|
i=$(find "$dir" -type d -perm -777 | sed -e 's/^/\t/')
|
2012-02-13 10:05:11 +00:00
|
|
|
if [ -n "$i" ]; then
|
|
|
|
warning "World writeable directories found:"
|
|
|
|
echo "$i"
|
|
|
|
fi
|
2014-09-25 07:34:57 +00:00
|
|
|
# check so we dont have any suid root binaries that are not PIE
|
2016-02-22 12:07:16 +00:00
|
|
|
i=$(find "$dir" -type f -perm /6000 \
|
2012-02-14 12:51:33 +00:00
|
|
|
| xargs scanelf --nobanner --etype ET_EXEC \
|
2024-01-14 13:50:15 +00:00
|
|
|
| sed -e 's/ET_EXEC /\t/')
|
2012-02-14 12:51:33 +00:00
|
|
|
if [ -n "$i" ]; then
|
2022-08-28 12:23:27 +00:00
|
|
|
warning "Found non-PIE files that have SUID:"
|
2012-02-14 12:51:33 +00:00
|
|
|
echo "$i"
|
2022-08-28 12:23:27 +00:00
|
|
|
warning "suid executables SHOULD be compiled with PIE if possible"
|
2012-02-14 12:51:33 +00:00
|
|
|
fi
|
2014-09-25 07:34:57 +00:00
|
|
|
# test suid bit on executable
|
|
|
|
if ! options_has "suid"; then
|
|
|
|
i=$(find "$dir" \( -perm -u+s -o -perm -g+s \) -a -type f \
|
|
|
|
-a -perm -o+x)
|
|
|
|
if [ -n "$i" ]; then
|
|
|
|
error "Found executable files with SUID bit set:"
|
|
|
|
echo "$i"
|
2020-07-02 00:58:25 +00:00
|
|
|
e=1
|
2014-09-25 07:34:57 +00:00
|
|
|
fi
|
|
|
|
fi
|
2022-07-03 12:30:15 +00:00
|
|
|
# test capabilities on executables
|
|
|
|
# see: https://gitlab.alpinelinux.org/alpine/tsc/-/issues/45
|
|
|
|
getcap -r "$dir" | (local r=true; while read -r line; do
|
|
|
|
local filename="${line% *}"
|
|
|
|
if ! options_has "setcap"; then
|
|
|
|
error "Found binary with extra capabilities: $filename"
|
|
|
|
r=false
|
|
|
|
fi
|
|
|
|
|
|
|
|
local execothers="$(find "$filename" -perm -o+x)"
|
|
|
|
if [ -n "$execothers" ]; then
|
|
|
|
warning "Found setcap binary executable by others: $filename"
|
|
|
|
fi
|
|
|
|
done; $r) || e=1
|
2014-09-25 07:34:57 +00:00
|
|
|
|
2012-10-04 09:42:25 +00:00
|
|
|
# test for textrels
|
|
|
|
if ! options_has "textrels"; then
|
|
|
|
local res="$(scanelf --recursive --textrel --quiet "$dir")"
|
|
|
|
if [ -n "$res" ]; then
|
|
|
|
error "Found textrels:"
|
|
|
|
echo "$res"
|
2020-07-02 00:58:25 +00:00
|
|
|
e=1
|
2012-10-04 09:42:25 +00:00
|
|
|
fi
|
|
|
|
fi
|
2020-07-02 00:58:25 +00:00
|
|
|
return $e
|
2012-02-13 10:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-11 11:56:04 +00:00
|
|
|
pre_split() {
|
|
|
|
if [ -z "$subpkgname" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
2019-04-15 23:24:31 +00:00
|
|
|
# the subpackages should not inherit these from main package
|
2015-06-11 11:56:04 +00:00
|
|
|
provides=""
|
|
|
|
install_if=""
|
|
|
|
}
|
|
|
|
|
2009-05-08 15:01:14 +00:00
|
|
|
prepare_subpackages() {
|
2008-10-18 08:09:24 +00:00
|
|
|
local i
|
|
|
|
cd "$startdir"
|
2008-11-06 16:08:30 +00:00
|
|
|
for i in $subpackages; do
|
2008-11-07 07:43:31 +00:00
|
|
|
# call abuild recursively, setting subpkg{dir,name}
|
2016-07-23 06:18:27 +00:00
|
|
|
( subpkg_set "$i"; msg "Running split function $subpkgsplit..."; \
|
|
|
|
subpkgdir="$pkgbasedir/$subpkgname" subpkgname="$subpkgname" subpkgarch="$subpkgarch" \
|
2022-06-15 12:14:24 +00:00
|
|
|
"$abuild_path" $forceroot $verbose pre_split $subpkgsplit prepare_package \
|
2016-07-23 06:18:27 +00:00
|
|
|
&& postcheck "$pkgbasedir/$subpkgname" "$subpkgname" ) || return 1
|
2008-10-18 08:09:24 +00:00
|
|
|
done
|
2012-02-13 10:05:11 +00:00
|
|
|
postcheck "$pkgdir" "$pkgname" || return 1
|
2011-10-03 11:19:25 +00:00
|
|
|
# post check for /usr/share/locale
|
|
|
|
if [ -d "$pkgdir"/usr/share/locale ]; then
|
2011-12-14 09:52:54 +00:00
|
|
|
warning "Found /usr/share/locale"
|
2012-02-13 09:50:39 +00:00
|
|
|
warning2 "Maybe add \$pkgname-lang to subpackages?"
|
2011-10-03 11:19:25 +00:00
|
|
|
fi
|
2020-01-28 10:33:51 +00:00
|
|
|
# post check for shell completions
|
|
|
|
if [ -d "$pkgdir"/usr/share/bash-completion ]; then
|
|
|
|
warning "Found /usr/share/bash-completion"
|
|
|
|
warning2 "Add \$pkgname-bash-completion to subpackages"
|
|
|
|
fi
|
|
|
|
if [ -d "$pkgdir"/usr/share/zsh/site-functions ]; then
|
|
|
|
warning "Found /usr/share/zsh/site-functions"
|
|
|
|
warning2 "Add \$pkgname-zsh-completion to subpackages"
|
|
|
|
fi
|
|
|
|
if [ -d "$pkgdir"/usr/share/fish/completions ]; then
|
2023-06-22 04:04:50 +00:00
|
|
|
warning "Found /usr/share/fish/completions"
|
|
|
|
warning2 "fish completions for programs should be located in /usr/share/fish/vendor_completions.d"
|
|
|
|
fi
|
|
|
|
if [ -d "$pkgdir"/usr/share/fish/vendor_completions.d ]; then
|
2020-01-28 10:33:51 +00:00
|
|
|
warning "Found /usr/share/fish/completions"
|
|
|
|
warning2 "Add \$pkgname-fish-completion to subpackages"
|
|
|
|
fi
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-30 06:47:28 +00:00
|
|
|
default_lang() {
|
2011-10-03 18:36:58 +00:00
|
|
|
pkgdesc="Languages for package $pkgname"
|
2011-09-30 06:47:28 +00:00
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel lang"
|
2023-06-22 18:03:32 +00:00
|
|
|
depends="$depends_lang"
|
2016-07-23 06:18:27 +00:00
|
|
|
|
2011-09-30 06:47:28 +00:00
|
|
|
local dir
|
|
|
|
for dir in ${langdir:-/usr/share/locale}; do
|
|
|
|
mkdir -p "$subpkgdir"/${dir%/*}
|
|
|
|
mv "$pkgdir"/"$dir" "$subpkgdir"/"$dir" || return 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
lang() {
|
|
|
|
default_lang
|
|
|
|
}
|
|
|
|
|
2011-09-02 09:35:55 +00:00
|
|
|
default_lang_subpkg() {
|
2011-01-04 10:32:12 +00:00
|
|
|
if [ -z "$lang" ]; then
|
|
|
|
error "lang is not set"
|
|
|
|
return 1
|
|
|
|
fi
|
2011-09-02 09:35:55 +00:00
|
|
|
pkgdesc="$pkgname language pack for $lang"
|
2011-01-04 10:32:12 +00:00
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel lang-$lang"
|
2016-07-23 06:18:27 +00:00
|
|
|
|
2011-09-02 09:35:55 +00:00
|
|
|
local dir
|
|
|
|
for dir in ${langdir:-/usr/share/locale}; do
|
|
|
|
mkdir -p "$subpkgdir"/$dir
|
|
|
|
mv "$pkgdir"/$dir/$lang* \
|
|
|
|
"$subpkgdir"/$dir/ \
|
2011-01-04 10:32:12 +00:00
|
|
|
|| return 1
|
2011-09-02 09:35:55 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
lang_subpkg() {
|
|
|
|
default_lang_subpkg
|
2011-01-04 10:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
prepare_language_packs() {
|
2016-07-26 11:32:43 +00:00
|
|
|
local lang
|
2011-01-04 10:32:12 +00:00
|
|
|
for lang in $linguas; do
|
|
|
|
lang="$lang" \
|
|
|
|
subpkgname="$pkgname-lang-$lang" \
|
|
|
|
subpkgdir="$pkgbasedir"/$subpkgname \
|
2018-10-23 09:02:54 +00:00
|
|
|
"$abuild_path" $forceroot lang_subpkg prepare_package || return 1
|
2011-01-04 10:32:12 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2011-03-08 09:50:17 +00:00
|
|
|
# echo '-dirty' if git is not clean
|
|
|
|
git_dirty() {
|
2019-11-07 14:11:10 +00:00
|
|
|
[ $($git status -s -- "$startdir" | wc -l) -ne 0 ] && echo "-dirty"
|
2011-03-08 09:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# echo last commit hash id
|
|
|
|
git_last_commit() {
|
2021-10-07 11:06:06 +00:00
|
|
|
$git rev-list -n 1 HEAD -- "$startdir"
|
2011-03-08 09:50:17 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 12:06:24 +00:00
|
|
|
# date of last commit
|
|
|
|
git_last_commit_epoch() {
|
2019-11-07 14:11:10 +00:00
|
|
|
$git log -1 --format=%cd --date=unix $1 -- "$startdir"
|
2019-11-07 12:06:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-08 10:08:01 +00:00
|
|
|
get_maintainer() {
|
|
|
|
if [ -z "$maintainer" ]; then
|
2019-04-29 22:56:31 +00:00
|
|
|
maintainer=$(awk -F': ' '/# *Maintainer/ {print $2}' "$APKBUILD")
|
2015-09-16 20:58:27 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_maintainer() {
|
|
|
|
get_maintainer
|
|
|
|
if [ -z "$maintainer" ]; then
|
|
|
|
warning "No maintainer"
|
|
|
|
else
|
|
|
|
# try to check for a valid rfc822 address
|
|
|
|
case "$maintainer" in
|
2022-12-02 15:17:39 +00:00
|
|
|
" "*|*" ") error "'$maintainer' has leading or trailing space"; return 1 ;;
|
|
|
|
\"*|*\") error "'$maintainer' has leading or trailing quote"; return 1 ;;
|
|
|
|
*\ \<*@*.*\>) ;;
|
|
|
|
*) error "'$maintainer' is not a valid rfc822 address"; return 1 ;;
|
2015-09-16 20:58:27 +00:00
|
|
|
esac
|
2011-03-08 10:08:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-02 10:26:51 +00:00
|
|
|
check_license() {
|
|
|
|
local ret=0
|
|
|
|
local license_list=/usr/share/spdx/license.lst
|
|
|
|
if options_has "!spdx" || ! [ -f "$license_list" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
2024-02-12 11:36:20 +00:00
|
|
|
local IFS="$IFS()"
|
2018-01-02 10:26:51 +00:00
|
|
|
local i; for i in $license; do
|
2024-02-12 11:36:20 +00:00
|
|
|
list_has "$i" AND OR WITH && continue
|
2019-05-12 17:16:48 +00:00
|
|
|
if ! grep -q -x -F "$i" "$license_list"; then
|
2018-01-02 10:26:51 +00:00
|
|
|
ret=1
|
|
|
|
warning "\"$i\" is not a known license"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2017-07-20 07:56:11 +00:00
|
|
|
check_secfixes_comment() {
|
2023-04-14 06:03:17 +00:00
|
|
|
local c=$(sed -E -n -e '/^# secfixes:/,/(^[^#]|^$)/p' "$APKBUILD" | grep '^#')
|
2017-07-20 07:56:11 +00:00
|
|
|
local invalid=$(echo "$c" \
|
|
|
|
| grep -v -E '(^# secfixes:|^# +- [A-Z0-9-]+|^# [0-9]+.*:$|^#$)')
|
|
|
|
if [ -z "$invalid" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if there are tabs
|
|
|
|
if echo "$invalid" | grep -q $'\t'; then
|
|
|
|
error "secfixes comment must not have tabs:"
|
|
|
|
echo "$c" | grep $'\t' >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
error "secfixes comment is not valid:"
|
|
|
|
echo "$invalid" >&2
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2015-09-28 11:08:16 +00:00
|
|
|
check_depends_dev() {
|
2015-10-12 07:01:06 +00:00
|
|
|
if [ -z "$depends_dev" ]; then
|
|
|
|
return 0
|
2015-09-28 11:08:16 +00:00
|
|
|
fi
|
2015-10-12 07:01:06 +00:00
|
|
|
local i
|
|
|
|
for i in $pkgname $subpackages; do
|
2016-07-23 06:18:27 +00:00
|
|
|
case "${i%%:*}" in
|
|
|
|
*-dev) return 0 ;;
|
2015-10-12 07:01:06 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
return 1
|
2015-09-28 11:08:16 +00:00
|
|
|
}
|
|
|
|
|
2018-01-02 13:22:42 +00:00
|
|
|
check_provides() {
|
|
|
|
local i
|
|
|
|
for i in $provides; do
|
2024-04-01 14:58:22 +00:00
|
|
|
if [ "${i%%[<>=~]*}" = "$pkgname" ]; then
|
2018-01-02 13:22:42 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-01-17 15:14:58 +00:00
|
|
|
check_depver() {
|
|
|
|
case "$1" in
|
|
|
|
*=*)
|
|
|
|
if ! $APK version --check --quiet "${1#*=}"; then
|
|
|
|
error "Invalid version: ${i#*=}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2009-05-08 15:01:14 +00:00
|
|
|
prepare_metafiles() {
|
2008-11-06 16:08:30 +00:00
|
|
|
local name=${subpkgname:-$pkgname}
|
|
|
|
[ -z "${name##* *}" ] && die "package name contains spaces"
|
2008-10-24 09:40:30 +00:00
|
|
|
local dir=${subpkgdir:-$pkgdir}
|
2008-11-07 20:54:09 +00:00
|
|
|
local pkg="$name-$pkgver-r$pkgrel.apk"
|
2009-07-20 14:56:01 +00:00
|
|
|
local pkginfo="$controldir"/.PKGINFO
|
2008-11-08 10:26:09 +00:00
|
|
|
local sub
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2008-11-04 10:34:40 +00:00
|
|
|
[ ! -d "$dir" ] && die "Missing $dir"
|
|
|
|
cd "$dir"
|
2009-07-20 14:56:01 +00:00
|
|
|
mkdir -p "$controldir"
|
2019-06-08 19:42:21 +00:00
|
|
|
local builddate="$SOURCE_DATE_EPOCH"
|
2017-02-08 11:09:16 +00:00
|
|
|
|
|
|
|
# Fix package size on several filesystems
|
2020-02-08 10:48:52 +00:00
|
|
|
case "$(stat -f -c "%T" .)" in
|
2017-02-08 11:09:16 +00:00
|
|
|
btrfs|ecryptfs|zfs)
|
|
|
|
sync;;
|
|
|
|
esac
|
|
|
|
|
2008-11-04 10:34:40 +00:00
|
|
|
local size=$(du -sk | awk '{print $1 * 1024}')
|
2022-08-05 14:00:36 +00:00
|
|
|
# If package contains only empty files (or only install scripts), the size
|
|
|
|
# might be 0. But due to apk-tools 2 considering packages with size = 0
|
|
|
|
# virtual, nothing is extracted (and no scripts are ran). That will be
|
|
|
|
# solved in apk-tools 3. As a workaround we can set the size to 1 if any
|
|
|
|
# files are present or install scripts are defined.
|
|
|
|
if [ "$size" -eq 0 ]; then
|
|
|
|
if [ -n "$install" ] || [ -n "$(find . ! -name .)" ]; then
|
|
|
|
size=1
|
|
|
|
fi
|
2021-04-08 22:47:35 +00:00
|
|
|
fi
|
2008-11-04 10:34:40 +00:00
|
|
|
|
2016-07-23 06:18:27 +00:00
|
|
|
if [ "$arch" != "$apkbuild_arch" ]; then
|
|
|
|
local msg="Split function set arch=\"$arch\" for $name, use subpackages=pkg:split:arch format instead"
|
|
|
|
[ "$arch" != "noarch" ] && die "$msg"
|
|
|
|
warning "$msg"
|
|
|
|
subpkgarch="$arch"
|
2015-08-10 07:52:45 +00:00
|
|
|
fi
|
|
|
|
|
2018-10-23 09:02:54 +00:00
|
|
|
echo "# Generated by $(basename "$abuild_path") $program_version" >"$pkginfo"
|
2008-11-04 10:34:40 +00:00
|
|
|
if [ -n "$FAKEROOTKEY" ]; then
|
2009-10-24 20:53:31 +00:00
|
|
|
echo "# using $($FAKEROOT -v)" >> "$pkginfo"
|
2008-11-04 10:34:40 +00:00
|
|
|
fi
|
2016-08-20 13:16:48 +00:00
|
|
|
cat >> "$pkginfo" <<-EOF
|
|
|
|
pkgname = $name
|
|
|
|
pkgver = $pkgver-r$pkgrel
|
|
|
|
pkgdesc = $pkgdesc
|
|
|
|
url = $url
|
|
|
|
builddate = $builddate
|
|
|
|
packager = ${PACKAGER:-"Unknown"}
|
|
|
|
size = $size
|
|
|
|
arch = ${subpkgarch:-$pkgarch}
|
|
|
|
origin = $pkgname
|
|
|
|
EOF
|
2009-02-11 14:07:08 +00:00
|
|
|
local i deps
|
|
|
|
deps="$depends"
|
2017-08-05 22:03:13 +00:00
|
|
|
if [ "$pkgname" != "busybox" ] && ! depends_has busybox && ! depends_has /bin/sh; then
|
2011-06-27 20:13:20 +00:00
|
|
|
for i in $install $triggers; do
|
|
|
|
local s=${i%=*}
|
2011-06-28 11:31:40 +00:00
|
|
|
[ "$name" != "${s%.*}" ] && continue
|
2019-11-07 15:38:50 +00:00
|
|
|
if head -n 1 "$startdir/$s" | grep -E '^#!\s*/bin/sh' >/dev/null ; then
|
2017-08-05 22:03:13 +00:00
|
|
|
msg "Script found. /bin/sh added as a dependency for $pkg"
|
|
|
|
deps="$deps /bin/sh"
|
2009-03-06 17:51:53 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2009-02-11 14:07:08 +00:00
|
|
|
fi
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2019-11-07 14:13:00 +00:00
|
|
|
# store ABUILD_LAST_COMMIT in global var so we only call git once
|
|
|
|
if [ -z "$ABUILD_LAST_COMMIT" ]; then
|
|
|
|
ABUILD_LAST_COMMIT="$(git_last_commit)$(git_dirty)"
|
2011-03-08 10:08:01 +00:00
|
|
|
fi
|
2019-11-07 14:13:00 +00:00
|
|
|
echo "commit = $ABUILD_LAST_COMMIT" >> "$pkginfo"
|
2011-03-08 10:08:01 +00:00
|
|
|
|
2015-09-16 20:58:27 +00:00
|
|
|
get_maintainer
|
2011-03-08 10:08:01 +00:00
|
|
|
if [ -n "$maintainer" ]; then
|
|
|
|
echo "maintainer = $maintainer" >> "$pkginfo"
|
|
|
|
fi
|
|
|
|
|
2012-02-17 14:16:35 +00:00
|
|
|
if [ -n "$replaces_priority" ]; then
|
2012-02-22 14:23:16 +00:00
|
|
|
echo "replaces_priority = $replaces_priority" >> "$pkginfo"
|
2012-02-17 14:16:35 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-02 04:51:51 +00:00
|
|
|
if [ -n "$provider_priority" ]; then
|
|
|
|
echo "provider_priority = $provider_priority" >> "$pkginfo"
|
|
|
|
fi
|
|
|
|
|
2022-05-19 11:43:27 +00:00
|
|
|
echo "license = $(echo $license)" >> "$pkginfo"
|
2008-11-04 10:34:40 +00:00
|
|
|
for i in $replaces; do
|
2009-07-20 14:56:01 +00:00
|
|
|
echo "replaces = $i" >> "$pkginfo"
|
2008-11-04 10:34:40 +00:00
|
|
|
done
|
2009-02-11 14:07:08 +00:00
|
|
|
for i in $deps; do
|
2019-01-09 15:23:46 +00:00
|
|
|
if [ "$i" != "$name" ]; then
|
2022-01-17 15:14:58 +00:00
|
|
|
check_depver "$i" || die "Invalid version in dependency: $i"
|
2019-01-09 15:23:46 +00:00
|
|
|
echo "depend = $i" >> "$pkginfo"
|
|
|
|
fi
|
2008-11-04 10:34:40 +00:00
|
|
|
done
|
|
|
|
for i in $provides; do
|
2022-01-17 15:14:58 +00:00
|
|
|
check_depver "$i" || die "Invalid version in provides: $i"
|
2009-07-20 14:56:01 +00:00
|
|
|
echo "provides = $i" >> "$pkginfo"
|
2008-11-04 10:34:40 +00:00
|
|
|
done
|
2011-06-27 20:13:20 +00:00
|
|
|
for i in $triggers; do
|
|
|
|
local f=${i%=*}
|
|
|
|
local dirs=${i#*=}
|
|
|
|
[ "${f%.trigger}" != "$name" ] && continue
|
|
|
|
echo "triggers = ${dirs//:/ }" >> "$pkginfo"
|
|
|
|
done
|
2011-01-04 09:15:05 +00:00
|
|
|
if [ -n "$install_if" ]; then
|
|
|
|
echo "install_if = $(echo $install_if)" >> "$pkginfo"
|
|
|
|
fi
|
2008-11-04 10:34:40 +00:00
|
|
|
|
|
|
|
local metafiles=".PKGINFO"
|
2011-06-27 20:13:20 +00:00
|
|
|
for i in $install $triggers; do
|
|
|
|
local f=${i%=*}
|
|
|
|
local n=${f%.*}
|
2011-06-28 11:31:40 +00:00
|
|
|
if [ "$n" != "$name" ]; then
|
2011-06-27 18:55:14 +00:00
|
|
|
continue
|
|
|
|
fi
|
2011-06-27 20:13:20 +00:00
|
|
|
script=${f#$name}
|
2011-06-27 18:55:14 +00:00
|
|
|
msg "Adding $script"
|
2011-06-27 20:13:20 +00:00
|
|
|
cp "$startdir/$f" "$controldir/$script" || return 1
|
2009-07-20 14:56:01 +00:00
|
|
|
chmod +x "$controldir/$script"
|
2009-03-04 20:17:25 +00:00
|
|
|
metafiles="$metafiles $script"
|
|
|
|
done
|
2009-07-20 14:56:01 +00:00
|
|
|
echo $metafiles | tr ' ' '\n' > "$controldir"/.metafiles
|
2009-06-03 19:23:32 +00:00
|
|
|
}
|
2009-05-08 16:16:48 +00:00
|
|
|
|
2015-06-02 07:52:35 +00:00
|
|
|
prepare_trace_rpaths() {
|
2009-06-03 19:23:32 +00:00
|
|
|
local dir=${subpkgdir:-$pkgdir}
|
2012-09-05 12:26:45 +00:00
|
|
|
local etype= soname= file= sover=
|
2016-07-23 06:18:27 +00:00
|
|
|
[ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0
|
2009-06-03 19:23:32 +00:00
|
|
|
options_has "!tracedeps" && return 0
|
2010-12-15 13:01:13 +00:00
|
|
|
# lets tell all the places we should look for .so files - all rpaths
|
2012-09-06 13:00:54 +00:00
|
|
|
scanelf --quiet --recursive --rpath "$dir" \
|
|
|
|
| sed -e 's/[[:space:]].*//' -e 's/:/\n/' | sort -u \
|
2010-12-15 13:01:13 +00:00
|
|
|
>"$controldir"/.rpaths
|
2012-09-06 13:28:30 +00:00
|
|
|
if grep -q -x '/usr/lib' "$controldir"/.rpaths; then
|
2014-03-18 12:58:29 +00:00
|
|
|
warning "Redundant /usr/lib in rpath found"
|
2012-09-06 13:28:30 +00:00
|
|
|
fi
|
|
|
|
if grep '^/home/' "$controldir"/.rpaths; then
|
|
|
|
error "Has /home/... in rpath"
|
|
|
|
return 1
|
|
|
|
fi
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2015-06-03 06:28:34 +00:00
|
|
|
# search for broken symlinks so we later can pull in proper depends
|
|
|
|
prepare_symlinks() {
|
2015-11-04 17:43:17 +00:00
|
|
|
local target
|
2015-06-03 06:28:34 +00:00
|
|
|
local dir="${subpkgdir:-$pkgdir}"
|
|
|
|
options_has "!tracedeps" && return 0
|
|
|
|
cd "$dir" || return 1
|
|
|
|
find -type l | while read symlink; do
|
2015-11-04 17:43:17 +00:00
|
|
|
target=$(readlink "$symlink")
|
|
|
|
if ! [ -e "$dir$(normalize_target_path "$target" "$symlink")" ]; then
|
|
|
|
echo "$symlink $target" >> "$controldir"/.symlinks
|
2015-06-03 06:28:34 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2015-06-03 12:14:50 +00:00
|
|
|
prepare_pkgconfig_provides() {
|
|
|
|
local dir="${subpkgdir:-$pkgdir}"
|
|
|
|
options_has "!tracedeps" && return 0
|
|
|
|
cd "$dir" || return 1
|
2019-07-29 18:03:03 +00:00
|
|
|
for i in usr/lib/pkgconfig/*.pc usr/share/pkgconfig/*.pc; do
|
2015-06-03 12:14:50 +00:00
|
|
|
if ! [ -e "$i" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
local f=${i##*/}
|
2019-07-29 18:03:03 +00:00
|
|
|
local v=$(PKG_CONFIG_PATH="$dir"/usr/lib/pkgconfig:"$dir"/usr/share/pkgconfig \
|
|
|
|
PKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH=1 pkg-config \
|
2019-08-09 08:21:37 +00:00
|
|
|
--modversion ${f%.pc} | sed -E -e 's/-(alpha|beta|rc|pre)/_\1/')
|
2019-08-09 07:34:02 +00:00
|
|
|
$APK version --check --quiet $v || die "$i: pkgconf version $v is invalid"
|
2019-02-22 13:57:08 +00:00
|
|
|
echo "$pcprefix${f%.pc}=${v:-0}" >> "$controldir"/.provides-pc
|
2015-06-03 12:14:50 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-10-20 14:53:34 +00:00
|
|
|
prepare_command_provides() {
|
|
|
|
local dir="${subpkgdir:-$pkgdir}"
|
|
|
|
options_has "!tracedeps" && return 0
|
|
|
|
cd "$dir" || return 1
|
|
|
|
for i in bin/* sbin/* usr/bin/* usr/sbin/*; do
|
2024-04-06 20:35:13 +00:00
|
|
|
# We can't check symlinks properly with absolute paths,
|
|
|
|
# subpackages and dependencies so assume that they are commands
|
|
|
|
if ! [ -L "$i" ]; then
|
|
|
|
if ! [ -x "$i" ] || ! [ -f "$i" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2017-10-20 14:53:34 +00:00
|
|
|
fi
|
2024-04-17 06:20:10 +00:00
|
|
|
# exclude any provides: lines for commands that has '@' because '@'
|
|
|
|
# is used as seperator between command name and repository. This
|
|
|
|
# avoids potential conflicts
|
|
|
|
# ref: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10074
|
|
|
|
case "$i" in
|
|
|
|
*@*) continue;;
|
|
|
|
esac
|
2017-10-20 14:53:34 +00:00
|
|
|
local f=${i##*/}
|
|
|
|
echo $f >> "$controldir"/.provides-command
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-08-08 22:01:39 +00:00
|
|
|
prepare_py_provides() {
|
|
|
|
local dir="${subpkgdir:-$pkgdir}" py_providers=""
|
|
|
|
options_has "!tracedeps" && return 0
|
|
|
|
cd "$dir" || return 1
|
|
|
|
|
|
|
|
# Find all directories under site-packages, ignore __pycache__ and
|
|
|
|
# .egg-info packages, store the basename with the proper pyX.Y prefix
|
|
|
|
# one per-line
|
|
|
|
py_providers="$(find 'usr/lib/python'*/site-packages \
|
2021-05-15 20:39:48 +00:00
|
|
|
-mindepth 1 -maxdepth 1 \
|
2019-08-08 22:01:39 +00:00
|
|
|
-type f -iname '*.py' -o -type d \
|
2021-05-15 20:39:48 +00:00
|
|
|
-print0 \
|
2019-08-08 22:01:39 +00:00
|
|
|
2>/dev/null | xargs -0 -I '{}' sh -c '
|
|
|
|
d="{}"
|
|
|
|
|
|
|
|
# Check if we were given a directory then check if there
|
|
|
|
# is a file called __init__.py inside, this is required
|
|
|
|
# to import modules, if there is no __init__.py then the
|
|
|
|
# installed directory is not actually a module, this is a
|
|
|
|
# special case for packages that use c-extensions and
|
|
|
|
# install their .c and .h files to $sitelib.
|
|
|
|
if [ -d "$d" ] && [ ! -f "$d"/__init__.py ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Find out which version of python we are building for
|
|
|
|
# this will find out by looking at the MAJOR and MINOR
|
|
|
|
# versions in /usr/lib/pythonMAJOR.MINOR
|
|
|
|
pyver="${d##*usr/lib/python}"
|
|
|
|
pyver="${pyver%%/*}"
|
|
|
|
|
|
|
|
# Strip the .py prefix if it exists
|
|
|
|
d="${d%%.py*}"
|
|
|
|
|
|
|
|
echo "py$pyver:${d##*/}"
|
|
|
|
')"
|
|
|
|
local i; for i in $py_providers; do
|
|
|
|
echo "$i=$pkgver-r$pkgrel" >> "$controldir"/.provides-py
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-12-30 12:53:44 +00:00
|
|
|
# check if dir has arch specific binaries
|
|
|
|
dir_has_arch_binaries() {
|
|
|
|
local dir="$1"
|
|
|
|
# if scanelf returns something, then we have binaries
|
|
|
|
[ -n "$(scanelf -R "$dir" | head -n 1)" ] && return 0
|
|
|
|
|
|
|
|
# look for static *.a
|
|
|
|
[ -n "$(find "$dir" -type f -name '*.a' | head -n 1)" ] && return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2011-01-06 20:21:33 +00:00
|
|
|
# returns true if this is the -dev package
|
|
|
|
is_dev_pkg() {
|
2019-05-02 18:36:42 +00:00
|
|
|
test "${1%-dev}" != "$1"
|
2011-01-06 20:21:33 +00:00
|
|
|
}
|
|
|
|
|
2019-04-27 00:23:27 +00:00
|
|
|
# returns true if this is the -static package
|
|
|
|
is_static_pkg() {
|
|
|
|
test "${1%-static}" != "$1"
|
|
|
|
}
|
|
|
|
|
2015-08-14 15:07:28 +00:00
|
|
|
# returns true if this is the -doc package
|
|
|
|
is_doc_pkg() {
|
2015-08-18 11:46:15 +00:00
|
|
|
test "${1%-doc}" != "$1"
|
2015-08-14 15:07:28 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 09:20:48 +00:00
|
|
|
# returns true if this is the -devhelp package
|
2022-08-29 11:47:38 +00:00
|
|
|
is_devhelp_pkg() {
|
|
|
|
test "${1%-devhelp}" != "$1"
|
|
|
|
}
|
|
|
|
|
2018-03-11 15:17:30 +00:00
|
|
|
# returns true if this is the -openrc package
|
|
|
|
is_openrc_pkg() {
|
|
|
|
test "${1%-openrc}" != "$1"
|
|
|
|
}
|
|
|
|
|
2010-12-30 12:53:44 +00:00
|
|
|
# check that noarch is set if needed
|
|
|
|
archcheck() {
|
|
|
|
options_has "!archcheck" && return 0
|
|
|
|
if dir_has_arch_binaries "${subpkgdir:-$pkgdir}"; then
|
2016-07-23 06:18:27 +00:00
|
|
|
[ "${subpkgarch:-$pkgarch}" != "noarch" ] && return 0
|
2010-12-30 12:53:44 +00:00
|
|
|
error "Arch specific binaries found so arch must not be set to \"noarch\""
|
|
|
|
return 1
|
2019-05-02 18:36:42 +00:00
|
|
|
elif [ "${subpkgarch:-$pkgarch}" != "noarch" ] && ! is_dev_pkg "$subpkgname" && ! is_static_pkg "$subpkgname"; then
|
2011-01-06 20:21:33 +00:00
|
|
|
# we dont want -dev package go to noarch
|
|
|
|
warning "No arch specific binaries found so arch should probably be set to \"noarch\""
|
2010-12-30 12:53:44 +00:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2009-05-08 15:01:14 +00:00
|
|
|
prepare_package() {
|
2009-05-08 18:34:30 +00:00
|
|
|
msg "Preparing ${subpkgname:+sub}package ${subpkgname:-$pkgname}..."
|
2009-06-03 19:23:32 +00:00
|
|
|
stripbin
|
2015-06-03 12:14:50 +00:00
|
|
|
prepare_metafiles \
|
|
|
|
&& prepare_trace_rpaths \
|
|
|
|
&& prepare_symlinks \
|
|
|
|
&& prepare_pkgconfig_provides \
|
2017-10-20 14:53:34 +00:00
|
|
|
&& prepare_command_provides \
|
2019-08-08 22:01:39 +00:00
|
|
|
&& prepare_py_provides \
|
2015-06-03 06:28:34 +00:00
|
|
|
|| return 1
|
2013-07-02 07:18:11 +00:00
|
|
|
archcheck
|
2009-05-08 15:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pkginfo_val() {
|
|
|
|
local key="$1"
|
|
|
|
local file="$2"
|
|
|
|
awk -F ' = ' "\$1 == \"$key\" {print \$2}" "$file"
|
|
|
|
}
|
|
|
|
|
2010-12-15 13:01:13 +00:00
|
|
|
# find real path to so files
|
|
|
|
real_so_path() {
|
|
|
|
local so="$1"
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
[ -e "$1"/$so ] && realpath "$1/$so" && return 0
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
error "$so: path not found"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# search rpaths and /usr/lib /lib for given so files
|
|
|
|
find_so_files() {
|
|
|
|
local rpaths=$(cat "$1")
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
real_so_path "$1" /usr/lib /lib $rpaths || return 1
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2015-08-18 14:56:26 +00:00
|
|
|
subpkg_provides_prefixed_so() {
|
|
|
|
[ -n "$sonameprefix" ] && grep -q -w "^$sonameprefix$1" \
|
|
|
|
"$pkgbasedir"/.control.*/.provides-so 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2015-06-02 07:52:35 +00:00
|
|
|
subpkg_provides_so() {
|
2012-10-02 18:34:30 +00:00
|
|
|
grep -q -w "^$1" "$pkgbasedir"/.control.*/.provides-so 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2019-02-22 13:57:08 +00:00
|
|
|
subpkg_provides_prefixed_pc() {
|
|
|
|
[ -n "$pcprefix" ] && grep -q -w "^$pcprefix$1" \
|
|
|
|
"$pkgbasedir"/.control.*/.provides-pc 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2015-06-03 12:14:50 +00:00
|
|
|
subpkg_provides_pc() {
|
2015-06-12 07:09:30 +00:00
|
|
|
grep -q -w "^${1%%[<>=]*}" "$pkgbasedir"/.control.*/.provides-pc \
|
|
|
|
2>/dev/null
|
2015-06-03 12:14:50 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 19:23:32 +00:00
|
|
|
trace_apk_deps() {
|
|
|
|
local name="$1"
|
|
|
|
local dir="$2"
|
2016-07-27 10:54:24 +00:00
|
|
|
local parch="$3"
|
2012-10-02 18:34:30 +00:00
|
|
|
local i= found= autodeps= deppkgs= missing=
|
2016-07-27 10:54:24 +00:00
|
|
|
local apkroot=
|
|
|
|
|
|
|
|
case "$parch" in
|
|
|
|
$CBUILD_ARCH) ;;
|
2016-12-21 10:01:29 +00:00
|
|
|
$CARCH | $CTARGET_ARCH) apkroot="--root $CBUILDROOT --arch $CTARGET_ARCH" ;;
|
2016-07-27 10:54:24 +00:00
|
|
|
esac
|
2016-07-23 06:18:27 +00:00
|
|
|
|
2012-09-06 13:00:54 +00:00
|
|
|
msg "Tracing dependencies..."
|
2009-11-02 09:26:09 +00:00
|
|
|
# add pkgconfig if usr/lib/pkgconfig is found
|
2019-07-29 18:03:03 +00:00
|
|
|
if [ -d "$pkgbasedir"/$name/usr/lib/pkgconfig ] || [ -d "$pkgbasedir"/$name/usr/share/pkgconfig ] \
|
2009-11-02 09:26:09 +00:00
|
|
|
&& ! grep -q '^depend = pkgconfig' "$dir"/.PKGINFO; then
|
2010-08-31 13:50:06 +00:00
|
|
|
autodeps="$autodeps pkgconfig"
|
|
|
|
fi
|
|
|
|
|
2011-01-04 10:32:12 +00:00
|
|
|
[ -f "$dir"/.needs-so ] && for i in $(cat "$dir"/.needs-so); do
|
2012-10-02 18:34:30 +00:00
|
|
|
# first check if its provided by same apkbuild
|
2015-08-18 14:56:26 +00:00
|
|
|
grep -q -w "^$sonameprefix$i" "$dir"/.provides-so 2>/dev/null && continue
|
2012-10-02 18:34:30 +00:00
|
|
|
|
2015-08-18 14:56:26 +00:00
|
|
|
if subpkg_provides_prefixed_so "$i"; then
|
|
|
|
autodeps="$autodeps so:$sonameprefix$i"
|
2016-07-27 10:54:24 +00:00
|
|
|
elif subpkg_provides_so "$i" \
|
|
|
|
|| $APK $apkroot info --quiet --installed "so:$i"; then
|
2012-10-02 18:34:30 +00:00
|
|
|
autodeps="$autodeps so:$i"
|
2010-12-15 13:01:13 +00:00
|
|
|
else
|
2012-10-02 18:34:30 +00:00
|
|
|
missing="$missing $i"
|
2009-06-03 19:23:32 +00:00
|
|
|
fi
|
2010-12-15 13:01:13 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# find all packages that holds the so files
|
2011-01-04 10:32:12 +00:00
|
|
|
if [ -f "$dir"/.rpaths ]; then
|
2012-10-02 18:34:30 +00:00
|
|
|
local so_files=$(find_so_files "$dir"/.rpaths $missing) \
|
|
|
|
|| return 1
|
2016-07-27 10:54:24 +00:00
|
|
|
deppkgs=$($APK $apkroot info --quiet --who-owns $so_files) || return 1
|
2011-01-04 10:32:12 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-02 18:34:30 +00:00
|
|
|
for found in $deppkgs; do
|
2009-07-29 20:01:52 +00:00
|
|
|
if grep -w "^depend = ${found}$" "$dir"/.PKGINFO >/dev/null ; then
|
2009-06-03 19:23:32 +00:00
|
|
|
warning "You can remove '$found' from depends"
|
|
|
|
continue
|
|
|
|
fi
|
2012-10-02 18:34:30 +00:00
|
|
|
autodeps="$autodeps $found"
|
2009-06-03 19:23:32 +00:00
|
|
|
done
|
2010-08-31 13:50:06 +00:00
|
|
|
|
2015-06-03 06:28:34 +00:00
|
|
|
# symlink targets
|
|
|
|
for i in $(sort -u "$dir"/.symlinks-needs 2>/dev/null); do
|
|
|
|
autodeps="$autodeps $i"
|
|
|
|
done
|
|
|
|
|
2023-03-20 09:19:12 +00:00
|
|
|
# python3 dependencies
|
|
|
|
for i in $(sort -u "$dir"/.python3-needs 2>/dev/null); do
|
|
|
|
autodeps="$autodeps $i"
|
|
|
|
done
|
|
|
|
|
2015-06-03 12:14:50 +00:00
|
|
|
# pkg-config depends
|
|
|
|
for i in $(sort -u "$dir"/.needs-pc 2>/dev/null); do
|
2019-02-22 13:57:08 +00:00
|
|
|
# first check if its provided by same apkbuild
|
|
|
|
grep -q -w "^$pcprefix$i" "$dir"/.provides-pc 2>/dev/null && continue
|
|
|
|
|
|
|
|
if subpkg_provides_prefixed_pc "$i"; then
|
|
|
|
autodeps="$autodeps pc:$pcprefix$i"
|
|
|
|
elif subpkg_provides_pc "$i" \
|
2016-07-27 10:54:24 +00:00
|
|
|
|| $APK $apkroot info --quiet --installed "pc:$i"; then
|
2020-02-27 10:56:34 +00:00
|
|
|
local provider=$($APK $apkroot search --quiet "pc:$i")
|
2015-06-05 07:27:44 +00:00
|
|
|
if list_has "$provider" $depends_dev; then
|
|
|
|
warning "$provider should be removed from depends_dev"
|
|
|
|
fi
|
2015-06-03 12:14:50 +00:00
|
|
|
autodeps="$autodeps pc:$i"
|
2015-06-05 07:18:09 +00:00
|
|
|
else
|
|
|
|
warning "Could not find any provider for pc:$i"
|
2019-07-29 18:03:03 +00:00
|
|
|
for d in share lib; do
|
|
|
|
local pcfile=/usr/$d/pkgconfig/"${i%%[<>=]*}".pc
|
|
|
|
if [ -e "$pcfile" ]; then
|
|
|
|
local owner=$($APK $apkroot info --quiet --who-owns $pcfile)
|
|
|
|
warning "${owner:-package providing $pcfile} needs to be rebuilt"
|
|
|
|
fi
|
|
|
|
done
|
2015-06-03 12:14:50 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-06-03 19:23:32 +00:00
|
|
|
echo "# automatically detected:" >> "$dir"/.PKGINFO
|
2012-09-04 13:37:26 +00:00
|
|
|
if [ -f "$dir"/.provides-so ]; then
|
2015-12-10 10:15:53 +00:00
|
|
|
sed 's/^\(.*\) \([0-9].*\)/provides = so:\1=\2/' \
|
|
|
|
"$dir"/.provides-so | sort -u \
|
2012-09-05 11:09:57 +00:00
|
|
|
>> "$dir"/.PKGINFO
|
2012-09-04 13:37:26 +00:00
|
|
|
fi
|
2015-06-03 12:14:50 +00:00
|
|
|
if [ -f "$dir"/.provides-pc ]; then
|
2015-06-05 12:56:44 +00:00
|
|
|
sed 's/^/provides = pc:/' "$dir"/.provides-pc | sort -u \
|
2015-06-03 12:14:50 +00:00
|
|
|
>> "$dir"/.PKGINFO
|
|
|
|
fi
|
2017-10-20 14:53:34 +00:00
|
|
|
if [ -f "$dir"/.provides-command ]; then
|
2021-08-16 19:50:05 +00:00
|
|
|
sed -e 's/^/provides = cmd:/' -e "s/\$/=$pkgver-r$pkgrel/" \
|
|
|
|
"$dir"/.provides-command | sort -u \
|
2017-10-20 14:53:34 +00:00
|
|
|
>> "$dir"/.PKGINFO
|
|
|
|
fi
|
2019-08-08 22:01:39 +00:00
|
|
|
if [ -f "$dir"/.provides-py ]; then
|
|
|
|
sed 's/^/provides = /' "$dir"/.provides-py | sort -u \
|
|
|
|
>> "$dir"/.PKGINFO
|
|
|
|
fi
|
2012-09-04 13:37:26 +00:00
|
|
|
[ -z "$autodeps" ] && return 0
|
2009-06-03 19:23:32 +00:00
|
|
|
for i in $autodeps; do
|
2012-10-02 11:30:14 +00:00
|
|
|
echo "depend = $i"
|
|
|
|
done | sort -u >> "$dir"/.PKGINFO
|
2012-10-02 18:37:37 +00:00
|
|
|
# display all depends
|
|
|
|
sed -n '/^depend =/s/depend = /\t/p' "$dir"/.PKGINFO >&2
|
2009-06-03 19:23:32 +00:00
|
|
|
}
|
|
|
|
|
2012-09-06 13:00:54 +00:00
|
|
|
find_scanelf_paths() {
|
2012-09-12 07:03:41 +00:00
|
|
|
local datadir="$1"
|
2012-09-12 07:01:05 +00:00
|
|
|
local paths="$datadir/lib:$datadir/usr/lib" i= rpaths=
|
2012-09-06 13:00:54 +00:00
|
|
|
if [ -n "$ldpath" ]; then
|
2013-07-30 12:16:44 +00:00
|
|
|
paths="$paths:$(echo "${datadir}${ldpath}" | sed "s|:|:$datadir|g")"
|
2012-09-06 13:00:54 +00:00
|
|
|
fi
|
|
|
|
# search in all rpaths
|
2012-09-12 07:01:05 +00:00
|
|
|
for rpaths in "$pkgbasedir"/.control.*/.rpaths; do
|
|
|
|
[ -f "$rpaths" ] || continue
|
2012-09-06 13:00:54 +00:00
|
|
|
while read i; do
|
2012-09-12 07:03:41 +00:00
|
|
|
local dir="${datadir}${i}"
|
|
|
|
IFS=:
|
|
|
|
if [ -d "$dir" ] && ! list_has "$dir" $paths; then
|
|
|
|
paths="$paths:${dir}"
|
2012-09-06 13:00:54 +00:00
|
|
|
fi
|
2012-09-12 07:03:41 +00:00
|
|
|
unset IFS
|
2012-09-12 07:01:05 +00:00
|
|
|
done < "$rpaths"
|
2012-09-06 13:00:54 +00:00
|
|
|
done
|
|
|
|
echo "$paths"
|
|
|
|
}
|
|
|
|
|
|
|
|
scan_shared_objects() {
|
|
|
|
local name="$1" controldir="$2" datadir="$3"
|
2013-07-30 12:27:03 +00:00
|
|
|
local opt= i=
|
2012-09-06 13:00:54 +00:00
|
|
|
|
2016-07-23 06:18:27 +00:00
|
|
|
if [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
|
2015-06-03 06:28:34 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2012-09-06 13:00:54 +00:00
|
|
|
# allow spaces in paths
|
|
|
|
IFS=:
|
2012-09-12 07:03:41 +00:00
|
|
|
set -- $(find_scanelf_paths "$datadir")
|
2012-09-06 13:00:54 +00:00
|
|
|
unset IFS
|
|
|
|
|
2013-07-30 12:27:03 +00:00
|
|
|
# sanity check, verify that each path is prefixed with datadir
|
|
|
|
for i; do
|
|
|
|
if [ "${i#$datadir}" = "$i" ]; then
|
|
|
|
error "Internal error in scanelf paths"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-09-10 11:53:44 +00:00
|
|
|
if options_has "ldpath-recursive"; then
|
|
|
|
opt="--recursive"
|
|
|
|
fi
|
2012-09-06 13:00:54 +00:00
|
|
|
msg "Scanning shared objects"
|
|
|
|
# lets tell all the .so files this package provides in .provides-so
|
2012-09-10 11:53:44 +00:00
|
|
|
scanelf --nobanner --soname $opt "$@" | while read etype soname file; do
|
2012-09-06 13:00:54 +00:00
|
|
|
# if soname field is missing, soname will be the filepath
|
|
|
|
sover=0
|
2012-09-08 13:45:34 +00:00
|
|
|
if [ -z "$file" ]; then
|
|
|
|
file="$soname"
|
2012-09-06 13:00:54 +00:00
|
|
|
soname=${soname##*/}
|
2012-09-08 13:45:34 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# we only want shared libs
|
|
|
|
case $soname in
|
2013-02-21 15:23:02 +00:00
|
|
|
*.so|*.so.[0-9]*|*.c32);;
|
2012-09-08 13:45:34 +00:00
|
|
|
*) continue;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$file" in
|
|
|
|
*.so.[0-9]*) sover=${file##*.so.};;
|
|
|
|
*.so)
|
|
|
|
# filter out sonames with version when file does not
|
|
|
|
# have version
|
|
|
|
case "$soname" in
|
2012-10-02 18:38:32 +00:00
|
|
|
*.so.[0-9]*)
|
|
|
|
if options_has "sover-namecheck"; then
|
|
|
|
continue
|
|
|
|
fi
|
2012-09-06 13:00:54 +00:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
2012-10-10 17:24:09 +00:00
|
|
|
list_has "$soname" $somask && continue
|
2015-08-18 14:56:26 +00:00
|
|
|
echo "$sonameprefix$soname $sover"
|
2012-10-30 15:19:12 +00:00
|
|
|
# use awk to filter out dupes that has sover = 0
|
|
|
|
done | awk '{ if (so[$1] == 0) so[$1] = $2; }
|
|
|
|
END { for (i in so) print(i " " so[i]); }' \
|
|
|
|
| sort -u > "$controldir"/.provides-so
|
|
|
|
|
|
|
|
# verify that we dont have any duplicates
|
|
|
|
local dupes="$(cut -d' ' -f1 "$controldir"/.provides-so | uniq -d)"
|
|
|
|
if [ -n "$dupes" ]; then
|
|
|
|
die "provides multiple versions of same shared object: $dupes"
|
|
|
|
fi
|
2012-09-06 13:00:54 +00:00
|
|
|
|
|
|
|
# now find the so dependencies
|
2023-06-05 06:41:37 +00:00
|
|
|
scanelf --nobanner --recursive --needed --etype ET_DYN,ET_EXEC "$datadir" | tr ' ' ':' \
|
|
|
|
| awk -F ":" '$2 != "" {print $2}' \
|
2012-09-06 13:00:54 +00:00
|
|
|
| sed 's:,:\n:g' | sort -u \
|
2012-10-10 17:24:09 +00:00
|
|
|
| while read soname; do
|
2012-09-06 13:00:54 +00:00
|
|
|
# only add files that are not self provided
|
2015-08-18 14:56:26 +00:00
|
|
|
grep -q -w "^$sonameprefix$soname" "$controldir"/.provides-so \
|
2012-10-10 17:24:09 +00:00
|
|
|
|| list_has "$soname" $somask \
|
|
|
|
|| echo $soname
|
2012-09-06 13:00:54 +00:00
|
|
|
done > "$controldir"/.needs-so
|
|
|
|
}
|
|
|
|
|
2015-11-04 17:43:17 +00:00
|
|
|
# normalize a symlink target path (1st arg)
|
|
|
|
# Converts a relative path to absolute with respect to the symlink
|
|
|
|
# path (2nd arg).
|
|
|
|
normalize_target_path() {
|
|
|
|
local path=$1
|
|
|
|
[ "${path:0:1}" = / ] || path=$(dirname "$2")/$path
|
|
|
|
|
2015-06-05 12:11:47 +00:00
|
|
|
local oifs="$IFS" pathstr= i=
|
|
|
|
IFS='/'
|
2015-11-04 17:43:17 +00:00
|
|
|
set -- $path
|
2015-06-05 12:11:47 +00:00
|
|
|
for i; do
|
|
|
|
case "$i" in
|
|
|
|
"."|"") continue;;
|
|
|
|
"..") pathstr="${pathstr%%/${pathstr##*/}}";;
|
|
|
|
*) pathstr="${pathstr}/$i";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
echo "$pathstr"
|
|
|
|
}
|
|
|
|
|
2015-06-03 06:28:34 +00:00
|
|
|
# find which package provides file that symlink points to
|
|
|
|
scan_symlink_targets() {
|
|
|
|
local name="$1" dir="$2" datadir="$3"
|
2015-06-04 11:50:41 +00:00
|
|
|
local symfile= targetpath=
|
2015-06-03 06:28:34 +00:00
|
|
|
cd "$datadir"
|
|
|
|
for symfile in "$pkgbasedir"/.control.*/.symlinks; do
|
2015-06-23 11:20:29 +00:00
|
|
|
local d="${symfile%/.symlinks}"
|
|
|
|
if ! [ -e "$symfile" ] || [ "$d" = "$dir" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2015-06-03 06:28:34 +00:00
|
|
|
while read symlink target; do
|
2015-11-04 17:43:17 +00:00
|
|
|
targetpath=$datadir$(normalize_target_path "$target" "$symlink")
|
2015-06-04 11:50:41 +00:00
|
|
|
if [ -e "$targetpath" ] || [ -L "$targetpath" ]; then
|
2015-06-03 06:45:04 +00:00
|
|
|
echo "$name=$pkgver-r$pkgrel" \
|
|
|
|
>> "$d"/.symlinks-needs
|
2015-06-03 06:28:34 +00:00
|
|
|
fi
|
|
|
|
done < "$symfile"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-03-20 09:19:12 +00:00
|
|
|
# check if python3 site packages are installed and depend on a compatible version
|
|
|
|
scan_python3_dependency() {
|
|
|
|
local controldir="$2" datadir="$3"
|
2023-06-15 12:50:11 +00:00
|
|
|
local dir_count=0
|
|
|
|
local site_pkg_dir
|
|
|
|
for site_pkg_dir in "$datadir"/usr/lib/python3*/site-packages; do
|
|
|
|
if ! [ -d "$site_pkg_dir" ]; then
|
|
|
|
# empty iteration
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
dir_count=$((dir_count + 1))
|
|
|
|
if [ "$dir_count" -gt 1 ]; then
|
2023-03-20 09:19:12 +00:00
|
|
|
error "package contains python3 modules for conflicting python3 versions"
|
2023-06-15 12:50:11 +00:00
|
|
|
return 1
|
2023-03-20 09:19:12 +00:00
|
|
|
fi
|
2023-06-15 12:50:11 +00:00
|
|
|
local pyver="${site_pkg_dir##*usr/lib/python}"
|
2023-03-20 09:19:12 +00:00
|
|
|
pyver="${pyver%%/*}"
|
2024-04-03 12:09:03 +00:00
|
|
|
if [ -n "$pyver" ] && [ "${subpkgname:-$pkgname}" != python3 ]; then
|
2023-03-20 09:19:12 +00:00
|
|
|
echo "python3~$pyver" \
|
|
|
|
>> "$controldir"/.python3-needs
|
|
|
|
fi
|
2023-06-15 12:50:11 +00:00
|
|
|
done
|
2023-03-20 09:19:12 +00:00
|
|
|
}
|
|
|
|
|
2015-06-03 12:14:50 +00:00
|
|
|
#find pkg-config dependencies
|
|
|
|
scan_pkgconfig_depends() {
|
|
|
|
local provides_pc="$1" controldir= name= datadir=
|
|
|
|
[ -e "$provides_pc" ] || return 0
|
|
|
|
controldir="${provides_pc%/*}"
|
|
|
|
name="$(pkginfo_val pkgname "$controldir"/.PKGINFO)"
|
|
|
|
datadir="$pkgbasedir"/$name
|
|
|
|
for i in $(sort -u "$provides_pc"); do
|
2019-07-29 18:03:03 +00:00
|
|
|
PKG_CONFIG_PATH="$datadir"/usr/lib/pkgconfig:"$datadir"/usr/share/pkgconfig \
|
|
|
|
pkg-config \
|
2015-06-03 12:14:50 +00:00
|
|
|
--print-requires \
|
|
|
|
--print-requires-private ${i%=*} \
|
|
|
|
| sed -E 's/\s*([<>=]+)\s*/\1/' \
|
|
|
|
| while read pc; do
|
|
|
|
# only add files that are not self provided
|
2015-06-12 07:12:47 +00:00
|
|
|
if ! grep -q -w "^${pc%%[<>=]*}" "$provides_pc"; then
|
2015-06-03 12:14:50 +00:00
|
|
|
echo "$pc" >> "$controldir"/.needs-pc
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-10-04 06:52:19 +00:00
|
|
|
# read size in bytes from stdin and show as human readable
|
|
|
|
human_size() {
|
|
|
|
awk '{ split("B KB MB GB TB PB", type)
|
2015-10-17 13:49:27 +00:00
|
|
|
for(i=5; y < 1 && $1 > 0; i--)
|
2017-06-23 07:52:18 +00:00
|
|
|
y = $1 / (2^(10*i))
|
2012-10-04 06:52:19 +00:00
|
|
|
printf("%.1f %s\n", y, type[i+2]) }'
|
|
|
|
}
|
|
|
|
|
2009-05-08 15:01:14 +00:00
|
|
|
create_apks() {
|
2012-10-04 06:52:19 +00:00
|
|
|
local file= dir= name= ver= apk= datadir= size=
|
2018-10-28 12:34:02 +00:00
|
|
|
local gzip=$(command -v pigz || echo gzip)
|
2024-03-22 19:36:53 +00:00
|
|
|
if ! options_has "keepdirs"; then
|
|
|
|
rmdir "$pkgdir"/usr/lib \
|
|
|
|
"$pkgdir"/usr/bin \
|
|
|
|
"$pkgdir"/usr/share \
|
|
|
|
"$pkgdir"/usr \
|
|
|
|
"$pkgdir"/etc/ \
|
|
|
|
2>/dev/null || :
|
|
|
|
fi
|
2015-06-03 06:28:34 +00:00
|
|
|
if ! options_has "!tracedeps"; then
|
2012-09-06 13:00:54 +00:00
|
|
|
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
|
|
|
|
dir="${file%/.PKGINFO}"
|
2023-04-14 06:03:17 +00:00
|
|
|
name="$(pkginfo_val pkgname "$file")"
|
2012-09-06 13:00:54 +00:00
|
|
|
datadir="$pkgbasedir"/$name
|
|
|
|
subpkgname=$name
|
|
|
|
scan_shared_objects "$name" "$dir" "$datadir"
|
2015-06-03 06:28:34 +00:00
|
|
|
scan_symlink_targets "$name" "$dir" "$datadir"
|
2023-03-20 09:19:12 +00:00
|
|
|
scan_python3_dependency "$name" "$dir" "$datadir"
|
2012-09-06 13:00:54 +00:00
|
|
|
done
|
2015-06-03 12:14:50 +00:00
|
|
|
for file in "$pkgbasedir"/.control.*/.provides-pc; do
|
|
|
|
scan_pkgconfig_depends "$file"
|
|
|
|
done
|
2012-09-06 13:00:54 +00:00
|
|
|
fi
|
2015-06-03 12:14:50 +00:00
|
|
|
|
2009-07-20 14:56:01 +00:00
|
|
|
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
|
2016-07-26 08:05:17 +00:00
|
|
|
local dir="${file%/.PKGINFO}"
|
2023-04-14 06:03:17 +00:00
|
|
|
local name=$(pkginfo_val pkgname "$file")
|
|
|
|
local ver=$(pkginfo_val pkgver "$file")
|
2023-06-03 10:55:12 +00:00
|
|
|
local size=$(pkginfo_val size "$file")
|
2016-07-26 08:05:17 +00:00
|
|
|
local apk=$name-$ver.apk
|
|
|
|
local datadir="$pkgbasedir"/$name
|
|
|
|
local subpkgname=$name
|
2023-04-14 06:03:17 +00:00
|
|
|
local subpkgarch=$(pkginfo_val arch "$file")
|
2009-06-03 19:23:32 +00:00
|
|
|
|
2023-06-03 10:55:12 +00:00
|
|
|
# See https://gitlab.alpinelinux.org/alpine/tsc/-/issues/16
|
|
|
|
if ! options_has "bigdocs" && is_doc_pkg "$name" && [ "$size" -gt "$doc_threshold" ]; then
|
|
|
|
warning "The -doc subpackage is unusually large, consider splitting it"
|
|
|
|
fi
|
|
|
|
|
2016-07-27 10:54:24 +00:00
|
|
|
trace_apk_deps "$name" "$dir" "$subpkgarch" || return 1
|
2023-06-03 10:55:12 +00:00
|
|
|
msg "Package size: $(echo "$size" | human_size)"
|
2012-09-06 13:00:54 +00:00
|
|
|
msg "Compressing data..."
|
2009-05-08 15:01:14 +00:00
|
|
|
(
|
2009-07-20 14:56:01 +00:00
|
|
|
cd "$datadir"
|
|
|
|
# data.tar.gz
|
2009-07-24 09:24:42 +00:00
|
|
|
set -- *
|
|
|
|
if [ "$1" = '*' ]; then
|
|
|
|
touch .dummy
|
|
|
|
set -- .dummy
|
|
|
|
fi
|
2019-06-08 19:42:21 +00:00
|
|
|
|
|
|
|
# normalize timestamps
|
2019-12-03 20:31:44 +00:00
|
|
|
find "$@" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
|
2019-06-08 19:42:21 +00:00
|
|
|
|
2019-12-03 20:31:44 +00:00
|
|
|
# explicitly sort package content
|
|
|
|
find "$@" -print0 | LC_ALL=C sort -z | tar --xattrs \
|
2021-05-19 04:01:42 +00:00
|
|
|
--xattrs-exclude=security.selinux \
|
2019-12-02 17:09:56 +00:00
|
|
|
--format=posix \
|
|
|
|
--pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0 \
|
|
|
|
--mtime="@${SOURCE_DATE_EPOCH}" \
|
2019-12-03 20:31:44 +00:00
|
|
|
--no-recursion --null -T - \
|
|
|
|
-f - -c | abuild-tar --hash | $gzip -n -9 >"$dir"/data.tar.gz
|
2009-07-20 14:56:01 +00:00
|
|
|
|
2012-09-06 13:00:54 +00:00
|
|
|
msg "Create checksum..."
|
2009-07-20 14:56:01 +00:00
|
|
|
# append the hash for data.tar.gz
|
|
|
|
local sha256=$(sha256sum "$dir"/data.tar.gz | cut -f1 -d' ')
|
|
|
|
echo "datahash = $sha256" >> "$dir"/.PKGINFO
|
2019-06-08 19:42:21 +00:00
|
|
|
touch -h -d "@$SOURCE_DATE_EPOCH" "$dir"/.PKGINFO
|
2009-07-20 14:56:01 +00:00
|
|
|
|
|
|
|
# control.tar.gz
|
2009-05-14 14:41:12 +00:00
|
|
|
cd "$dir"
|
2019-12-02 17:09:56 +00:00
|
|
|
tar \
|
|
|
|
--format=posix \
|
|
|
|
--pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0 \
|
|
|
|
--mtime="@${SOURCE_DATE_EPOCH}" \
|
|
|
|
-f - -c $(cat "$dir"/.metafiles) | abuild-tar --cut \
|
|
|
|
| $gzip -n -9 > control.tar.gz
|
2009-07-23 09:29:54 +00:00
|
|
|
abuild-sign -q control.tar.gz || exit 1
|
2008-10-18 08:09:24 +00:00
|
|
|
|
2012-09-06 13:00:54 +00:00
|
|
|
msg "Create $apk"
|
2024-01-11 21:04:32 +00:00
|
|
|
mkdir -p "$REPODEST/$repo/$(arch2dir "$subpkgarch")"
|
|
|
|
cat control.tar.gz data.tar.gz > "$REPODEST/$repo/$(arch2dir "$subpkgarch")/$apk"
|
2012-09-06 13:00:54 +00:00
|
|
|
)
|
2009-05-14 14:41:12 +00:00
|
|
|
done
|
2011-03-30 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
2013-02-07 15:29:53 +00:00
|
|
|
build_abuildrepo() {
|
2018-10-03 12:44:56 +00:00
|
|
|
local part _check=check
|
2018-10-03 12:29:57 +00:00
|
|
|
if options_has "checkroot"; then
|
|
|
|
_check=check_fakeroot
|
2017-05-20 16:32:45 +00:00
|
|
|
fi
|
2017-01-29 09:47:25 +00:00
|
|
|
if ! want_check; then
|
|
|
|
_check=true
|
|
|
|
fi
|
2011-03-30 09:06:48 +00:00
|
|
|
if ! apk_up2date || [ -n "$force" ]; then
|
2013-10-25 08:40:40 +00:00
|
|
|
# check early if we have abuild key
|
2017-02-21 15:44:15 +00:00
|
|
|
abuild-sign --installed
|
2016-07-26 08:05:17 +00:00
|
|
|
logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
|
2023-06-04 18:10:22 +00:00
|
|
|
local _starttime=$(date -u +%s)
|
2018-11-08 08:47:28 +00:00
|
|
|
msg "Building $repo/$pkgname $pkgver-r$pkgrel (using $program $program_version) started $(date -R)"
|
2019-11-07 14:13:51 +00:00
|
|
|
|
2019-11-13 17:15:28 +00:00
|
|
|
# make sure SOURCE_DATE_EPOCH is set
|
|
|
|
set_source_date
|
2019-11-07 14:13:51 +00:00
|
|
|
|
2018-10-03 12:44:56 +00:00
|
|
|
for part in sanitycheck builddeps clean fetch unpack prepare mkusers build \
|
|
|
|
$_check rootpkg; do
|
|
|
|
runpart $part
|
|
|
|
done
|
2023-06-04 18:10:22 +00:00
|
|
|
local _endtime=$(date -u +%s)
|
2018-11-08 08:47:28 +00:00
|
|
|
local _difftime=$((_endtime - _starttime))
|
2018-12-02 19:50:28 +00:00
|
|
|
msg "Build complete at $(date -R) elapsed time $((_difftime/3600))h $((_difftime/60%60))m $((_difftime%60))s"
|
2017-02-21 15:44:15 +00:00
|
|
|
cleanup $CLEANUP
|
2011-03-30 09:06:48 +00:00
|
|
|
fi
|
2013-02-07 15:29:53 +00:00
|
|
|
update_abuildrepo_index
|
|
|
|
}
|
2011-03-30 09:06:48 +00:00
|
|
|
|
2013-07-02 07:18:11 +00:00
|
|
|
update_abuildrepo_index() {
|
2016-07-26 11:32:43 +00:00
|
|
|
local i allarch=""
|
|
|
|
for i in $allpackages; do
|
|
|
|
subpkg_set "$i"
|
|
|
|
##NOARCH: These packages are really in $CARCH and do not need their
|
|
|
|
# own repository. --rewrite-arch is used below to make sure the index
|
|
|
|
# thinks they are for $CARCH and apk-tools will fetch them from
|
2024-01-11 21:04:32 +00:00
|
|
|
# correct URL path. Remainder of the script uses $(arch2dir "$subpkgarch")
|
2016-07-26 11:32:43 +00:00
|
|
|
# when expanding to the target repository path.
|
2024-01-11 21:04:32 +00:00
|
|
|
[ "$subpkgarch" = "noarch" -o "$subpkgarch" = "all" ] && subpkgarch="$CARCH"
|
2016-07-26 11:32:43 +00:00
|
|
|
list_has "$subpkgarch" "$allarch" || allarch="$allarch $subpkgarch"
|
|
|
|
done
|
|
|
|
subpkg_unset
|
|
|
|
|
2018-02-07 19:06:56 +00:00
|
|
|
if [ -z "$DESCRIPTION" ]; then
|
2018-04-22 14:17:23 +00:00
|
|
|
DESCRIPTION="$repo $(cd $startdir && $git describe 2>/dev/null || true)"
|
2018-02-07 19:06:56 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-29 14:42:12 +00:00
|
|
|
local oldpwd="$PWD"
|
2016-07-26 11:32:43 +00:00
|
|
|
for i in $allarch; do
|
|
|
|
cd "$REPODEST/$repo/$i"
|
|
|
|
local index=$i/APKINDEX.tar.gz
|
|
|
|
|
|
|
|
msg "Updating the $repo/$i repository index..."
|
|
|
|
local oldindex=
|
|
|
|
if [ -f APKINDEX.tar.gz ]; then
|
|
|
|
oldindex="--index APKINDEX.tar.gz"
|
|
|
|
fi
|
2023-04-13 05:04:19 +00:00
|
|
|
( $APK index $ABUILD_APK_INDEX_OPTS --no-warnings --quiet $oldindex --output APKINDEX.tar.gz.$$ \
|
2017-06-21 17:51:00 +00:00
|
|
|
--description "$DESCRIPTION" --rewrite-arch $i *.apk && \
|
2016-07-26 11:32:43 +00:00
|
|
|
msg "Signing the index..." && \
|
|
|
|
abuild-sign -q APKINDEX.tar.gz.$$ && \
|
|
|
|
chmod 644 APKINDEX.tar.gz.$$ && \
|
|
|
|
mv APKINDEX.tar.gz.$$ APKINDEX.tar.gz \
|
|
|
|
) || (rm -f APKINDEX.tar.gz.$$ ; die "Failed to create index")
|
|
|
|
done
|
2020-10-29 14:42:12 +00:00
|
|
|
cd "$oldpwd"
|
2009-05-08 18:34:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 09:47:25 +00:00
|
|
|
# predefined function check
|
|
|
|
default_check() {
|
2017-02-28 08:22:36 +00:00
|
|
|
warning "APKBUILD does not run any tests!"
|
|
|
|
msg2 "Alpine policy will soon require that packages have any relevant testsuites run during the build process."
|
|
|
|
msg2 "To fix, either define a check() function, or declare !check in \$options to indicate the package does not have a testsuite."
|
2017-01-29 09:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check() {
|
|
|
|
default_check
|
|
|
|
}
|
|
|
|
|
2008-11-06 15:27:10 +00:00
|
|
|
# predefined splitfunc doc
|
2009-02-08 21:03:32 +00:00
|
|
|
default_doc() {
|
2019-04-22 19:34:50 +00:00
|
|
|
local gzip=$(command -v pigz || echo gzip)
|
2009-01-07 07:44:15 +00:00
|
|
|
depends="$depends_doc"
|
2011-01-28 00:46:43 +00:00
|
|
|
pkgdesc="$pkgdesc (documentation)"
|
2015-07-20 14:10:36 +00:00
|
|
|
install_if="docs $pkgname=$pkgver-r$pkgrel"
|
2011-01-28 00:46:43 +00:00
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
local i
|
2013-10-31 12:55:23 +00:00
|
|
|
for i in doc man info html sgml licenses gtk-doc ri help; do
|
2008-10-24 09:40:30 +00:00
|
|
|
if [ -d "$pkgdir/usr/share/$i" ]; then
|
|
|
|
mkdir -p "$subpkgdir/usr/share"
|
|
|
|
mv "$pkgdir/usr/share/$i" "$subpkgdir/usr/share/"
|
2008-10-18 08:09:24 +00:00
|
|
|
fi
|
|
|
|
done
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2014-06-07 13:47:47 +00:00
|
|
|
# compress man pages
|
2015-11-26 23:38:51 +00:00
|
|
|
local mandir="$subpkgdir"/usr/share/man
|
2015-11-26 23:47:07 +00:00
|
|
|
[ -d "$mandir" ] && find "$mandir" -type l \
|
|
|
|
-a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \
|
2016-02-03 19:32:30 +00:00
|
|
|
-a \! \( -name '*.gz' -o -name '*.bz2' -o -name '*.xz' \) \
|
2015-11-26 23:47:07 +00:00
|
|
|
| while read symlink; do
|
|
|
|
|
|
|
|
ln -s $(readlink $symlink).gz "$symlink".gz
|
|
|
|
rm -f "$symlink"
|
|
|
|
done
|
2015-11-26 23:38:51 +00:00
|
|
|
[ -d "$mandir" ] && find "$mandir" -type f \
|
|
|
|
-a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \
|
2016-02-03 19:32:30 +00:00
|
|
|
-a \! \( -name '*.gz' -o -name '*.bz2' -o -name '*.xz' \) \
|
2016-02-03 19:04:50 +00:00
|
|
|
-exec stat -c "%i %n" \{\} \+ | while read inode name; do
|
2015-11-26 23:38:51 +00:00
|
|
|
|
|
|
|
# Skip hardlinks removed in last iteration.
|
|
|
|
[ -f "$name" ] || continue
|
|
|
|
|
|
|
|
local islink=0
|
|
|
|
find "$mandir" -type f -links +1 \
|
|
|
|
-a \( -name \*.[0-8n] -o -name \*.[0-8][a-z]* \) \
|
2016-02-03 19:32:30 +00:00
|
|
|
-a \! \( -name '*.gz' -o -name '*.bz2' -o -name '*.xz' \) \
|
2016-02-03 19:04:50 +00:00
|
|
|
-exec stat -c "%i %n" \{\} \+ | while read linode lname; do
|
2015-11-26 23:38:51 +00:00
|
|
|
if [ "$linode" = "$inode" -a "$lname" != "$name" ]; then
|
|
|
|
islink=1
|
|
|
|
rm -f "$lname"
|
|
|
|
ln -s "${name##*/}".gz "$lname".gz
|
|
|
|
fi
|
|
|
|
done
|
2015-08-19 08:59:00 +00:00
|
|
|
|
2019-12-02 17:09:56 +00:00
|
|
|
[ $islink -eq 0 ] && $gzip -n -9 "$name"
|
2015-08-19 08:59:00 +00:00
|
|
|
done
|
2014-06-07 13:47:47 +00:00
|
|
|
|
2008-11-13 10:40:58 +00:00
|
|
|
rm -f "$subpkgdir/usr/share/info/dir"
|
|
|
|
|
2008-10-24 10:00:46 +00:00
|
|
|
# remove if empty, ignore error (not empty)
|
2017-02-21 15:44:15 +00:00
|
|
|
rmdir "$pkgdir/usr/share" "$pkgdir/usr" 2>/dev/null || :
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-08 21:03:32 +00:00
|
|
|
doc() {
|
|
|
|
default_doc
|
|
|
|
}
|
|
|
|
|
2017-06-16 08:21:53 +00:00
|
|
|
# predefined splitfunc dbg
|
2014-01-16 13:33:45 +00:00
|
|
|
default_dbg() {
|
2019-04-30 07:41:23 +00:00
|
|
|
local f
|
2017-06-16 08:21:53 +00:00
|
|
|
pkgdesc="$pkgdesc (debug symbols)"
|
|
|
|
|
2020-07-02 16:47:29 +00:00
|
|
|
# assume $pkgbasedir is all one filesystem
|
|
|
|
mkdir "$pkgbasedir/.dbg-tmp"
|
|
|
|
# note: the subpkgdir doesn't exist when the glob is evaluated
|
|
|
|
scanelf -Ry "$pkgbasedir"/* | while read type src; do
|
|
|
|
if [ "$type" != ET_DYN ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
local dst=$subpkgdir/usr/lib/debug/${src#"$pkgbasedir"/*/}.debug
|
|
|
|
mkdir -p "${dst%/*}"
|
|
|
|
local ino=$(stat -c %i "$src")
|
|
|
|
if ! [ -e "$pkgbasedir/.dbg-tmp/$ino" ]; then
|
|
|
|
local tmp=$pkgbasedir/.dbg-tmp/${src##*/}
|
|
|
|
${CROSS_COMPILE}objcopy --only-keep-debug "$src" "$dst"
|
|
|
|
${CROSS_COMPILE}objcopy --add-gnu-debuglink="$dst" --strip-unneeded -R .comment "$src" "$tmp"
|
|
|
|
# preserve attributes, links
|
|
|
|
cat "$tmp" > "$src"
|
|
|
|
rm "$tmp"
|
|
|
|
ln "$dst" "$pkgbasedir/.dbg-tmp/$ino"
|
2019-04-30 07:41:23 +00:00
|
|
|
fi
|
2014-01-16 13:33:45 +00:00
|
|
|
done
|
2020-07-02 16:47:29 +00:00
|
|
|
rm -r "$pkgbasedir/.dbg-tmp"
|
2014-01-16 13:33:45 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
dbg() {
|
|
|
|
default_dbg
|
|
|
|
}
|
|
|
|
|
2008-11-06 15:27:10 +00:00
|
|
|
# predefined splitfunc dev
|
2009-02-08 21:03:32 +00:00
|
|
|
default_dev() {
|
2010-05-18 12:45:17 +00:00
|
|
|
local i= j=
|
2015-06-03 09:38:48 +00:00
|
|
|
depends="$depends_dev"
|
2011-01-28 00:46:43 +00:00
|
|
|
pkgdesc="$pkgdesc (development files)"
|
|
|
|
|
2008-12-01 22:04:39 +00:00
|
|
|
cd "$pkgdir" || return 0
|
2015-01-14 15:26:58 +00:00
|
|
|
local libdirs=usr/
|
|
|
|
[ -d lib/ ] && libdirs="lib/ $libdirs"
|
2019-07-29 18:09:21 +00:00
|
|
|
for i in usr/include usr/lib/pkgconfig usr/share/pkgconfig \
|
|
|
|
usr/share/aclocal usr/share/gettext \
|
|
|
|
usr/bin/*-config usr/share/vala/vapi \
|
|
|
|
usr/share/gir-[0-9]* usr/share/qt*/mkspecs \
|
|
|
|
usr/lib/qt*/mkspecs usr/lib/cmake \
|
2019-12-04 15:55:56 +00:00
|
|
|
usr/lib/glade/modules usr/share/glade/catalogs \
|
2020-07-01 21:57:19 +00:00
|
|
|
$(find . -name include -type d) \
|
2019-05-01 08:03:09 +00:00
|
|
|
$(subpackage_types_has static || find $libdirs \
|
2019-04-27 00:23:27 +00:00
|
|
|
-name '*.a' 2>/dev/null) \
|
|
|
|
$(find $libdirs -name '*.[cho]' \
|
2013-10-04 14:05:12 +00:00
|
|
|
-o -name '*.prl' 2>/dev/null); do
|
2008-10-24 09:40:30 +00:00
|
|
|
if [ -e "$pkgdir/$i" ] || [ -L "$pkgdir/$i" ]; then
|
2020-07-01 21:57:19 +00:00
|
|
|
d="$subpkgdir/${i%/*}" # dirname $i
|
2008-10-18 08:09:24 +00:00
|
|
|
mkdir -p "$d"
|
2008-10-24 09:40:30 +00:00
|
|
|
mv "$pkgdir/$i" "$d"
|
2017-02-21 15:44:15 +00:00
|
|
|
rmdir "$pkgdir/${i%/*}" 2>/dev/null || :
|
2008-10-18 08:09:24 +00:00
|
|
|
fi
|
|
|
|
done
|
2010-05-18 12:45:17 +00:00
|
|
|
# move *.so links needed when linking the apps to -dev packages
|
|
|
|
for i in lib/*.so usr/lib/*.so; do
|
|
|
|
if [ -L "$i" ]; then
|
|
|
|
mkdir -p "$subpkgdir"/"${i%/*}"
|
|
|
|
mv "$i" "$subpkgdir/$i" || return 1
|
|
|
|
fi
|
|
|
|
done
|
2009-01-09 21:03:15 +00:00
|
|
|
return 0
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-08 21:03:32 +00:00
|
|
|
dev() {
|
|
|
|
default_dev
|
|
|
|
}
|
|
|
|
|
2019-04-27 00:23:27 +00:00
|
|
|
# predefined splitfunc static
|
|
|
|
default_static() {
|
2019-08-15 17:19:59 +00:00
|
|
|
local i= devpkg
|
|
|
|
|
|
|
|
# search for -dev package matching our prefix
|
|
|
|
if [ -z "$depends_static" ]; then
|
2019-09-30 12:02:40 +00:00
|
|
|
devpkg="${subpkgname%-libs-static}"
|
|
|
|
devpkg="${devpkg%-static}"
|
|
|
|
devpkg="$devpkg-dev"
|
|
|
|
if subpackages_has "$devpkg"; then
|
|
|
|
depends_static="$devpkg"
|
|
|
|
fi
|
2019-08-15 17:19:59 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-07 05:09:39 +00:00
|
|
|
depends="$depends_static"
|
2019-04-27 00:23:27 +00:00
|
|
|
pkgdesc="$pkgdesc (static library)"
|
|
|
|
|
|
|
|
cd "$pkgdir" || return 0
|
|
|
|
local libdirs=usr/lib
|
|
|
|
[ -d lib/ ] && libdirs="lib/ $libdirs"
|
|
|
|
|
|
|
|
# move *.a static library
|
|
|
|
for i in $(find $libdir -name '*.a'); do
|
|
|
|
mkdir -p "$subpkgdir"/"${i%/*}"
|
|
|
|
mv "$i" "$subpkgdir/$i" || return 1
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
static() {
|
|
|
|
default_static
|
|
|
|
}
|
|
|
|
|
2012-10-10 17:36:00 +00:00
|
|
|
# predefined splitfunc libs
|
|
|
|
default_libs() {
|
2019-04-09 14:04:35 +00:00
|
|
|
depends="$depends_libs"
|
2012-10-10 17:36:00 +00:00
|
|
|
pkgdesc="$pkgdesc (libraries)"
|
|
|
|
local dir= file=
|
|
|
|
for dir in lib usr/lib; do
|
|
|
|
for file in "$pkgdir"/$dir/lib*.so.[0-9]*; do
|
|
|
|
[ -f "$file" ] || continue
|
|
|
|
mkdir -p "$subpkgdir"/$dir
|
|
|
|
mv "$file" "$subpkgdir"/$dir/
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
libs() {
|
|
|
|
default_libs
|
|
|
|
}
|
|
|
|
|
2017-07-25 12:16:23 +00:00
|
|
|
# predefined splitfunc openrc
|
|
|
|
default_openrc() {
|
2019-03-28 19:35:36 +00:00
|
|
|
depends="$depends_openrc"
|
2017-07-25 12:16:23 +00:00
|
|
|
pkgdesc="$pkgdesc (OpenRC init scripts)"
|
2019-05-03 16:35:44 +00:00
|
|
|
install_if="openrc ${subpkgname%-openrc}=$pkgver-r$pkgrel"
|
2017-07-25 12:16:23 +00:00
|
|
|
local dir file
|
|
|
|
for dir in conf.d init.d; do
|
|
|
|
if [ -d "$pkgdir/etc/$dir" ]; then
|
|
|
|
mkdir -p "$subpkgdir"/etc
|
|
|
|
mv "$pkgdir/etc/$dir" "$subpkgdir"/etc/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
openrc() {
|
|
|
|
default_openrc
|
|
|
|
}
|
|
|
|
|
2022-08-29 11:47:38 +00:00
|
|
|
default_devhelp() {
|
2023-04-14 10:24:57 +00:00
|
|
|
depends=""
|
2022-08-29 11:47:38 +00:00
|
|
|
pkgdesc="$pkgname - devhelp files"
|
2023-04-14 10:24:57 +00:00
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel devhelp"
|
2022-08-29 11:47:38 +00:00
|
|
|
amove usr/share/devhelp
|
|
|
|
}
|
|
|
|
|
|
|
|
devhelp() {
|
|
|
|
default_devhelp
|
|
|
|
}
|
|
|
|
|
2019-05-02 19:14:46 +00:00
|
|
|
default_bashcomp() {
|
|
|
|
depends=""
|
|
|
|
pkgdesc="Bash completions for $pkgname"
|
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
|
|
|
|
|
|
|
|
cd "$pkgdir" || return 0
|
2020-01-28 10:33:51 +00:00
|
|
|
amove usr/share/bash-completion/completions
|
2019-05-02 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bashcomp() {
|
|
|
|
default_bashcomp
|
|
|
|
}
|
|
|
|
|
|
|
|
default_zshcomp() {
|
|
|
|
depends=""
|
|
|
|
pkgdesc="Zsh completions for $pkgname"
|
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel zsh"
|
|
|
|
|
|
|
|
amove usr/share/zsh/site-functions
|
|
|
|
}
|
|
|
|
|
|
|
|
zshcomp() {
|
|
|
|
default_zshcomp
|
|
|
|
}
|
|
|
|
|
|
|
|
default_fishcomp() {
|
|
|
|
depends=""
|
|
|
|
pkgdesc="Fish completions for $pkgname"
|
|
|
|
install_if="$pkgname=$pkgver-r$pkgrel fish"
|
|
|
|
|
|
|
|
cd "$pkgdir" || return 0
|
2023-06-22 04:04:50 +00:00
|
|
|
|
|
|
|
if [ -d usr/share/fish/vendor_completions.d ]; then
|
|
|
|
amove usr/share/fish/vendor_completions.d
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d usr/share/fish/completions ]; then
|
|
|
|
warning "fish completions for programs should be in /usr/share/fish/vendor_completions.d"
|
|
|
|
amove usr/share/fish/completions
|
|
|
|
fi
|
2019-05-02 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fishcomp() {
|
|
|
|
default_fishcomp
|
|
|
|
}
|
2017-07-25 12:16:23 +00:00
|
|
|
|
abuild: add default_pyc helper
Python by default pre-compiles cache files in __pycache__ directories,
which we currently happily install along in python packages.
Theses .pyc files are rather big and the time/space tradeoff could be
left to users if we just split these out to a -pyc subpackage.
With this default_pyc helper, one can add $pkgname-pyc to their
package's subpackages and it will automatically split off the pyc files
in a package that will be automatically installed if the virtual 'pyc'
package is installed.
Note that this does not work so easily if there already were python
subpackages, the function could be adjusted to strip off the last dash
if required but that seems rather rare.
Random data, sizes:
- python3: currently 47MiB, split into 23M (main package) / 24M (pyc)
- py3-markdown: currently 700KiB, 368K (main) / 288K (pyc)
Random benchmark, with python3-pyc:
hyperfine --warmup 5 -m 100 \
"python3 -c 'import time; print(time.strftime(\"%T\"))'"
Time (mean ± σ): 24.5 ms ± 2.5 ms [User: 18.4 ms, System: 6.0 ms]
Range (min … max): 19.4 ms … 28.9 ms 148 runs
without python3-pyc (same as user without root permissions, root would
generate files on first root, for reference this command generates 184KB
of pyc files):
hyperfine --warmup 5 -m 100 \
-p 'rm -rf /usr/lib/python3.10/__pycache__ /usr/lib/python3.10/encodings/__pycache__' \
"python3 -c 'import time; print(time.strftime(\"%T\"))'"
Time (mean ± σ): 53.7 ms ± 4.3 ms [User: 39.3 ms, System: 14.3 ms]
Range (min … max): 47.0 ms … 65.6 ms 100 runs
Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/11906
Suggested-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
2023-04-18 10:43:20 +00:00
|
|
|
default_pyc() {
|
|
|
|
pkgdesc="Precompiled Python bytecode for ${subpkgname%-pyc}"
|
|
|
|
install_if="${subpkgname%-pyc}=$pkgver-r$pkgrel pyc"
|
|
|
|
|
|
|
|
cd "$pkgdir" || return 0
|
|
|
|
local IFS=$'\n'
|
|
|
|
amove $(find usr/lib/python* -type d -name __pycache__)
|
|
|
|
}
|
|
|
|
|
|
|
|
pyc() {
|
|
|
|
default_pyc
|
|
|
|
}
|
|
|
|
|
2009-10-23 09:57:04 +00:00
|
|
|
is_function() {
|
2022-09-12 15:06:21 +00:00
|
|
|
type "$1" 2>&1 | head -n 1 | grep -E -q "is a (shell )?function"
|
2009-10-23 09:57:04 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 12:23:30 +00:00
|
|
|
do_fakeroot() {
|
|
|
|
if [ -n "$FAKEROOT" ]; then
|
|
|
|
$FAKEROOT -- "$@"
|
|
|
|
else
|
|
|
|
"$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-27 19:38:38 +00:00
|
|
|
# wrap check() with fakeroot
|
|
|
|
check_fakeroot() {
|
|
|
|
cd "$startdir"
|
|
|
|
[ -n "$FAKEROOT" ] && msg "Entering fakeroot..."
|
2022-06-15 12:14:24 +00:00
|
|
|
do_fakeroot "$abuild_path" $forceroot $color_opt $keep_build $verbose check
|
2017-03-27 19:38:38 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
# build and package in fakeroot
|
|
|
|
rootpkg() {
|
2008-10-25 10:18:32 +00:00
|
|
|
cd "$startdir"
|
2013-07-26 09:18:55 +00:00
|
|
|
rm -rf "$pkgdir"
|
2009-10-24 20:53:31 +00:00
|
|
|
[ -n "$FAKEROOT" ] && msg "Entering fakeroot..."
|
2019-11-07 14:13:51 +00:00
|
|
|
|
2022-06-15 12:14:24 +00:00
|
|
|
do_fakeroot "$abuild_path" $forceroot $color_opt $keep_build $verbose \
|
|
|
|
set_source_date \
|
2018-10-03 11:10:55 +00:00
|
|
|
package \
|
2009-10-24 20:53:31 +00:00
|
|
|
prepare_subpackages \
|
2011-01-04 10:32:12 +00:00
|
|
|
prepare_language_packs \
|
2009-10-24 20:53:31 +00:00
|
|
|
prepare_package \
|
2009-10-24 20:37:20 +00:00
|
|
|
create_apks
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
srcpkg() {
|
2016-07-18 19:19:42 +00:00
|
|
|
echo "Ensuring source is fetched"
|
|
|
|
fetch
|
2008-11-06 14:42:24 +00:00
|
|
|
local p="$pkgname-$pkgver-$pkgrel"
|
2008-10-25 10:18:32 +00:00
|
|
|
local prefix="${startdir##*/}"
|
2008-10-18 08:09:24 +00:00
|
|
|
local i files="$prefix/APKBUILD"
|
|
|
|
for i in $source; do
|
2016-07-18 19:19:42 +00:00
|
|
|
echo "Packaging source file: $i"
|
|
|
|
if [ ! -e $(filename_from_uri $i) ]; then
|
|
|
|
cp $srcdir/$(filename_from_uri $i) $(filename_from_uri $i)
|
|
|
|
fi
|
|
|
|
files="$files $prefix/$(filename_from_uri $i)"
|
2008-10-18 08:09:24 +00:00
|
|
|
done
|
2016-07-18 19:19:42 +00:00
|
|
|
|
|
|
|
for i in $install; do
|
|
|
|
echo "Packaging install file: $i"
|
|
|
|
files="$files $prefix/$i"
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in $triggers; do
|
|
|
|
local f=${i%=*}
|
|
|
|
echo "Packaging trigger file: $f"
|
|
|
|
files="$files $prefix/$f"
|
|
|
|
done
|
|
|
|
|
2016-07-26 08:05:17 +00:00
|
|
|
mkdir -p "$REPODEST/src"
|
2008-11-08 10:26:09 +00:00
|
|
|
msg "Creating source package $p.src.tar.gz..."
|
2016-07-26 08:05:17 +00:00
|
|
|
(cd .. && tar -zcf "$REPODEST/src/$p.src.tar.gz" $files)
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 13:27:00 +00:00
|
|
|
# return true if arch is supported or noarch
|
|
|
|
check_arch() {
|
2016-07-07 08:39:03 +00:00
|
|
|
local ret=1
|
|
|
|
local i
|
|
|
|
for i in $arch; do
|
|
|
|
case $i in
|
|
|
|
all | noarch) ret=0 ;;
|
|
|
|
"$CARCH") ret=0 ;;
|
|
|
|
"!$CARCH") return 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
return $ret
|
2010-12-14 13:27:00 +00:00
|
|
|
}
|
|
|
|
|
2008-10-22 21:13:56 +00:00
|
|
|
# check if package is up to date
|
2009-06-03 21:29:58 +00:00
|
|
|
apk_up2date() {
|
2008-10-22 21:13:56 +00:00
|
|
|
local i s
|
2016-07-26 11:32:43 +00:00
|
|
|
for i in $allpackages; do
|
|
|
|
subpkg_set "$i"
|
2024-01-11 21:04:32 +00:00
|
|
|
if [ ! -f "$REPODEST/$repo/$(arch2dir "$subpkgarch")/$subpkgname-$pkgver-r$pkgrel.apk" ]; then
|
2016-07-26 11:32:43 +00:00
|
|
|
subpkg_unset
|
|
|
|
return 1
|
|
|
|
fi
|
2009-01-06 14:52:47 +00:00
|
|
|
done
|
2016-07-26 11:32:43 +00:00
|
|
|
subpkg_unset
|
2009-01-06 14:52:47 +00:00
|
|
|
[ -n "$keep" ] && return 0
|
|
|
|
|
2016-07-26 11:32:43 +00:00
|
|
|
cd "$startdir"
|
2008-10-22 21:13:56 +00:00
|
|
|
for i in $source APKBUILD; do
|
2008-11-25 11:00:29 +00:00
|
|
|
if is_remote "$i"; then
|
2013-02-20 13:38:22 +00:00
|
|
|
s="$SRCDEST/$(filename_from_uri $i)"
|
2008-11-25 11:00:29 +00:00
|
|
|
else
|
|
|
|
s="$startdir/${i##*/}"
|
|
|
|
fi
|
2024-01-11 21:04:32 +00:00
|
|
|
if [ "$s" -nt "$REPODEST/$repo/$(arch2dir "$pkgarch")/$pkgname-$pkgver-r$pkgrel.apk" ]; then
|
2008-10-22 21:13:56 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2010-05-06 08:20:59 +00:00
|
|
|
abuildindex_up2date() {
|
2011-04-04 11:18:29 +00:00
|
|
|
local i
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2016-07-26 11:32:43 +00:00
|
|
|
for i in $allpackages; do
|
|
|
|
subpkg_set "$i"
|
2024-01-11 21:04:32 +00:00
|
|
|
local dir="$REPODEST/$repo/$(arch2dir "$subpkgarch")"
|
2016-07-26 11:32:43 +00:00
|
|
|
local idx="$dir"/APKINDEX.tar.gz
|
|
|
|
local file="$dir"/$subpkgname-$pkgver-r$pkgrel.apk
|
2011-04-04 13:00:22 +00:00
|
|
|
|
2016-07-26 11:32:43 +00:00
|
|
|
# if any file is missing or .apk is newer then index
|
|
|
|
# the index needs to be updated
|
|
|
|
if [ ! -f "$idx" -o ! -f "$file" -o "$file" -nt "$idx" ]; then
|
|
|
|
subpkg_unset
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
subpkg_unset
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2009-06-03 21:29:58 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
up2date() {
|
2010-12-14 13:27:00 +00:00
|
|
|
check_arch || return 0
|
2010-05-06 08:20:59 +00:00
|
|
|
apk_up2date && abuildindex_up2date
|
|
|
|
}
|
|
|
|
|
2016-07-27 10:17:19 +00:00
|
|
|
calcdeps() {
|
|
|
|
builddeps=
|
|
|
|
hostdeps=
|
2009-02-17 07:39:06 +00:00
|
|
|
|
2013-09-05 08:40:59 +00:00
|
|
|
if cross_compiling && [ -n "$makedepends_build" -o -n "$makedepends_host" ]; then
|
2017-02-16 13:17:11 +00:00
|
|
|
for i in $EXTRADEPENDS_BUILD $1 $makedepends_build; do
|
2016-07-27 10:17:19 +00:00
|
|
|
list_has $i $hostdeps && continue
|
|
|
|
builddeps="$builddeps $i"
|
2013-09-05 08:21:29 +00:00
|
|
|
done
|
2017-02-24 06:55:13 +00:00
|
|
|
for i in $EXTRADEPENDS_HOST $EXTRADEPENDS_TARGET $makedepends_host; do
|
2024-04-01 14:58:22 +00:00
|
|
|
[ "$pkgname" = "${i%%[<>=~]*}" ] && continue
|
2016-07-27 10:17:19 +00:00
|
|
|
list_has $i $hostdeps && continue
|
2024-04-01 14:58:22 +00:00
|
|
|
subpackages_has ${i%%[<>=~]*} || hostdeps="$hostdeps $i"
|
2013-09-05 08:21:29 +00:00
|
|
|
done
|
|
|
|
else
|
2016-07-27 10:17:19 +00:00
|
|
|
[ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
|
2017-01-29 09:47:25 +00:00
|
|
|
want_check && makedepends="$makedepends $checkdepends"
|
2017-02-16 13:17:11 +00:00
|
|
|
for i in $EXTRADEPENDS_BUILD $EXTRADEPENDS_HOST $1 $depends $makedepends; do
|
2024-04-01 14:58:22 +00:00
|
|
|
[ "$pkgname" = "${i%%[<>=~]*}" ] && continue
|
2016-07-27 10:17:19 +00:00
|
|
|
list_has $i $builddeps && continue
|
2024-04-01 14:58:22 +00:00
|
|
|
subpackages_has ${i%%[<>=~]*} || builddeps="$builddeps $i"
|
2013-09-05 08:21:29 +00:00
|
|
|
done
|
2017-02-16 13:17:11 +00:00
|
|
|
hostdeps="$EXTRADEPENDS_TARGET"
|
2013-09-05 08:21:29 +00:00
|
|
|
fi
|
2016-07-27 10:17:19 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 15:23:31 +00:00
|
|
|
get_missing_deps() {
|
|
|
|
local cmd="$APK info --quiet --installed $1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
while [ "$1" ]; do
|
|
|
|
local cp=${1#\!}
|
|
|
|
if [ $cp != $1 ]; then
|
|
|
|
if $cmd $cp; then
|
|
|
|
error "Conflicting package installed: $cp"
|
|
|
|
return 1
|
|
|
|
fi
|
2019-08-07 09:05:36 +00:00
|
|
|
elif ! $cmd $1; then
|
2017-03-06 15:23:31 +00:00
|
|
|
echo $1
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-05-30 08:54:10 +00:00
|
|
|
apk_add_makedeps() {
|
|
|
|
local prefix=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
local repo_args="--repository $(shell_escape "$REPODEST/$repo")"
|
|
|
|
[ -s "$repo_template" ] && repo_args=$(while read r; do
|
|
|
|
echo --repository "$(shell_escape "$REPODEST/${r##*/}")"
|
|
|
|
done) < "$repo_template"
|
|
|
|
|
|
|
|
eval $SUDO_APK add $apk_opt_wait $repo_args \
|
|
|
|
--virtual .${prefix}depends-$pkgname "\$@" || return
|
|
|
|
}
|
|
|
|
|
2016-07-27 10:17:19 +00:00
|
|
|
# build and install dependencies
|
|
|
|
builddeps() {
|
2017-03-06 15:23:31 +00:00
|
|
|
local pkg= i= BUILD_BASE=
|
2016-07-27 10:17:19 +00:00
|
|
|
[ -n "$nodeps" ] && return 0
|
|
|
|
|
|
|
|
msg "Analyzing dependencies..."
|
2017-02-24 08:16:55 +00:00
|
|
|
case "$BOOTSTRAP" in
|
|
|
|
no*) BUILD_BASE="";;
|
|
|
|
*) if cross_creating || cross_compiling; then
|
|
|
|
BUILD_BASE="build-base-$CTARGET_ARCH"
|
|
|
|
else
|
|
|
|
BUILD_BASE="build-base"
|
|
|
|
fi
|
|
|
|
esac
|
2016-07-27 10:17:19 +00:00
|
|
|
calcdeps "$BUILD_BASE"
|
2013-09-05 08:21:29 +00:00
|
|
|
|
2021-11-18 06:34:48 +00:00
|
|
|
# shall ccache be added?
|
|
|
|
[ -n "$USE_CCACHE" ] && builddeps="$builddeps ccache"
|
|
|
|
|
2009-02-17 07:39:06 +00:00
|
|
|
# find which deps are missing
|
2017-03-06 15:23:31 +00:00
|
|
|
local mbd mhd missing
|
|
|
|
mbd=$(get_missing_deps "" $builddeps) || return 1
|
|
|
|
mhd=$(get_missing_deps "--root $CBUILDROOT --arch $CTARGET_ARCH" $hostdeps) || return 1
|
|
|
|
missing=$(echo $mbd $mhd)
|
2013-07-02 07:18:11 +00:00
|
|
|
|
2019-08-07 09:05:36 +00:00
|
|
|
if [ -z "$install_deps" ]; then
|
2010-05-06 19:37:52 +00:00
|
|
|
# if we dont have any missing deps we are done now
|
|
|
|
[ -z "$missing" ] && return 0
|
2019-08-07 09:05:36 +00:00
|
|
|
error "Missing dependencies (use -r to autoinstall them): $missing"
|
2010-05-06 19:37:52 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2009-02-02 15:48:19 +00:00
|
|
|
|
2009-06-03 08:37:05 +00:00
|
|
|
uninstall_after=".makedepends-$pkgname $uninstall_after"
|
2019-08-07 09:05:36 +00:00
|
|
|
# make a --simulate run first to detect missing deps
|
|
|
|
# apk-tools --virtual is no goot at reporting those.
|
|
|
|
deps "--quiet --simulate" || return 1
|
|
|
|
deps || return 1
|
2008-11-07 20:54:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 08:28:58 +00:00
|
|
|
# replace the md5sums in the APKBUILD
|
2008-11-25 10:44:32 +00:00
|
|
|
checksum() {
|
|
|
|
local s files
|
2012-11-29 10:09:47 +00:00
|
|
|
[ -z "$source" ] && [ -n "${md5sums}${sha256sums}${sha512sums}" ] \
|
2022-07-03 06:11:32 +00:00
|
|
|
&& msg "Removing checksums from $APKBUILD"
|
2020-06-07 21:29:50 +00:00
|
|
|
sed -E -i \
|
2018-10-03 10:31:09 +00:00
|
|
|
-e '/^(md5|sha[0-9]+)sums=".*"$/d' \
|
2020-06-07 21:29:50 +00:00
|
|
|
-e '/^(md5|sha[0-9]+)sums="/,/"$/d' \
|
2018-10-03 10:31:09 +00:00
|
|
|
\
|
|
|
|
-e "/^(md5|sha[0-9]+)sums='.*'\$/d" \
|
2020-06-07 21:29:50 +00:00
|
|
|
-e "/^(md5|sha[0-9]+)sums='/,/'\$/d" \
|
2022-07-03 06:11:32 +00:00
|
|
|
"$APKBUILD"
|
2018-10-03 10:31:09 +00:00
|
|
|
|
2009-02-20 09:08:26 +00:00
|
|
|
[ -z "$source" ] && return 0
|
2008-11-25 10:44:32 +00:00
|
|
|
fetch
|
|
|
|
for s in $source; do
|
2021-04-28 11:02:28 +00:00
|
|
|
local name="$(filename_from_uri $s)"
|
|
|
|
case " $files " in
|
|
|
|
*" $name "*) die "duplicate found in \$source: $name";;
|
|
|
|
esac
|
|
|
|
files="$files $name"
|
2008-11-25 10:44:32 +00:00
|
|
|
done
|
2012-11-29 10:09:47 +00:00
|
|
|
|
2022-07-03 06:11:32 +00:00
|
|
|
msg "Updating the sha512sums in $APKBUILD..."
|
2017-02-17 10:07:15 +00:00
|
|
|
md5sums=
|
|
|
|
sha256sums=
|
2012-11-29 10:09:47 +00:00
|
|
|
sha512sums="$(cd "$srcdir" && sha512sum $files)" \
|
|
|
|
|| die "sha512sum failed"
|
2020-06-07 21:29:50 +00:00
|
|
|
printf 'sha512sums="\n%s\n"\n' "$sha512sums" >>"$APKBUILD"
|
2008-11-25 10:44:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-16 16:14:19 +00:00
|
|
|
rootbld_actions() {
|
2018-10-03 12:29:57 +00:00
|
|
|
local part _check=check
|
|
|
|
if options_has "checkroot"; then
|
|
|
|
_check=check_fakeroot
|
2017-11-10 21:34:27 +00:00
|
|
|
fi
|
|
|
|
if ! want_check; then
|
|
|
|
_check=true
|
|
|
|
fi
|
2023-06-22 19:53:46 +00:00
|
|
|
for part in symlinksrc unpack prepare build $_check rootpkg; do
|
2017-07-16 16:14:19 +00:00
|
|
|
runpart $part
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-09-18 20:23:17 +00:00
|
|
|
rootbld_qemu_arch() {
|
|
|
|
local qarch=""
|
|
|
|
|
|
|
|
case "$CBUILD_ARCH" in
|
|
|
|
arm*) qarch="arm" ;;
|
|
|
|
x86) qarch="i386" ;;
|
2023-04-15 19:36:22 +00:00
|
|
|
*) qarch="$CBUILD_ARCH" ;;
|
2021-09-18 20:23:17 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
echo "${qarch}"
|
|
|
|
}
|
|
|
|
|
2017-04-05 13:28:13 +00:00
|
|
|
rootbld() {
|
|
|
|
if apk_up2date && [ -z "$force" ]; then
|
|
|
|
msg "Package is up to date"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2024-04-10 10:29:35 +00:00
|
|
|
$APK info -eq abuild-rootbld || die "rootbld: abuild-rootbld package not installed"
|
2017-04-05 13:28:13 +00:00
|
|
|
|
2021-06-09 14:43:18 +00:00
|
|
|
[ $CBUILD = $CHOST ] || die "rootbld: set CBUILD=$CHOST to build for $CHOST"
|
2023-06-01 04:11:43 +00:00
|
|
|
|
2024-04-10 10:12:20 +00:00
|
|
|
local cachedir=/etc/apk/cache
|
2024-04-10 10:29:35 +00:00
|
|
|
if ! [ $CBUILD_ARCH = "$($APK --print-arch)" ]; then
|
2023-06-01 04:11:43 +00:00
|
|
|
# cross-building, so check for binfmt registration
|
2023-06-01 07:29:59 +00:00
|
|
|
local qarch="$(rootbld_qemu_arch)"
|
2023-07-03 02:45:13 +00:00
|
|
|
if ! [ -f "/proc/sys/fs/binfmt_misc/qemu-$qarch" ]; then
|
2023-06-01 07:29:59 +00:00
|
|
|
warning "rootbld: binfmt registration missing for $qarch binaries"
|
2023-06-01 04:11:43 +00:00
|
|
|
fi
|
2024-04-10 10:12:20 +00:00
|
|
|
# Old versions of apk have cache conflicts
|
|
|
|
$APK info -eq 'cmd:apk>=2.14.1' || cachedir=""
|
2023-06-01 04:11:43 +00:00
|
|
|
fi
|
2021-06-09 14:43:18 +00:00
|
|
|
|
2017-04-05 13:28:13 +00:00
|
|
|
logcmd "chroot building building $repo/$pkgname-$pkgver-r$pkgrel"
|
|
|
|
|
|
|
|
# check early if we have abuild key
|
|
|
|
abuild-sign --installed
|
|
|
|
|
2019-11-13 17:15:28 +00:00
|
|
|
# make sure SOURCE_DATE_EPOCH is set
|
|
|
|
set_source_date
|
|
|
|
|
2017-04-05 13:28:13 +00:00
|
|
|
# networking business
|
|
|
|
sanitycheck
|
|
|
|
clean
|
|
|
|
fetch
|
|
|
|
verify
|
|
|
|
|
|
|
|
msg "Preparing build chroot..."
|
|
|
|
|
2023-06-22 19:53:46 +00:00
|
|
|
# Unfortunately, we can't create the users inside the chroot.
|
|
|
|
# Hence, we need to do it on the host which is not optimal as it
|
|
|
|
# pollutes the host's /etc/group and /etc/passwd file.
|
|
|
|
#
|
|
|
|
# See https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10094
|
|
|
|
mkusers
|
|
|
|
|
2020-04-17 10:21:48 +00:00
|
|
|
BUILD_ROOT=$(mktemp -d /var/tmp/abuild.XXXXXXXXXX)
|
2017-04-05 13:28:13 +00:00
|
|
|
|
|
|
|
mkdir -p "$BUILD_ROOT/proc" "$BUILD_ROOT/etc/apk/keys" \
|
2022-12-14 22:00:19 +00:00
|
|
|
"$BUILD_ROOT/$ABUILD_USERDIR" "$BUILD_ROOT/$aportsgit" \
|
2017-04-05 13:28:13 +00:00
|
|
|
"$BUILD_ROOT/$SRCDEST" "$BUILD_ROOT/$REPODEST" \
|
|
|
|
"$BUILD_ROOT/tmp/pkg" "$BUILD_ROOT/tmp/src" \
|
|
|
|
"$BUILD_ROOT/usr/bin" "$pkgbasedir" "$REPODEST" \
|
2019-07-20 01:14:20 +00:00
|
|
|
"$BUILD_ROOT/$HOME/.ccache" \
|
2017-04-05 13:28:13 +00:00
|
|
|
"$srcdir"
|
|
|
|
|
2017-07-06 14:41:37 +00:00
|
|
|
cp /etc/abuild.conf /etc/group /etc/passwd "$BUILD_ROOT/etc"
|
2021-06-09 14:43:18 +00:00
|
|
|
|
|
|
|
local dir
|
|
|
|
for dir in /usr/share/apk/keys/$CBUILD_ARCH /etc/apk/keys; do
|
|
|
|
cp $dir/* "$BUILD_ROOT/etc/apk/keys"
|
|
|
|
done
|
2017-04-05 13:28:13 +00:00
|
|
|
|
2018-03-08 00:48:04 +00:00
|
|
|
if options_has "net"; then
|
|
|
|
cp /etc/resolv.conf "$BUILD_ROOT/etc"
|
|
|
|
fi
|
|
|
|
|
2017-09-27 11:58:56 +00:00
|
|
|
local version="edge" buildhost="edge" gitref
|
2023-04-18 17:42:30 +00:00
|
|
|
if gitref="$(expr "$($git symbolic-ref --short HEAD)" : '\([0-9]\+\(\.[0-9]\+\)*\)-')"; then
|
2017-09-27 11:58:56 +00:00
|
|
|
version=v${gitref}
|
|
|
|
buildhost=${gitref/./-}
|
|
|
|
fi
|
|
|
|
|
2017-05-28 16:13:20 +00:00
|
|
|
[ -s "$repo_template" ] || die "rootbld: $repo_template does not exist"
|
|
|
|
(
|
|
|
|
for key in $(git config --list --name-only); do
|
|
|
|
k=${key#abuild.}
|
|
|
|
[ $k != $key ] && \
|
|
|
|
eval "export $k=\"$(git config --get $key)\""
|
|
|
|
done
|
|
|
|
|
|
|
|
export mirror version
|
|
|
|
[ "$mirror" ] || mirror=http://dl-cdn.alpinelinux.org/alpine
|
|
|
|
|
2022-08-07 15:23:54 +00:00
|
|
|
envsubst | while read -r repository; do
|
|
|
|
echo "$repository"
|
|
|
|
echo "$REPODEST/${repository##*/}"
|
|
|
|
done
|
2017-05-28 16:13:20 +00:00
|
|
|
) < "$repo_template" > "$BUILD_ROOT/etc/apk/repositories"
|
2017-04-05 13:28:13 +00:00
|
|
|
|
|
|
|
calcdeps
|
2021-06-09 14:43:18 +00:00
|
|
|
$SUDO_APK add --initdb --update \
|
|
|
|
--arch $CBUILD_ARCH \
|
|
|
|
--root "$BUILD_ROOT" \
|
2023-06-01 04:11:43 +00:00
|
|
|
${cachedir:+--cache-dir $cachedir} \
|
2019-10-01 12:49:49 +00:00
|
|
|
abuild alpine-base build-base git $hostdeps $builddeps \
|
|
|
|
${USE_CCACHE:+ccache}
|
2017-04-05 13:28:13 +00:00
|
|
|
|
|
|
|
local bwrap_opts=""
|
|
|
|
options_has "net" || bwrap_opts="$bwrap_opts --unshare-net"
|
2023-03-14 11:06:05 +00:00
|
|
|
bwrap --new-session --unshare-ipc --unshare-uts $bwrap_opts \
|
2017-04-05 13:28:13 +00:00
|
|
|
--ro-bind "$BUILD_ROOT" / \
|
|
|
|
--proc /proc \
|
|
|
|
--dev-bind /dev /dev \
|
2017-11-15 00:11:14 +00:00
|
|
|
--bind "$BUILD_ROOT/$HOME" "$HOME" \
|
2022-12-14 22:00:19 +00:00
|
|
|
--ro-bind "$ABUILD_USERDIR" "$ABUILD_USERDIR" \
|
2017-04-05 13:28:13 +00:00
|
|
|
--ro-bind "$aportsgit" "$aportsgit" \
|
2019-10-01 12:49:49 +00:00
|
|
|
${USE_CCACHE:+ --bind "$HOME/.ccache" "$HOME/.ccache"} \
|
2017-04-05 13:28:13 +00:00
|
|
|
--bind "$SRCDEST" "$SRCDEST" \
|
2017-11-08 05:18:10 +00:00
|
|
|
--bind "$BUILD_ROOT/tmp" /tmp \
|
2017-04-05 13:28:13 +00:00
|
|
|
--bind "$BUILD_ROOT/tmp/src" "$srcdir" \
|
|
|
|
--bind "$BUILD_ROOT/tmp/pkg" "$pkgbasedir" \
|
|
|
|
--bind "$REPODEST" "$REPODEST" \
|
2017-09-27 11:58:56 +00:00
|
|
|
--hostname "build-$buildhost-$CARCH" \
|
2017-04-05 13:28:13 +00:00
|
|
|
--chdir "$startdir" \
|
2023-01-21 00:30:39 +00:00
|
|
|
--clearenv \
|
2023-05-26 21:19:28 +00:00
|
|
|
--setenv CARCH "$CARCH" \
|
2023-01-21 00:30:39 +00:00
|
|
|
--setenv HOME "$HOME" \
|
2023-04-16 12:25:42 +00:00
|
|
|
--setenv REPODEST "$REPODEST" \
|
2024-04-25 22:20:25 +00:00
|
|
|
--setenv SRCDEST "$SRCDEST" \
|
2024-03-28 11:50:53 +00:00
|
|
|
--setenv ABUILD_USERDIR "$ABUILD_USERDIR" \
|
2023-04-15 08:10:07 +00:00
|
|
|
${ABUILD_BOOTSTRAP:+--setenv ABUILD_BOOTSTRAP "$ABUILD_BOOTSTRAP"} \
|
2024-04-19 21:41:45 +00:00
|
|
|
${APORTS_BOOTSTRAP:+--setenv APORTS_BOOTSTRAP "$APORTS_BOOTSTRAP"} \
|
2023-01-21 00:30:39 +00:00
|
|
|
--setenv SOURCE_DATE_EPOCH "$SOURCE_DATE_EPOCH" \
|
|
|
|
--setenv ABUILD_LAST_COMMIT "$ABUILD_LAST_COMMIT" \
|
2019-10-01 13:13:43 +00:00
|
|
|
--setenv PATH ${USE_CCACHE:+/usr/lib/ccache/bin:}/bin:/usr/bin:/sbin:/usr/sbin \
|
2020-12-21 21:00:19 +00:00
|
|
|
--setenv FAKEROOTDONTTRYCHOWN 1 \
|
2021-06-09 14:43:18 +00:00
|
|
|
--unsetenv CBUILD \
|
2017-07-16 16:14:19 +00:00
|
|
|
/usr/bin/abuild $force rootbld_actions
|
2017-04-05 13:28:13 +00:00
|
|
|
update_abuildrepo_index
|
|
|
|
cleanup $CLEANUP
|
|
|
|
}
|
|
|
|
|
2008-11-25 14:07:40 +00:00
|
|
|
stripbin() {
|
2009-01-07 19:13:03 +00:00
|
|
|
local bin
|
2016-07-23 06:18:27 +00:00
|
|
|
if options_has "!strip" || [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
|
2010-12-30 12:53:44 +00:00
|
|
|
return 0
|
|
|
|
fi
|
2008-11-25 14:07:40 +00:00
|
|
|
cd "${subpkgdir:-$pkgdir}" || return 1
|
2016-07-25 05:50:20 +00:00
|
|
|
|
|
|
|
local stripcmd=strip
|
|
|
|
case "${subpkgarch:-$pkgarch}" in
|
|
|
|
$CBUILD_ARCH) stripcmd="strip" ;;
|
|
|
|
$CARCH) stripcmd="${CHOST}-strip" ;;
|
|
|
|
$CTARGET_ARCH) stripcmd="${CTARGET}-strip" ;;
|
|
|
|
esac
|
|
|
|
|
2008-11-25 14:07:40 +00:00
|
|
|
msg "Stripping binaries"
|
2017-09-26 07:26:02 +00:00
|
|
|
scanelf --recursive --nobanner --osabi --etype "ET_DYN,ET_EXEC" . \
|
|
|
|
| while read type osabi filename; do
|
2018-05-31 14:37:31 +00:00
|
|
|
|
|
|
|
# scanelf may have picked up a temp file so verify that file still exists
|
|
|
|
[ -e "$filename" ] || continue
|
|
|
|
|
2017-09-26 07:26:02 +00:00
|
|
|
[ "$osabi" != "STANDALONE" ] || continue
|
2017-02-09 11:30:03 +00:00
|
|
|
local XATTR=$(getfattr --match="" --dump "${filename}")
|
2016-07-25 05:50:20 +00:00
|
|
|
"${stripcmd}" "${filename}"
|
2017-02-21 15:44:15 +00:00
|
|
|
if [ -n "$XATTR" ]; then
|
2021-04-28 08:33:23 +00:00
|
|
|
echo "$XATTR" | "$SETFATTR" --restore=-
|
2017-02-21 15:44:15 +00:00
|
|
|
fi
|
2014-11-01 15:09:34 +00:00
|
|
|
done
|
2008-11-25 14:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 09:04:15 +00:00
|
|
|
# simply list target apks
|
|
|
|
listpkg() {
|
2011-01-04 10:32:12 +00:00
|
|
|
local name
|
2016-07-26 11:32:43 +00:00
|
|
|
for name in $allpackages ; do
|
|
|
|
subpkg_set $name
|
|
|
|
echo "$subpkgname-$pkgver-r$pkgrel.apk"
|
2009-01-03 09:04:15 +00:00
|
|
|
done
|
2016-07-26 11:32:43 +00:00
|
|
|
subpkg_unset
|
2009-01-03 09:04:15 +00:00
|
|
|
}
|
|
|
|
|
2009-02-08 21:02:22 +00:00
|
|
|
source_has() {
|
|
|
|
local i
|
|
|
|
for i in $source; do
|
|
|
|
[ "$1" = "${i##*/}" ] && return 0
|
2013-02-20 13:38:22 +00:00
|
|
|
[ "$1" = "${i%%::*}" ] && return 0
|
2009-02-08 21:02:22 +00:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-01-20 10:33:11 +00:00
|
|
|
subpackages_has() {
|
|
|
|
local i
|
|
|
|
for i in $subpackages; do
|
2016-07-26 10:02:24 +00:00
|
|
|
[ "$1" = "${i%%:*}" ] && return 0
|
2009-01-20 10:33:11 +00:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2014-01-16 13:33:45 +00:00
|
|
|
subpackage_types_has() {
|
|
|
|
local i
|
|
|
|
for i in $subpackages; do
|
2016-07-26 10:02:24 +00:00
|
|
|
local _name="${i%%:*}"
|
|
|
|
[ "$1" = "${_name##*-}" ] && return 0
|
2014-01-16 13:33:45 +00:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-02-05 10:35:29 +00:00
|
|
|
list_has() {
|
|
|
|
local needle="$1"
|
|
|
|
local i
|
|
|
|
shift
|
|
|
|
for i in $@; do
|
|
|
|
[ "$needle" = "$i" ] && return 0
|
|
|
|
[ "$needle" = "!$i" ] && return 1
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-08-05 13:55:35 +00:00
|
|
|
# same as list_has but we filter version info
|
|
|
|
deplist_has() {
|
|
|
|
local needle="$1"
|
|
|
|
local i
|
|
|
|
shift
|
|
|
|
for i in $@; do
|
2024-04-01 14:58:22 +00:00
|
|
|
i=${i%%[<>=~]*}
|
2009-08-05 13:55:35 +00:00
|
|
|
[ "$needle" = "$i" ] && return 0
|
|
|
|
[ "$needle" = "!$i" ] && return 1
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-02-05 10:35:29 +00:00
|
|
|
options_has() {
|
|
|
|
list_has "$1" $options
|
|
|
|
}
|
|
|
|
|
2009-02-20 09:08:26 +00:00
|
|
|
depends_has() {
|
2009-08-05 13:55:35 +00:00
|
|
|
deplist_has "$1" $depends
|
2009-02-20 09:08:26 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 09:13:46 +00:00
|
|
|
makedepends_has() {
|
2009-08-05 13:55:35 +00:00
|
|
|
deplist_has "$1" $makedepends
|
2009-03-26 09:13:46 +00:00
|
|
|
}
|
|
|
|
|
2009-02-08 21:02:22 +00:00
|
|
|
md5sums_has() {
|
|
|
|
list_has "$1" $md5sums
|
|
|
|
}
|
|
|
|
|
2009-08-13 19:33:12 +00:00
|
|
|
install_has() {
|
|
|
|
list_has "$1" $install
|
|
|
|
}
|
|
|
|
|
2013-07-26 11:04:40 +00:00
|
|
|
deps() {
|
2016-07-27 10:17:19 +00:00
|
|
|
[ -z "$hostdeps" -a -z "$builddeps" ] && calcdeps
|
|
|
|
|
|
|
|
local _quiet="$1"
|
|
|
|
[ -z "$_quiet" ] && msg "Installing for build:$builddeps"
|
2019-05-30 08:54:10 +00:00
|
|
|
apk_add_makedeps make $_quiet $builddeps || return 1
|
2016-07-27 10:17:19 +00:00
|
|
|
if [ -n "$CBUILDROOT" ]; then
|
|
|
|
[ -z "$_quiet" ] && msg "Installing for host:$hostdeps"
|
2019-05-30 08:54:10 +00:00
|
|
|
apk_add_makedeps host $_quiet --no-scripts \
|
|
|
|
--root "$CBUILDROOT" --arch "$CTARGET_ARCH" $hostdeps \
|
|
|
|
|| return 1
|
2016-07-27 10:17:19 +00:00
|
|
|
fi
|
2009-04-01 12:43:05 +00:00
|
|
|
}
|
|
|
|
|
2016-07-27 10:17:19 +00:00
|
|
|
undeps() {
|
|
|
|
local _quiet="$@"
|
2017-02-21 15:44:15 +00:00
|
|
|
$SUDO_APK del $_quiet $apk_opt_wait .makedepends-$pkgname || :
|
2016-07-27 10:17:19 +00:00
|
|
|
if [ -n "$CBUILDROOT" ]; then
|
2016-12-21 10:01:29 +00:00
|
|
|
$SUDO_APK del $_quiet --root "$CBUILDROOT" --arch "$CTARGET_ARCH" $apk_opt_wait \
|
2019-07-29 18:42:35 +00:00
|
|
|
--no-scripts .hostdepends-$pkgname || :
|
2013-09-05 08:40:59 +00:00
|
|
|
fi
|
2009-04-01 12:43:05 +00:00
|
|
|
}
|
2009-06-03 21:29:58 +00:00
|
|
|
|
2013-07-26 11:04:40 +00:00
|
|
|
# compat
|
|
|
|
installdeps() { deps; }
|
|
|
|
uninstalldeps() { undeps; }
|
2014-09-25 07:43:39 +00:00
|
|
|
index() { update_abuildrepo_index; }
|
2013-07-26 11:04:40 +00:00
|
|
|
|
2009-06-03 21:29:58 +00:00
|
|
|
all() {
|
2024-04-09 21:05:40 +00:00
|
|
|
if ! [ -n "$force" ] && ! check_arch; then
|
|
|
|
echo "Package not available for the target architecture ($CARCH). Aborting."
|
|
|
|
return 0
|
2011-01-09 12:50:16 +00:00
|
|
|
fi
|
2009-06-03 21:29:58 +00:00
|
|
|
if up2date && [ -z "$force" ]; then
|
|
|
|
msg "Package is up to date"
|
|
|
|
else
|
2013-02-07 15:29:53 +00:00
|
|
|
build_abuildrepo
|
2009-06-03 21:29:58 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-01-07 23:40:53 +00:00
|
|
|
# This abuild hook will checkout an svn or git repository by specifying
|
2022-12-01 16:15:47 +00:00
|
|
|
# $giturl in APKBUILD. You can checkout a specific branch in
|
2013-01-07 23:40:53 +00:00
|
|
|
# git by adding -b $branch in $giturl. $reporev will select the correct
|
|
|
|
# commit, revision or tag for you. If you specify $disturl your distfile
|
|
|
|
# will automatically be uploaded with rsync to the url provided.
|
2014-02-18 08:42:01 +00:00
|
|
|
# Base version defaults to 0 except if specified by $verbase.
|
2013-01-07 23:40:53 +00:00
|
|
|
|
|
|
|
snapshot() {
|
2016-02-01 22:32:29 +00:00
|
|
|
# check if we setup vars correctly
|
|
|
|
[ -z "$disturl" ] && warning "Missing disturl in APKBUILD, auto uploading disabled."
|
2022-12-01 16:15:47 +00:00
|
|
|
[ -z "$giturl" ] && die "Missing repository url in APKBUILD!"
|
2016-02-01 22:32:29 +00:00
|
|
|
local _date=$(date +%Y%m%d)
|
2013-01-07 23:40:53 +00:00
|
|
|
local _format="tar.gz"
|
2016-02-01 22:32:29 +00:00
|
|
|
# remove any repositories left in srcdir
|
2020-01-30 11:30:48 +00:00
|
|
|
"$abuild_path" $forceroot clean
|
2016-02-01 22:32:29 +00:00
|
|
|
mkdir -p "$srcdir" && cd "$srcdir"
|
|
|
|
# clone git repo and archive
|
|
|
|
if [ -n "$giturl" ]; then
|
|
|
|
local _version=${verbase:-0}_git${_date}
|
2018-04-13 14:34:34 +00:00
|
|
|
[ "$git" = "true" ] && die "Missing git! Install git to support git clone."
|
2016-02-11 13:26:08 +00:00
|
|
|
local _rev="${reporev:-HEAD}"
|
|
|
|
[ "$_rev" = "HEAD" ] && local _depth="--depth=1"
|
2016-02-01 22:32:29 +00:00
|
|
|
msg "Creating git snapshot: $pkgname-$_version"
|
|
|
|
git clone $_depth --bare $giturl $pkgname-$_version || return 1
|
|
|
|
git --git-dir $pkgname-$_version archive \
|
2013-01-07 23:40:53 +00:00
|
|
|
--format=$_format \
|
2016-02-01 22:32:29 +00:00
|
|
|
-o $pkgname-$_version.$_format \
|
|
|
|
--prefix=$pkgname-$_version/ $_rev \
|
|
|
|
|| return 1
|
|
|
|
fi
|
|
|
|
# upload to defined distfiles url
|
|
|
|
if [ -n "$disturl" ]; then
|
|
|
|
command -v rsync >/dev/null || \
|
|
|
|
die "Missing rsync! Install rsync to enable automatic uploads."
|
|
|
|
msg "Uploading to $disturl"
|
|
|
|
rsync --progress -La $pkgname-$_version.$_format \
|
|
|
|
$disturl || return 1
|
|
|
|
cd "$startdir"
|
|
|
|
# set the pkgver to current date and update checksum
|
|
|
|
sed -i -e "s/^pkgver=.*/pkgver=${_version}/" \
|
|
|
|
APKBUILD || return 1
|
2020-01-30 11:30:48 +00:00
|
|
|
"$abuild_path" $forceroot checksum
|
2016-02-01 22:32:29 +00:00
|
|
|
fi
|
2013-01-07 23:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-10-18 08:09:24 +00:00
|
|
|
usage() {
|
2016-08-20 13:16:48 +00:00
|
|
|
cat <<-EOF
|
2017-06-21 17:51:00 +00:00
|
|
|
usage: $program [options] [-P REPODEST] [-s SRCDEST] [-D DESCRIPTION] [cmd] ...
|
2016-08-20 13:16:48 +00:00
|
|
|
$program [-c] -n PKGNAME[-PKGVER]
|
|
|
|
Options:
|
|
|
|
-A Print CARCH and exit
|
|
|
|
-c Enable colored output
|
|
|
|
-d Disable dependency checking
|
2017-06-21 17:51:00 +00:00
|
|
|
-D Set APKINDEX description (default: \$repo \$(git describe))
|
2024-04-09 21:05:40 +00:00
|
|
|
-f Force specified cmd (skip checks: apk up to date, arch)
|
2016-08-20 13:16:48 +00:00
|
|
|
-F Force run as root
|
|
|
|
-h Show this help
|
|
|
|
-k Keep built packages, even if APKBUILD or sources are newer
|
|
|
|
-K Keep buildtime temp dirs and files (srcdir/pkgdir/deps)
|
|
|
|
-m Disable colors (monochrome)
|
|
|
|
-P Set REPODEST as the repository location for created packages
|
|
|
|
-q Quiet
|
2024-03-28 12:24:27 +00:00
|
|
|
-r Install missing dependencies from system repository (using \$SUDO_APK)
|
2016-08-20 13:16:48 +00:00
|
|
|
-s Set source package destination directory
|
2017-06-12 04:56:28 +00:00
|
|
|
-v Verbose: show every command as it is run (very noisy)
|
2016-08-20 13:16:48 +00:00
|
|
|
|
|
|
|
Commands:
|
|
|
|
build Compile and install package into \$pkgdir
|
2017-01-29 09:47:25 +00:00
|
|
|
check Run any defined tests concerning the package
|
2016-08-20 13:16:48 +00:00
|
|
|
checksum Generate checksum to be included in APKBUILD
|
|
|
|
clean Remove temp build and install dirs
|
|
|
|
cleancache Remove downloaded files from \$SRCDEST
|
|
|
|
cleanoldpkg Remove binary packages except current version
|
|
|
|
cleanpkg Remove already built binary and source package
|
|
|
|
deps Install packages listed in makedepends and depends
|
2019-05-17 20:38:25 +00:00
|
|
|
fetch Fetch sources to \$SRCDEST (consider: 'abuild fetch verify')
|
2016-08-20 13:16:48 +00:00
|
|
|
index Regenerate indexes in \$REPODEST
|
|
|
|
listpkg List target packages
|
2024-03-28 12:24:27 +00:00
|
|
|
package Install project into \$pkgdir
|
2016-08-20 13:16:48 +00:00
|
|
|
prepare Apply patches
|
2017-04-05 13:28:13 +00:00
|
|
|
rootbld Build package in clean chroot
|
2016-08-20 13:16:48 +00:00
|
|
|
rootpkg Run 'package', the split functions and create apks as fakeroot
|
|
|
|
sanitycheck Basic sanity check of APKBUILD
|
2022-12-01 16:15:47 +00:00
|
|
|
snapshot Create a \$giturl snapshot and upload to \$disturl
|
2016-08-20 13:16:48 +00:00
|
|
|
sourcecheck Check if remote source package exists upstream
|
|
|
|
srcpkg Make a source package
|
|
|
|
undeps Uninstall packages listed in makedepends and depends
|
|
|
|
unpack Unpack sources to \$srcdir
|
|
|
|
up2date Compare target and sources dates
|
|
|
|
verify Verify checksums
|
|
|
|
|
|
|
|
To activate cross compilation specify in environment:
|
|
|
|
CHOST Arch or hostspec of machine to generate packages for
|
|
|
|
CTARGET Arch or hostspec of machine to generate compiler for
|
|
|
|
|
|
|
|
EOF
|
2008-10-18 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
APKBUILD="${APKBUILD:-./APKBUILD}"
|
2023-06-05 12:57:06 +00:00
|
|
|
unset color_opt force forceroot install_deps keep keep_build nodeps quiet verbose
|
2019-10-01 16:51:21 +00:00
|
|
|
while getopts ":AcdD:fFhkKmnP:qrRs:uvV" opt; do
|
2008-10-18 08:09:24 +00:00
|
|
|
case $opt in
|
2014-03-31 08:47:29 +00:00
|
|
|
'A') echo "$CARCH"; exit 0;;
|
2013-10-25 07:07:50 +00:00
|
|
|
'c') enable_colors
|
2010-05-18 09:42:04 +00:00
|
|
|
color_opt="-c";;
|
2017-02-21 15:44:15 +00:00
|
|
|
'd') nodeps="-d";;
|
2017-06-21 17:51:00 +00:00
|
|
|
'D') DESCRIPTION=$OPTARG;;
|
2010-05-06 19:37:52 +00:00
|
|
|
'f') force="-f";;
|
|
|
|
'F') forceroot="-F";;
|
2022-06-15 11:31:57 +00:00
|
|
|
'h') usage; exit 0;;
|
2010-05-06 19:37:52 +00:00
|
|
|
'k') keep="-k";;
|
2017-03-24 11:30:57 +00:00
|
|
|
'K') keep_build="-K";;
|
2013-10-25 07:07:50 +00:00
|
|
|
'm') disable_colors
|
2010-05-18 09:42:04 +00:00
|
|
|
color_opt="-m";;
|
2009-10-24 20:03:06 +00:00
|
|
|
'n') die "Use newapkbuild to create new aports";;
|
2009-02-11 14:07:08 +00:00
|
|
|
'P') REPODEST=$OPTARG;;
|
2010-05-06 19:37:52 +00:00
|
|
|
'q') quiet="-q";;
|
|
|
|
'r') install_deps="-r";;
|
2009-01-07 10:46:26 +00:00
|
|
|
's') SRCDEST=$OPTARG;;
|
2022-06-15 12:14:24 +00:00
|
|
|
'v') verbose="-v"; set -x;;
|
2019-10-01 16:51:21 +00:00
|
|
|
'V') echo "$program $program_version"; exit 0;;
|
2022-06-15 11:31:57 +00:00
|
|
|
'?') error "Unrecognized option: $OPTARG"; usage >&2; exit 1;;
|
2008-10-18 08:09:24 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
|
2009-10-24 21:01:29 +00:00
|
|
|
# check so we are not root
|
2015-11-25 11:19:09 +00:00
|
|
|
if [ $(id -u) -eq 0 ] && [ -z "$FAKEROOTKEY" ]; then
|
2009-10-24 21:01:29 +00:00
|
|
|
[ -z "$forceroot" ] && die "Do not run abuild as root"
|
|
|
|
FAKEROOT=
|
|
|
|
fi
|
|
|
|
|
2019-07-20 01:14:20 +00:00
|
|
|
# check for ccache presence and maybe export its path
|
|
|
|
if [ -n "$USE_CCACHE" ]; then
|
2019-10-01 13:13:43 +00:00
|
|
|
mkdir -p "$HOME/.ccache"
|
2019-07-20 01:14:20 +00:00
|
|
|
# prepend ccache path
|
|
|
|
export PATH="/usr/lib/ccache/bin:$PATH"
|
|
|
|
fi
|
|
|
|
|
2009-10-24 20:37:20 +00:00
|
|
|
# find startdir
|
|
|
|
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
|
|
|
|
APKBUILD=$(readlink -f "$APKBUILD")
|
|
|
|
|
|
|
|
startdir="${APKBUILD%/*}"
|
|
|
|
srcdir=${srcdir:-"$startdir/src"}
|
|
|
|
pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
|
2023-06-22 03:33:59 +00:00
|
|
|
tmpdir=${tmpdir:-"$startdir/tmp"}
|
2014-01-13 12:36:07 +00:00
|
|
|
|
2009-10-24 20:37:20 +00:00
|
|
|
repo=${startdir%/*}
|
|
|
|
repo=${repo##*/}
|
|
|
|
|
2019-05-30 08:54:10 +00:00
|
|
|
aportsgit=${APORTSDIR:-${startdir}}
|
2022-07-20 21:03:39 +00:00
|
|
|
repo_template=$startdir/../.rootbld-repositories
|
2019-05-30 08:54:10 +00:00
|
|
|
|
2009-10-24 20:37:20 +00:00
|
|
|
SRCDEST=${SRCDEST:-$startdir}
|
|
|
|
|
2017-04-05 13:28:13 +00:00
|
|
|
BUILD_ROOT=
|
|
|
|
|
2019-07-20 01:14:20 +00:00
|
|
|
export CC CXX
|
2013-08-01 08:46:12 +00:00
|
|
|
|
2009-10-24 20:37:20 +00:00
|
|
|
cd "$startdir" || die
|
|
|
|
. "$APKBUILD"
|
|
|
|
|
2016-08-20 14:22:22 +00:00
|
|
|
builddir=${builddir:-"$srcdir/$pkgname-$pkgver"}
|
|
|
|
|
2009-02-11 14:07:08 +00:00
|
|
|
# If REPODEST is set then it will override the PKGDEST
|
2016-07-26 08:05:17 +00:00
|
|
|
if [ -z "$REPODEST" ]; then
|
2019-05-23 03:29:36 +00:00
|
|
|
warning "REPODEST is not set and is now required. Defaulting to $HOME/packages"
|
2016-07-26 08:05:17 +00:00
|
|
|
[ -n "$PKGDEST" ] && die "PKGDEST is no longer supported."
|
2019-05-23 03:29:36 +00:00
|
|
|
REPODEST="$HOME/packages"
|
2009-02-11 14:07:08 +00:00
|
|
|
fi
|
|
|
|
|
2016-07-26 08:05:17 +00:00
|
|
|
# for recursive action
|
2020-11-27 15:16:57 +00:00
|
|
|
export REPODEST SRCDEST
|
2016-07-26 08:05:17 +00:00
|
|
|
|
2017-06-16 07:40:43 +00:00
|
|
|
# add dbg subpackage if its enabled globally
|
|
|
|
if [ -n "$DEFAULT_DBG" ] && ! subpackage_types_has "dbg" && ! options_has "!dbg" && [ "$arch" != "noarch" ]; then
|
|
|
|
subpackages="$pkgname-dbg $subpackages"
|
|
|
|
fi
|
|
|
|
|
2011-05-18 06:19:18 +00:00
|
|
|
# if we want build debug package
|
2014-01-16 13:33:45 +00:00
|
|
|
if [ -n "$DEBUG" ] || subpackage_types_has "dbg"; then
|
2011-05-18 06:19:18 +00:00
|
|
|
CFLAGS="$CFLAGS -g"
|
2015-01-28 13:09:24 +00:00
|
|
|
CXXFLAGS="$CXXFLAGS -g"
|
2020-05-03 11:57:32 +00:00
|
|
|
DFLAGS="$DFLAGS -g"
|
2011-05-18 06:19:18 +00:00
|
|
|
options="$options !strip"
|
|
|
|
fi
|
|
|
|
|
2008-11-06 16:08:30 +00:00
|
|
|
if [ -n "$subpkgname" ]; then
|
2016-07-26 11:32:43 +00:00
|
|
|
# If we are handling a sub package then reset subpackages and install
|
2009-08-17 13:02:37 +00:00
|
|
|
origsubpackages="$subpackages"
|
2008-11-06 16:08:30 +00:00
|
|
|
subpackages=
|
2016-07-26 11:32:43 +00:00
|
|
|
else
|
|
|
|
allpackages="$pkgname $subpackages"
|
|
|
|
for i in $linguas; do
|
|
|
|
allpackages="$allpackages $pkgname-lang-$i::noarch"
|
|
|
|
done
|
2008-11-06 16:08:30 +00:00
|
|
|
fi
|
2016-07-23 06:18:27 +00:00
|
|
|
apkbuild_arch="$arch"
|
2009-05-08 16:21:12 +00:00
|
|
|
pkgdir="$pkgbasedir/$pkgname"
|
2016-07-23 06:18:27 +00:00
|
|
|
if [ -z "$pkgarch" ]; then
|
|
|
|
pkgarch=$CARCH
|
|
|
|
list_has noarch $arch && pkgarch=noarch
|
|
|
|
fi
|
2009-07-20 14:56:01 +00:00
|
|
|
controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
|
2008-10-18 08:09:24 +00:00
|
|
|
|
|
|
|
trap 'die "Aborted by user"' INT
|
|
|
|
|
2017-03-21 08:05:44 +00:00
|
|
|
[ -z "$subpkgdir" ] && set_xterm_title "abuild${CROSS_COMPILE+-$CARCH}: $pkgname"
|
2008-10-18 08:09:24 +00:00
|
|
|
|
2017-03-21 08:05:44 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
set all
|
2017-02-21 15:44:15 +00:00
|
|
|
fi
|
2009-01-04 13:38:45 +00:00
|
|
|
|
2017-03-21 08:05:44 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
runpart $1
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2008-11-08 13:45:30 +00:00
|
|
|
cleanup
|