xbps-src: implement a 'check' stage
Add another stage 'check' between 'build' and 'install'. It is be enabled using the variable XBPS_CHECK_PKGS=yes and disabled if unset, set to "0" or "no" in your local etc/conf. A new xbps-src option `-q` for `quick` will disable XBPS_CHECK_PKGS by overriding it to 0. If enabled, `common/xbps-src/shutils/xbps-src-docheck.sh` checks for an existing `do_check()` function in the package's template and, if it exists, calls it. A new template variable `checkdepends` may be present and list packages required to run the `do_check()` function. Example: `checkdepends="bc unittest-cpp"`.
This commit is contained in:
parent
f9dface61c
commit
c31dd888f6
14 changed files with 156 additions and 13 deletions
|
@ -61,6 +61,10 @@ $XBPS_LIBEXECDIR/xbps-src-doconfigure.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
|||
$XBPS_LIBEXECDIR/xbps-src-dobuild.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
||||
[ "$XBPS_TARGET" = "build" ] && exit 0
|
||||
|
||||
# Run check phase
|
||||
$XBPS_LIBEXECDIR/xbps-src-docheck.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
||||
[ "$XBPS_TARGET" = "check" ] && exit 0
|
||||
|
||||
# Install pkgs into destdir.
|
||||
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $SOURCEPKG no $XBPS_CROSS_BUILD || exit 1
|
||||
|
||||
|
|
54
common/xbps-src/libexec/xbps-src-docheck.sh
Executable file
54
common/xbps-src/libexec/xbps-src-docheck.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# vim: set ts=4 sw=4 et:
|
||||
#
|
||||
# Passed arguments:
|
||||
# $1 - pkgname to build [REQUIRED]
|
||||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PKGNAME="$1"
|
||||
XBPS_CROSS_BUILD="$2"
|
||||
|
||||
for f in $XBPS_SHUTILSDIR/*.sh; do
|
||||
. $f
|
||||
done
|
||||
|
||||
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
|
||||
|
||||
XBPS_CHECK_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_check_done"
|
||||
|
||||
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
||||
msg_normal "${pkgname}-${version}_${revision}: skipping check (cross build for $XBPS_CROSS_BUILD) ...\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$XBPS_CHECK_PKGS" -o "$XBPS_CHECK_PKGS" = "0" -o "$XBPS_CHECK_PKGS" = "no" ]; then
|
||||
msg_normal "${pkgname}-${version}_${revision}: skipping check (XBPS_CHECK_PKGS is disabled) ...\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for f in $XBPS_COMMONDIR/environment/check/*.sh; do
|
||||
source_file "$f"
|
||||
done
|
||||
|
||||
cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
|
||||
if [ -n "$build_wrksrc" ]; then
|
||||
cd $build_wrksrc || \
|
||||
msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
|
||||
fi
|
||||
|
||||
# Run do_check() if the function is defined
|
||||
if declare -f do_check > /dev/null; then
|
||||
run_func do_check
|
||||
else
|
||||
msg_normal "${pkgname}-${version}_${revision}: template does not have do_check() ...\n"
|
||||
fi
|
||||
|
||||
touch -f $XBPS_CHECK_DONE
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue