[pacman-dev] [PATCH] makepkg: exit if updating pkgver fails
From: Zach Buhman
On Oct 14, 2013 2:52 AM, "Allan McRae"
From: Zach Buhman
[Allan: add details to failure message] Signed-off-by: Allan McRae
--- scripts/makepkg.sh.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cedef4c..db344a3 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -813,7 +813,11 @@ update_pkgver() {
if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then - @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/"
"$BUILDFILE"
+ if ! @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"; then + error "$(gettext "Failure updating %s from %s to %s")" + "pkgver" "$pkgver" "$newpkgver" + exit 1
This does not work. Failure to match in not a program failure.
+ fi @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" source_safe "$BUILDFILE" local fullver=$(get_full_version) -- 1.8.4
On 14/10/13 21:02, Dave Reisner wrote:
On Oct 14, 2013 2:52 AM, "Allan McRae"
wrote: From: Zach Buhman
[Allan: add details to failure message] Signed-off-by: Allan McRae
--- scripts/makepkg.sh.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cedef4c..db344a3 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -813,7 +813,11 @@ update_pkgver() {
if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then - @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/"
"$BUILDFILE"
+ if ! @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"; then + error "$(gettext "Failure updating %s from %s to %s")" + "pkgver" "$pkgver" "$newpkgver" + exit 1
This does not work. Failure to match in not a program failure.
Failure to match will mean the sanity check for pkgrel right after this will fail. This is to catch cases like: newpkgver="/path/to/PKGBUILD: line 22: svnversion: command not found"
+ fi @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" source_safe "$BUILDFILE" local fullver=$(get_full_version) -- 1.8.4
Validate the new pkgver efore blindly ramming it into the PKGBUILD.
This gives us good feedback and prevents corrupting the PKGBUILD, e.g.
==> Starting pkgver()...
==> ERROR: pkgver is not allowed to contain colons, hyphens or whitespace.
==> ERROR: pkgver() generated an invalid version: a horse is not a pkgver
As an additional failsafe, exchange a valid for invalid character as
command separator in @SEDINPLACE@ expressions. For even more paranoia,
exit if sed fails for any reason.
Signed-off-by: Dave Reisner
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dave Reisner