[arch-general] [PATCH] add upgpkg
Signed-off-by: Florian Pritz <bluewind@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@gmail.com> +# Thanks to cactus, profjim and daenyth for all the sed help! +# Edited: Florian Pritz <flo@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
On Monday 01 November 2010 14:38:23 Florian Pritz wrote:
+if [ -x "rebuild" ]; then + ./rebuild +else + makepkg +fi Which official script is named 'rebuild'? And, this script does not use a chroot to build the package!
-- Andrea Scarpino Arch Linux Developer
On Mon, 2010-11-01 at 16:25 +0100, Andrea Scarpino wrote:
On Monday 01 November 2010 14:38:23 Florian Pritz wrote:
+if [ -x "rebuild" ]; then + ./rebuild +else + makepkg +fi Which official script is named 'rebuild'? And, this script does not use a chroot to build the package!
And official packages should never ever just "makepkg -g" without actually checking the checksums generated by that. I always copy&paste the sha1sums or sha256sums into the PKGBUILD from announcement mails, so I know that a downloaded tarball is the same one that is announced in my mailbox.
On 01.11.2010 16:25, Andrea Scarpino wrote:
On Monday 01 November 2010 14:38:23 Florian Pritz wrote:
+if [ -x "rebuild" ]; then + ./rebuild +else + makepkg +fi Which official script is named 'rebuild'? And, this script does not use a chroot to build the package!
Because everyone handles chroots differently I just call a script called "rebuild" from the same directory the PKGBUILD is in. There you can run some build function and then automatically release the package. (extra-i686-build; communitypkg) -- Florian Pritz -- {flo,bluewind}@server-speed.net
This version replaces (no longer appends) the old checksums instead of using those specified by INTEGRITY_CHECK in makepkg.conf. If there are multiple checksums in the PKGBUILD, it will replace the first one and move the new ones to it's place. It also uses a file called "upgpkg" as a scriptlet file (similar to pacman's install files) It can be generated by running upgpkg -g. The functions used could also be defined in the PKGBUILD, but I think that's not really what one should do.
Add colors and the possibility to check gpg signatures. $gpgsources can be added to ./upgpkg or the PKGBUILD.
Signed-off-by: Florian Pritz <bluewind@xssn.at> --- 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@gmail.com> +# Thanks to cactus, profjim and daenyth for all the sed help! +# Edited: Florian Pritz <flo@xinu.at> + +# 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
This helper is neat, I like it. Any chance to get it into devtools?
Signed-off-by: Florian Pritz <bluewind@xssn.at> --- upgpkg | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 82 insertions(+), 0 deletions(-) create mode 100755 upgpkg diff --git a/upgpkg b/upgpkg new file mode 100755 index 0000000..80b12ad --- /dev/null +++ b/upgpkg @@ -0,0 +1,82 @@ +#!/bin/bash + +# upgpkg: Upgrades package versions in PKGBUILD and starts build. +# Author: Abhishek Dasgupta <abhidg@gmail.com> +# Thanks to cactus, profjim and daenyth for all the sed help! +# Edited: Florian Pritz <flo@xinu.at> + +# I place this script in the public domain. + +VERSION=0.3 + +die() { + local message="$1" + shift + printf "$(gettext "Error: $message")\n" "$@" + exit 1 +} + +warn() { + local message="$1" + shift + printf "$(gettext "Warning: $message")\n" "$@" +} + +scriptlet() { + if [ -f "upgpkg" ]; then + upgpkg_$1 || die "\"$1\" scriptlet failed" + 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 + +# Main code follows + +[ ! -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) -ge 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 + +scriptlet build -- 1.7.3.2
participants (5)
-
Andrea Scarpino
-
Florian Pritz
-
Florian Pritz
-
Jan de Groot
-
Sven-Hendrik Haase