abuild: implement check and $checkdepends support.
The check() function is an APKBUILD overridable function which runs a testsuite. The packages listed in $checkdepends are packages which will be installed at build time only if check() will be run.
This commit is contained in:
parent
89d62e9d4d
commit
ea1db36f1f
32
abuild.in
32
abuild.in
@ -66,6 +66,12 @@ cross_compiling() {
|
|||||||
test "$CBUILD" != "$CHOST" -a -n "$CBUILDROOT"
|
test "$CBUILD" != "$CHOST" -a -n "$CBUILDROOT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
want_check() {
|
||||||
|
cross_compiling && return 1
|
||||||
|
options_has "!check" && return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
local i=
|
local i=
|
||||||
[ -z "$subpkgdir" ] && set_xterm_title ""
|
[ -z "$subpkgdir" ] && set_xterm_title ""
|
||||||
@ -199,6 +205,7 @@ default_sanitycheck() {
|
|||||||
[ -n "$pkguser" ] && spell_error pkguser pkgusers
|
[ -n "$pkguser" ] && spell_error pkguser pkgusers
|
||||||
[ -n "$pkggroup" ] && spell_error pkggroup pkggroups
|
[ -n "$pkggroup" ] && spell_error pkggroup pkggroups
|
||||||
[ -n "$subpackage" ] && spell_error subpackage subpackages
|
[ -n "$subpackage" ] && spell_error subpackage subpackages
|
||||||
|
[ -n "$checkdepend" ] && spell_error checkdepend checkdepends
|
||||||
|
|
||||||
check_maintainer || die "Provide a valid RFC822 maintainer address"
|
check_maintainer || die "Provide a valid RFC822 maintainer address"
|
||||||
|
|
||||||
@ -1365,18 +1372,21 @@ create_apks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build_abuildrepo() {
|
build_abuildrepo() {
|
||||||
local d apk _build=build
|
local d apk _build=build _check=check
|
||||||
if ! is_function package; then
|
if ! is_function package; then
|
||||||
# if package() is missing then build is called from rootpkg
|
# if package() is missing then build is called from rootpkg
|
||||||
_build=true
|
_build=true
|
||||||
fi
|
fi
|
||||||
|
if ! want_check; then
|
||||||
|
_check=true
|
||||||
|
fi
|
||||||
if ! apk_up2date || [ -n "$force" ]; then
|
if ! apk_up2date || [ -n "$force" ]; then
|
||||||
# check early if we have abuild key
|
# check early if we have abuild key
|
||||||
abuild-sign --installed || return 1
|
abuild-sign --installed || return 1
|
||||||
logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
|
logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
|
||||||
sanitycheck && builddeps && clean && fetch && unpack \
|
sanitycheck && builddeps && clean && fetch && unpack \
|
||||||
&& prepare && mkusers && $_build && rootpkg \
|
&& prepare && mkusers && $_build && $_check \
|
||||||
&& cleanup $CLEANUP \
|
&& rootpkg && cleanup $CLEANUP \
|
||||||
|| return 1
|
|| return 1
|
||||||
fi
|
fi
|
||||||
update_abuildrepo_index
|
update_abuildrepo_index
|
||||||
@ -1417,6 +1427,15 @@ update_abuildrepo_index() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# predefined function check
|
||||||
|
default_check() {
|
||||||
|
warning "APKBUILD does not run any tests - define a check() function!"
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
default_check
|
||||||
|
}
|
||||||
|
|
||||||
# predefined splitfunc doc
|
# predefined splitfunc doc
|
||||||
default_doc() {
|
default_doc() {
|
||||||
depends="$depends_doc"
|
depends="$depends_doc"
|
||||||
@ -1715,11 +1734,14 @@ parse_aports_makedepends() {
|
|||||||
subpackages=
|
subpackages=
|
||||||
depends=
|
depends=
|
||||||
makedepends=
|
makedepends=
|
||||||
|
checkdepends=
|
||||||
. $i
|
. $i
|
||||||
dir=${i%/APKBUILD}
|
dir=${i%/APKBUILD}
|
||||||
deps=
|
deps=
|
||||||
# filter out conflicts from deps and version info
|
# filter out conflicts from deps and version info
|
||||||
for j in $depends $makedepends; do
|
wantdepends="$depends $makedepends"
|
||||||
|
want_check && wantdepends="$wantdepends $checkdepends"
|
||||||
|
for j in $wantdepends; do
|
||||||
case "$j" in
|
case "$j" in
|
||||||
!*) continue;;
|
!*) continue;;
|
||||||
esac
|
esac
|
||||||
@ -1792,6 +1814,7 @@ calcdeps() {
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
[ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
|
[ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
|
||||||
|
want_check && makedepends="$makedepends $checkdepends"
|
||||||
for i in $1 $depends $makedepends; do
|
for i in $1 $depends $makedepends; do
|
||||||
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
[ "$pkgname" = "${i%%[<>=]*}" ] && continue
|
||||||
list_has $i $builddeps && continue
|
list_has $i $builddeps && continue
|
||||||
@ -2147,6 +2170,7 @@ usage() {
|
|||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
build Compile and install package into \$pkgdir
|
build Compile and install package into \$pkgdir
|
||||||
|
check Run any defined tests concerning the package
|
||||||
checksum Generate checksum to be included in APKBUILD
|
checksum Generate checksum to be included in APKBUILD
|
||||||
clean Remove temp build and install dirs
|
clean Remove temp build and install dirs
|
||||||
cleancache Remove downloaded files from \$SRCDEST
|
cleancache Remove downloaded files from \$SRCDEST
|
||||||
|
Reference in New Issue
Block a user