[PATCH] add upgpkg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Signed-off-by: Florian Pritz <bluewind@xxxxxxx>
---
 upgpkg |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100755 upgpkg

diff --git a/upgpkg b/upgpkg
new file mode 100755
index 0000000..5a35057
--- /dev/null
+++ b/upgpkg
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# upgpkg: Upgrades package versions in PKGBUILD and starts build.
+# Author: Abhishek Dasgupta <abhidg@xxxxxxxxx>
+#         Thanks to cactus, profjim and daenyth for all the sed help!
+# Edited: Florian Pritz <flo@xxxxxxx>
+
+# I place this script in the public domain.
+
+VERSION=0.4
+
+# from makepkg
+unset ALL_OFF BOLD BLUE GREEN RED YELLOW
+if [[ -t 2 ]]; then
+	# prefer terminal safe colored and bold text when tput is supported
+	if tput setaf 0 &>/dev/null; then
+		ALL_OFF="$(tput sgr0)"
+		BOLD="$(tput bold)"
+		BLUE="${BOLD}$(tput setaf 4)"
+		GREEN="${BOLD}$(tput setaf 2)"
+		RED="${BOLD}$(tput setaf 1)"
+		YELLOW="${BOLD}$(tput setaf 3)"
+	else
+		ALL_OFF="\033[1;0m"
+		BOLD="\033[1;1m"
+		BLUE="${BOLD}\033[1;34m"
+		GREEN="${BOLD}\033[1;32m"
+		RED="${BOLD}\033[1;31m"
+		YELLOW="${BOLD}\033[1;33m"
+	fi
+fi
+readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
+
+die() {
+    local message="$1"
+    shift
+    printf "$RED==> $(gettext "Error"):$ALL_OFF $(gettext "$message")\n" "$@"
+    exit 1
+}
+
+warn() {
+    local message="$1"
+    shift
+    printf "$YELLOW==> $(gettext "Warning"):$ALL_OFF $(gettext "$message")\n" "$@"
+}
+
+scriptlet() {
+  if [ -f "upgpkg" ]; then
+    if [[ $(type -t upgpkg_$1) = "function" ]]; then
+      upgpkg_$1 || die "\"%s\" scriptlet failed" $1
+    fi
+  fi
+}
+
+help() {
+  echo "upgpkg $VERSION"
+  printf "$(gettext "usage: upgpkg [options] newver")\n"
+  printf "$(gettext "      -h     this help")\n"
+  printf "$(gettext "      -g     generate a template ./upgpkg file")\n"
+  exit 2
+}
+
+if [ -z "$1" ]; then
+  help
+fi
+
+while getopts "gh" OPTION; do
+  case $OPTION in
+    g)
+      cat > upgpkg <<EOF
+upgpkg_pre_upgrade() {
+  # You might want to remove old sources here
+  true
+}
+
+upgpkg_build() {
+  makepkg
+}
+EOF
+      exit;
+      ;;
+    h) help;
+  esac
+done
+
+[ ! -f PKGBUILD ] && die "No \"%s\" in %s" "PKGBUILD" "$PWD"
+
+if [ -f "upgpkg" ]; then
+  source ./upgpkg
+fi
+
+source PKGBUILD
+
+scriptlet pre_upgrade
+
+if [[ $(vercmp $1 $pkgver) -le 0 ]]; then
+    warn "New version (%s) older or equal to current %s" "$1" "$pkgver"
+fi
+
+sed -i "s/pkgver=.*$/pkgver=$1/g" PKGBUILD
+sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD
+awk <PKGBUILD '$0 ~ /^(md5|sha[0-9]+)sums/ {i = 1; if(!run==1) {system("makepkg -g 2>/dev/null")}; run=1; }; !i {print}; $0 ~ /\)/ {i = 0}' | sponge PKGBUILD
+
+source PKGBUILD
+if [ -f "upgpkg" ]; then
+  source ./upgpkg
+fi
+
+for i in $gpgsource; do
+  sigfile="$(basename "$i")"
+  if [[ $sigfile != $i ]]; then
+    wget -nv  -O "$sigfile" "$i"
+  fi
+  gpg2 --verify "$sigfile" || die "Signature verification failed!"
+done
+
+scriptlet build
-- 
1.7.3.2


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux