If this is an accepted feature, I can resend the patch with manpage
updates.

Signed-off-by: Jeff C <[email protected]>
---
 etc/makepkg.conf.in   |    5 +++--
 scripts/makepkg.sh.in |   24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index f0d1c44..b3c4b4c 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -58,7 +58,7 @@ BUILDENV=(fakeroot !distcc color !ccache)
 #   These are default values for the options=() settings
 #########################################################################
 #
-# Default: OPTIONS=(strip docs libtool emptydirs zipman purge)
+# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !check)
 #  A negated option will do the opposite of the comments below.
 #
 #-- strip:     Strip symbols from binaries/libraries in STRIP_DIRS
@@ -67,8 +67,9 @@ BUILDENV=(fakeroot !distcc color !ccache)
 #-- emptydirs: Leave empty directories in packages
 #-- zipman:    Compress manual (man and info) pages in MAN_DIRS with gzip
 #-- purge:     Remove files specified by PURGE_TARGETS
+#-- check:     Run the check() function if it exists.
 #
-OPTIONS=(strip docs libtool emptydirs zipman purge)
+OPTIONS=(strip docs libtool emptydirs zipman purge !check)
 
 #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
 INTEGRITY_CHECK=(md5)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 678359f..2a659e6 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -44,7 +44,7 @@ startdir="$PWD"
 srcdir="$startdir/src"
 pkgdir="$startdir/pkg"
 
-packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
+packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 
'check')
 other_options=('ccache' 'distcc' 'makeflags' 'force')
 splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \
                     'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \
@@ -71,6 +71,7 @@ SOURCEONLY=0
 IGNOREARCH=0
 HOLDVER=0
 BUILDFUNC=0
+CHECKFUNC=0
 PKGFUNC=0
 SPLITPKG=0
 PKGLIST=""
@@ -143,6 +144,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
@@ -735,7 +739,11 @@ run_function() {
        fi
 
        msg "$(gettext "Starting %s()...")" "$pkgfunc"
-       cd "$srcdir"
+       if [[ -d "$srcdir"/"$pkgname"-"$pkgver" ]]; then
+               cd "$srcdir"/"$pkgname"-"$pkgver"
+       else
+               cd "$srcdir"
+       fi
 
        # ensure all necessary build variables are exported
        export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
@@ -798,6 +806,10 @@ run_build() {
        run_function "build"
 }
 
+run_check() {
+       [[ $(check_option check) = "y" ]] && run_function "check"
+}
+
 run_package() {
        if [[ -z $1 ]]; then
                pkgfunc="package"
@@ -1772,6 +1784,9 @@ fi
 if [[ $(type -t build) = "function" ]]; then
        BUILDFUNC=1
 fi
+if [[ $(type -t check) = "function" ]]; then
+       CHECKFUNC=1
+fi
 if [[ $(type -t package) = "function" ]]; then
        PKGFUNC=1
 elif [[ $SPLITPKG -eq 0 && $(type -t package_${pkgname}) = "function" ]]; then
@@ -1835,6 +1850,9 @@ if (( INFAKEROOT )); then
                        if (( ! REPKG )); then
                                if (( BUILDFUNC )); then
                                        run_build
+                                 if (( CHECKFUNC )); then
+                                               run_check
+                                       fi
                                        tidy_install
                                fi
                        else
@@ -1960,6 +1978,7 @@ else
                if (( ! REPKG )); then
                        devel_update
                        (( BUILDFUNC )) && run_build
+                       (( CHECKFUNC )) && run_check
                fi
                if (( ! SPLITPKG )); then
                        if (( PKGFUNC )); then
@@ -1991,6 +2010,7 @@ else
                if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then
                        devel_update
                        (( BUILDFUNC )) && run_build
+                       (( CHECKFUNC )) && run_check
                        cd "$startdir"
                fi
 
-- 
1.7.1


Reply via email to