Verified Commit f02eb097 authored by Max Rees's avatar Max Rees
Browse files

abuild, abump: use type(1) portably

parent 164e656b
......@@ -134,7 +134,6 @@ default_sanitycheck() {
if [ $(echo "$pkgdesc" | wc -c) -gt 128 ]; then
die "pkgdesc is too long"
fi
is_function package || die "Missing package() function in APKBUILD"
if [ -n "$replaces_priority" ] \
&& ! echo $replaces_priority | egrep -q '^[0-9]+$'; then
......@@ -240,9 +239,11 @@ default_sanitycheck() {
makedepends_has 'g++' && ! options_has toolchain && warning "g++ should not be in makedepends"
is_function package || die "Missing package() function in APKBUILD"
if ! options_has "!check" && [ -n "$REQUIRE_CHECK" ]; then
(unset check; . "$APKBUILD"; type check >/dev/null 2>&1) || \
die "Testsuites (abuild check) are required or need to be explicitly disabled!"
is_function check \
|| die "Testsuites (abuild check) are required or need to be explicitly disabled!"
fi
check_provides || die "provides must not contain $pkgname"
......@@ -1757,9 +1758,12 @@ openrc() {
}
is_function() {
type "$1" 2>&1 | head -n 1 | egrep -q "is a (shell )?function"
}
is_function() (
unset -f "$1" >/dev/null 2>&1 || true
unalias "$1" >/dev/null 2>&1 || true
. "$APKBUILD"
PATH= type "$1" >/dev/null 2>&1
)
do_fakeroot() {
if [ -n "$FAKEROOT" ]; then
......
......@@ -49,8 +49,13 @@ do_bump() {
name=${name#*/}
[ "$pkgname" = "$name" ] \
|| die "APKBUILD has different \$pkgname for $name"
type package | grep -q function \
|| die "missing package() for $name"
(
unset -f package || true
unalias package || true
. "$a"
PATH= type package >/dev/null 2>&1
) || die "missing package() for $name"
cd "${a%/*}"
section=${PWD%/*}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment