[pacman-dev] [PATCH] makepkg: don't try to verbump PKGBUILD on /dev/stdin

Dave Reisner d at falconindy.com
Sun Jul 10 14:03:14 EDT 2011


This works around an edge case where we try to change the $pkgver and
$pkgrel of a VCS PKGBUILD passed in standard input, which fails on
missing write permissions in /dev.

As an added bonus, we avoid a second (costly) full re-sourcing of the
PKGBUILD, and simply reassign the variables that may have changed to
ensure that in the non-write case we create the new package with the
correct version.

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
Extreme edge cases ftw.

Allan, correct me if I'm wrong that this is the only place where we actually
modify the PKGBUILD itself. I had myself a grep around and couldn't find
anything else -- I just want to make sure I'm not going to hit some crazy
pitfall by avoiding the second resourcing. I did do some simple testing and all
seems to be well, but you probably know this portion of the code better than I
do.

 scripts/makepkg.sh.in |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 1b132a9..e77ca51 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1623,9 +1623,14 @@ devel_update() {
 	if [[ -n $newpkgver ]]; then
 		if [[ $newpkgver != $pkgver ]]; then
 			if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
-				@SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
-				@SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
-				source "$BUILDFILE"
+				if [[ -w "${BUILDFILE%/*}" ]]; then
+					@SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
+					@SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
+				else
+					warning "$(gettext "Unable to update PKGBUILD package version")"
+				fi
+				pkgver=$newpkgver
+				pkgrel=1
 			fi
 		fi
 	fi
-- 
1.7.6



More information about the pacman-dev mailing list