···6161 done
6262 '';
63636464+ passthru.updateScript = ./update.sh;
6565+6466 meta = {
6567 homepage = http://netpbm.sourceforge.net/;
6668 description = "Toolkit for manipulation of graphic images";
+40
pkgs/tools/graphics/netpbm/update.sh
···11+#!/usr/bin/env nix-shell
22+#!nix-shell -p bash -p subversion -p common-updater-scripts -i bash
33+44+die() {
55+ echo "error: $1" >&2
66+ exit 1
77+}
88+99+attr=netpbm
1010+svnRoot=https://svn.code.sf.net/p/netpbm/code/advanced
1111+1212+oldRev=$(nix-instantiate --eval -E "with import ./. {}; $attr.src.rev" | tr -d '"')
1313+if [[ -z "$oldRev" ]]; then
1414+ die "Could not extract old revision."
1515+fi
1616+1717+latestRev=$(svn info --show-item "last-changed-revision" "$svnRoot")
1818+if [[ -z "$latestRev" ]]; then
1919+ die "Could not find out last changed revision."
2020+fi
2121+2222+versionInfo=$(svn cat -r "$latestRev" "$svnRoot/version.mk")
2323+if [[ -z "$versionInfo" ]]; then
2424+ die "Could not get version info."
2525+fi
2626+2727+nixFile=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
2828+if [[ ! -f "$nixFile" ]]; then
2929+ die "Could not evaluate '$attr.meta.position' to locate the .nix file!"
3030+fi
3131+3232+# h remembers if we found the pattern; on the last line, if a pattern was previously found, we exit with 1
3333+# https://stackoverflow.com/a/12145797/160386
3434+sed -i "$nixFile" -re '/(\brev\b\s*=\s*)"'"$oldRev"'"/{ s||\1"'"$latestRev"'"|; h }; ${x; /./{x; q1}; x}' && die "Unable to update revision."
3535+3636+majorRelease=$(grep --perl-regex --only-matching 'NETPBM_MAJOR_RELEASE = \K.+' <<< "$versionInfo")
3737+minorRelease=$(grep --perl-regex --only-matching 'NETPBM_MINOR_RELEASE = \K.+' <<< "$versionInfo")
3838+pointRelease=$(grep --perl-regex --only-matching 'NETPBM_POINT_RELEASE = \K.+' <<< "$versionInfo")
3939+4040+update-source-version "$attr" "$majorRelease.$minorRelease.$pointRelease"