From 7e4f9bcdb6027b667ce33c376e0de4bffe92755f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 8 Nov 2010 15:57:06 +0100 Subject: upgpkg: many changes Signed-off-by: Florian Pritz --- upgpkg | 122 ++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 32 deletions(-) (limited to 'upgpkg') diff --git a/upgpkg b/upgpkg index 0a2b203..5a35057 100755 --- a/upgpkg +++ b/upgpkg @@ -3,57 +3,115 @@ # upgpkg: Upgrades package versions in PKGBUILD and starts build. # Author: Abhishek Dasgupta # Thanks to cactus, profjim and daenyth for all the sed help! -# Requires: pkgtools. +# Edited: Florian Pritz # I place this script in the public domain. -MYVERSION=0.1 -PROGNAME="upgpkg" +VERSION=0.4 -if [ -r /usr/share/pkgtools/functions ]; then - source /usr/share/pkgtools/functions -else - printf "$(gettext "upgpkg: Unable to source function file!\n")" >&2 - exit 1 +# 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 "$message" "$@" + printf "$RED==> $(gettext "Error"):$ALL_OFF $(gettext "$message")\n" "$@" exit 1 } -if [ -r /etc/pkgtools/newpkg.conf ]; then - source /etc/pkgtools/newpkg.conf -fi -if [ -r "${HOME}/.pkgtools/newpkg.conf" ]; then - source "${HOME}/.pkgtools/newpkg.conf" +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 -if [ -z "$BASEDIR" ]; then die "$(gettext "upgpkg: unable to locate BASEDIR in configuration.")"; fi +while getopts "gh" OPTION; do + case $OPTION in + g) + cat > upgpkg <> PKGBUILD -else - die "$(gettext "upgpkg: %s - new version (%s) older or equal to current %s\n")" "$1" "$2" "$pkgver" +scriptlet pre_upgrade + +if [[ $(vercmp $1 $pkgver) -le 0 ]]; then + warn "New version (%s) older or equal to current %s" "$1" "$pkgver" fi -makepkg -m -if [ $? -gt 0 ]; then - sed -i "s/pkgver=.*$/pkgver=$pkgver/g" PKGBUILD - sed -i "s/pkgrel=.*$/pkgrel=$pkgrel/g" PKGBUILD - die "$(gettext "upgpkg: %s - build failed for %s, reverting to %s\n")" "$1" "$2" "$pkgver" + +sed -i "s/pkgver=.*$/pkgver=$1/g" PKGBUILD +sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD +awk /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 -- cgit v1.2.3-24-g4f1b