[pacman-dev] Fwd: Feature Request

Dan McGee dan at archlinux.org
Sun Oct 11 17:20:43 EDT 2009


Something really old that I found today while cleaning email...not
sure if you can pull anything useful out of this, Allan. The from
address bounces which is why I'm forwarding this here rather than
asking him to write directly.

-Dan

---------- Forwarded message ----------
From: Archaic <archaic at kconline.com>
Date: Sat, Feb 7, 2009 at 8:49 PM
Subject: Re: Feature Request
To: dan at archlinux.org


Okay, I think I've managed to integrate this feature request with the
minimal fuss and full backwards compatability. To give a run down, the
new features will allow for a build(), check(), and inst() section in
the PKGBUILD, however, if either check() or inst() are missing, they
will be skipped over. Also, check() will never even be attempted unless
the 'check' option appears in the PKGBUILD or makepkg.conf. There are 2
other changes that *can* be made to any give PKGBUILD merely as a result
of making the above changes:

1) You no longer need to cd "$srcdir/pkgname-pkgver" in the PKGBUILD.
The non-standard paths are still viable like ${srcdir}/tcl${pkgver}/unix
if so needed.

2) You don't need excess || return 1 statements as in:

./configure
make || return 1
make install

Provided you use a separate build(), check(), and inst() function, the
makepkg code itself will handle the errors.

Let me know what you think of these changes.

--
Archaic

My other computer is an abacus.
-------------- next part --------------
--- /usr/bin/makepkg	2009-01-06 21:18:59.000000000 -0500
+++ makepkg	2009-02-07 20:44:38.000000000 -0500
@@ -41,7 +41,7 @@
 startdir="$PWD"
 srcdir="$startdir/src"
 pkgdir="$startdir/pkg"
-known_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'ccache' 'distcc' 'makeflags' 'force')
+known_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'ccache' 'distcc' 'makeflags' 'force' 'check')
 readonly -a known_options
 
 # Options
@@ -670,17 +670,24 @@
 		MAKEFLAGS=""
 	fi
 
-	msg "$(gettext "Starting build()...")"
-	cd "$srcdir"
-
 	# ensure all necessary build variables are exported
 	export CFLAGS CXXFLAGS MAKEFLAGS CHOST
 	# save our shell options so build() can't override what we need
 	local shellopts=$(shopt -p)
 
+	# run_build is called 3 times. Once each for build(), check(), and inst(). If
+	# the PKGBUILD does not have such a function, skip it for backwards
+	# compatability reasons.
+	if ! type -t $1 |grep -q function ; then
+		return 0
+	fi
+
+	msg "$(gettext "Starting ${1}()...")"
+	[ -d ${srcdir}/${pkgname}-${pkgver} ] && cd ${srcdir}/${pkgname}-${pkgver}
+
 	local ret=0
 	if [ "$LOGGING" = "1" ]; then
-		BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
+		BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-${1}.log"
 		if [ -f "$BUILDLOG" ]; then
 			local i=1
 			while true; do
@@ -693,10 +700,11 @@
 			mv "$BUILDLOG" "$BUILDLOG.$i"
 		fi
 
-		build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
+		$1 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
 	else
-		build 2>&1 || ret=$?
+		$1 2>&1 || ret=$?
 	fi
+
 	# reset our shell options
 	eval "$shellopts"
 
@@ -1522,7 +1530,9 @@
 	if [ "$REPKG" = "1" ]; then
 		warning "$(gettext "Skipping build.")"
 	else
-		run_build
+		run_build "build"
+		[ "$(check_option check)" = "y" ] && run_build "check"
+		run_build "inst"
 		tidy_install
 	fi
 
@@ -1619,7 +1629,9 @@
 			warning "$(gettext "Skipping build.")"
 		else
 			devel_update
-			run_build
+			run_build "build"
+			[ "$(check_option check)" = "y" ] && run_build "check"
+			run_build "inst"
 			tidy_install
 		fi
 
-------------- next part --------------
--- /etc/makepkg.conf	2009-02-07 20:19:36.000000000 -0500
+++ makepkg.conf	2009-02-07 20:09:00.000000000 -0500
@@ -58,16 +58,17 @@
 #   These are default values for the options=() settings
 #########################################################################
 #
-# Default: OPTIONS=(!check strip docs libtool emptydirs zipman)
+# Default: OPTIONS=(strip docs libtool emptydirs zipman)
 #  A negated option will do the opposite of the comments below.
 #
+#-- check:     Run the testsuite if such code exists in PKGBUILD
 #-- strip:     Strip symbols from binaries/libraries
 #-- docs:      Save doc and info directories
 #-- libtool:   Leave libtool (.la) files in packages
 #-- emptydirs: Leave empty directories in packages
 #-- zipman:    Compress manpages with gzip
 #
-OPTIONS=(!check strip docs libtool emptydirs zipman)
+OPTIONS=(strip docs libtool emptydirs zipman)
 
 #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
 INTEGRITY_CHECK=(md5)


More information about the pacman-dev mailing list