[arch-general] [PATCH] add upgpkg
Florian Pritz
bluewind at xssn.at
Mon Nov 1 09:38:23 EDT 2010
Signed-off-by: Florian Pritz <bluewind at xssn.at>
---
upgpkg | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
create mode 100755 upgpkg
diff --git a/upgpkg b/upgpkg
new file mode 100755
index 0000000..7966ac3
--- /dev/null
+++ b/upgpkg
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# upgpkg: Upgrades package versions in PKGBUILD and starts build.
+# Author: Abhishek Dasgupta <abhidg at gmail.com>
+# Thanks to cactus, profjim and daenyth for all the sed help!
+# Edited: Florian Pritz <flo at xinu.at>
+
+# I place this script in the public domain.
+
+VERSION=0.2
+
+die() {
+ local message="$1"
+ shift
+ printf "$(gettext "Error: $message")\n" "$@"
+ exit 1
+}
+
+if [ -z "$1" ]; then
+ echo "upgpkg $VERSION"
+ printf "$(gettext "usage: upgpkg newver")\n"
+ exit 2
+fi
+
+# Main code follows
+
+[ ! -f PKGBUILD ] && die "No \"%s\" in %s" "PKGBUILD" "$PWD"
+
+sed -ri '/(md5sums|sha[0-9]+sums)[ ]?\=/{:a; /\)/d; N; ba;}' PKGBUILD || die "Could not bump pkgver"
+source PKGBUILD
+
+if [ $(vercmp $1 $pkgver) -gt 0 ]; then
+ sed -i "s/pkgver=.*$/pkgver=$1/g" PKGBUILD
+ sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD
+ makepkg -g >> PKGBUILD
+else
+ die "New version (%s) older or equal to current %s" "$1" "$pkgver"
+fi
+
+if [ -x "rebuild" ]; then
+ ./rebuild
+else
+ makepkg
+fi
--
1.7.3.2
More information about the arch-general
mailing list