diff options
-rw-r--r-- | PKGBUILD-split.proto | 6 | ||||
-rw-r--r-- | PKGBUILD.proto | 8 | ||||
-rw-r--r-- | doc/PKGBUILD.5.txt | 16 | ||||
-rw-r--r-- | doc/makepkg.8.txt | 7 | ||||
-rw-r--r-- | doc/makepkg.conf.5.txt | 5 | ||||
-rw-r--r-- | etc/makepkg.conf.in | 5 | ||||
-rw-r--r-- | scripts/makepkg.sh.in | 31 |
7 files changed, 70 insertions, 8 deletions
diff --git a/PKGBUILD-split.proto b/PKGBUILD-split.proto index f5114ab7..52aacc54 100644 --- a/PKGBUILD-split.proto +++ b/PKGBUILD-split.proto @@ -16,6 +16,7 @@ license=('GPL') groups=() depends=() makedepends=() +checkdepends=() provides=() conflicts=() replaces=() @@ -33,6 +34,11 @@ build() { make } +check() { + cd "$srcdir/$pkgname-$pkgver" + make -k check +} + package_pkg1() { # options and directives that can be overridden pkgver= diff --git a/PKGBUILD.proto b/PKGBUILD.proto index 71dbc14d..98172d8d 100644 --- a/PKGBUILD.proto +++ b/PKGBUILD.proto @@ -15,6 +15,7 @@ license=('GPL') groups=() depends=() makedepends=() +checkdepends=() optdepends=() provides=() conflicts=() @@ -29,14 +30,17 @@ md5sums=() #generate with 'makepkg -g' build() { cd "$srcdir/$pkgname-$pkgver" - ./configure --prefix=/usr make } -package() { +check() { cd "$srcdir/$pkgname-$pkgver" + make -k check +} +package() { + cd "$srcdir/$pkgname-$pkgver" make DESTDIR="$pkgdir/" install } diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 3d3909ac..2ccf0b2e 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -156,6 +156,12 @@ name. The syntax is: `source=('filename::url')`. needed at runtime. Packages in this list follow the same format as depends. +*checkdepends (array)*:: + An array of packages that this package depends on to run its test suite, + but are not needed at runtime. Packages in this list follow the same + format as depends. These dependencies are only considered when the + check() function is present and is to be run by makepkg. + *optdepends (array)*:: An array of packages (and accompanying reasons) that are not essential for base functionality, but may be necessary to make full use of the contents @@ -263,10 +269,18 @@ If you create any variables of your own in the build function, it is recommended to use the bash `local` keyword to scope the variable to inside the build function. +check() Function +---------------- +An optional check() function can be specified in which a packages test-suite +may be run. This function is run between the build() and package() functions. +The function is run in `bash -e` mode, meaning any command that exits with a +non-zero status will cause the function to exit. Be sure any exotic commands +used are covered by `checkdepends`. + package() Function ------------------ An optional package() function can be specified in addition to the build() -function. This function is run immediately after the build() function. The +function. This function is run after the build() and check() functions. The function is run in `bash -e` mode, meaning any command that exits with a non-zero status will cause the function to exit. When specified in combination with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index ff0f2b63..3b83015e 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -153,6 +153,13 @@ Options Only build listed packages from a split package. The use of quotes is necessary when specifying multiple packages. e.g. `--pkg "pkg1 pkg3"` +*\--check*:: + Run the check() function in the PKGBUILD, overriding the setting in + linkman:makepkg.conf[5]. + +*\--nocheck*:: + Do not run the check() function in the PKGBUILD or handle the checkdepends. + *\--noconfirm*:: (Passed to pacman) Prevent pacman from waiting for user input before proceeding with operations. diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index 86ea6a3a..020804cb 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -93,6 +93,11 @@ Options be disabled for individual packages by placing `!ccache` in the PKGBUILD options array. + *check*;; + Run the check() function if present in the PKGBUILD. This can be + enabled or disabled for individual packages through the use of + makepkg's `--check` and `--nocheck` options respectively. + **DISTCC_HOSTS=**"host1 ...":: If using DistCC, this is used to specify a space-delimited list of hosts running in the DistCC cluster. In addition, you will want to modify your diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index c795432f..81a11b1d 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -39,15 +39,16 @@ CXXFLAGS="@CARCHFLAGS@-mtune=generic -O2 -pipe" # BUILD ENVIRONMENT ######################################################################### # -# Defaults: BUILDENV=(fakeroot !distcc color !ccache) +# Defaults: BUILDENV=(fakeroot !distcc color !ccache check) # A negated environment option will do the opposite of the comments below. # #-- fakeroot: Allow building packages as a non-root user #-- distcc: Use the Distributed C/C++/ObjC compiler #-- color: Colorize output messages #-- ccache: Use ccache to cache compilation +#-- check: Run the check() function if present in the PKGBUILD # -BUILDENV=(fakeroot !distcc color !ccache) +BUILDENV=(fakeroot !distcc color !ccache check) # #-- If using DistCC, your MAKEFLAGS will also need modification. In addition, #-- specify a space-delimited list of hosts running in the DistCC cluster. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 985d7f0a..c0fcae0f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -71,6 +71,7 @@ SOURCEONLY=0 IGNOREARCH=0 HOLDVER=0 BUILDFUNC=0 +CHECKFUNC=0 PKGFUNC=0 SPLITPKG=0 PKGLIST=() @@ -145,6 +146,9 @@ clean_up() { if (( BUILDFUNC )); then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* fi + if (( CHECKFUNC )); then + rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-check.log"* + fi if (( PKGFUNC )); then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* elif (( SPLITPKG )); then @@ -805,6 +809,10 @@ run_build() { run_function "build" } +run_check() { + run_function "check" +} + run_package() { local pkgfunc if [[ -z $1 ]]; then @@ -1547,8 +1555,10 @@ usage() { echo "$(gettext " -s, --syncdeps Install missing dependencies with pacman")" echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources")" echo "$(gettext " --asroot Allow makepkg to run as root user")" + printf "$(gettext " --check Run the check() function in the %s")\n" "$BUILDSCRIPT" printf "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" printf "$(gettext " --holdver Prevent automatic version bumping for development %ss")\n" "$BUILDSCRIPT" + printf "$(gettext " --nocheck Do not run the check() function in the %s")\n" "$BUILDSCRIPT" echo "$(gettext " --pkg <list> Only build listed packages from a split package")" echo "$(gettext " --skipinteg Do not fail when integrity checks are missing")" echo "$(gettext " --source Generate a source-only tarball without downloaded sources")" @@ -1584,10 +1594,10 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcCdefFghiLmop:rRsV" -OPT_LONG="allsource,asroot,ignorearch,clean,cleancache,nodeps" +OPT_LONG="allsource,asroot,ignorearch,check,clean,cleancache,nodeps" OPT_LONG+=",noextract,force,forcever:,geninteg,help,holdver" -OPT_LONG+=",install,log,nocolor,nobuild,pkg:,rmdeps,repackage,skipinteg" -OPT_LONG+=",source,syncdeps,version,config:" +OPT_LONG+=",install,log,nocolor,nobuild,nocheck,pkg:,rmdeps" +OPT_LONG+=",repackage,skipinteg,source,syncdeps,version,config:" # Pacman Options OPT_LONG+=",noconfirm,noprogressbar" OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@" || echo 'PARSE_OPTIONS FAILED')" @@ -1610,6 +1620,7 @@ while true; do -A|--ignorearch) IGNOREARCH=1 ;; -c|--clean) CLEANUP=1 ;; -C|--cleancache) CLEANCACHE=1 ;; + --check) RUN_CHECK='y' ;; --config) shift; MAKEPKG_CONF=$1 ;; -d|--nodeps) NODEPS=1 ;; -e|--noextract) NOEXTRACT=1 ;; @@ -1622,6 +1633,7 @@ while true; do -i|--install) INSTALL=1 ;; -L|--log) LOGGING=1 ;; -m|--nocolor) USE_COLOR='n' ;; + --nocheck) RUN_CHECK='n' ;; -o|--nobuild) NOBUILD=1 ;; -p) shift; BUILDFILE=$1 ;; --pkg) shift; PKGLIST=($1) ;; @@ -1837,6 +1849,12 @@ fi if declare -f build >/dev/null; then BUILDFUNC=1 fi +if declare -f check >/dev/null; then + # "Hide" check() function if not going to be run + if [[ $RUN_CHECK = 'y' || (! $(check_buildenv check) = "n" && ! $RUN_CHECK = "n") ]]; then + CHECKFUNC=1 + fi +fi if declare -f package >/dev/null; then PKGFUNC=1 elif [[ $SPLITPKG -eq 0 ]] && declare -f package_${pkgname} >/dev/null; then @@ -1900,6 +1918,7 @@ if (( INFAKEROOT )); then if (( ! REPKG )); then if (( BUILDFUNC )); then run_build + (( CHECKFUNC )) && run_check tidy_install fi else @@ -1950,6 +1969,10 @@ elif type -p "${PACMAN%% *}" >/dev/null; then msg "$(gettext "Checking buildtime dependencies...")" resolve_deps ${makedepends[@]} || deperr=1 + if (( CHECKFUNC )); then + resolve_deps ${checkdepends[@]} || deperr=1 + fi + if (( RMDEPS )); then current_pkglist=($(run_pacman -Qq)) # required by remove_deps fi @@ -2015,6 +2038,7 @@ else if (( ! REPKG )); then devel_update (( BUILDFUNC )) && run_build + (( CHECKFUNC )) && run_check fi if (( ! SPLITPKG )); then if (( PKGFUNC )); then @@ -2036,6 +2060,7 @@ else if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then devel_update (( BUILDFUNC )) && run_build + (( CHECKFUNC )) && run_check cd "$startdir" fi |