netpbm: add updateScript

+42
+2
pkgs/tools/graphics/netpbm/default.nix
··· 61 61 done 62 62 ''; 63 63 64 + passthru.updateScript = ./update.sh; 65 + 64 66 meta = { 65 67 homepage = http://netpbm.sourceforge.net/; 66 68 description = "Toolkit for manipulation of graphic images";
+40
pkgs/tools/graphics/netpbm/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -p bash -p subversion -p common-updater-scripts -i bash 3 + 4 + die() { 5 + echo "error: $1" >&2 6 + exit 1 7 + } 8 + 9 + attr=netpbm 10 + svnRoot=https://svn.code.sf.net/p/netpbm/code/advanced 11 + 12 + oldRev=$(nix-instantiate --eval -E "with import ./. {}; $attr.src.rev" | tr -d '"') 13 + if [[ -z "$oldRev" ]]; then 14 + die "Could not extract old revision." 15 + fi 16 + 17 + latestRev=$(svn info --show-item "last-changed-revision" "$svnRoot") 18 + if [[ -z "$latestRev" ]]; then 19 + die "Could not find out last changed revision." 20 + fi 21 + 22 + versionInfo=$(svn cat -r "$latestRev" "$svnRoot/version.mk") 23 + if [[ -z "$versionInfo" ]]; then 24 + die "Could not get version info." 25 + fi 26 + 27 + nixFile=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/') 28 + if [[ ! -f "$nixFile" ]]; then 29 + die "Could not evaluate '$attr.meta.position' to locate the .nix file!" 30 + fi 31 + 32 + # h remembers if we found the pattern; on the last line, if a pattern was previously found, we exit with 1 33 + # https://stackoverflow.com/a/12145797/160386 34 + sed -i "$nixFile" -re '/(\brev\b\s*=\s*)"'"$oldRev"'"/{ s||\1"'"$latestRev"'"|; h }; ${x; /./{x; q1}; x}' && die "Unable to update revision." 35 + 36 + majorRelease=$(grep --perl-regex --only-matching 'NETPBM_MAJOR_RELEASE = \K.+' <<< "$versionInfo") 37 + minorRelease=$(grep --perl-regex --only-matching 'NETPBM_MINOR_RELEASE = \K.+' <<< "$versionInfo") 38 + pointRelease=$(grep --perl-regex --only-matching 'NETPBM_POINT_RELEASE = \K.+' <<< "$versionInfo") 39 + 40 + update-source-version "$attr" "$majorRelease.$minorRelease.$pointRelease"