1 #!/usr/bin/env nix-shell
2 #!nix-shell -p bash -p subversion -p common-updater-scripts -i bash
10 svnRoot
=https
://svn.code.sf.net
/p
/netpbm
/code
/advanced
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."
17 latestRev
=$
(svn info
--show-item "last-changed-revision" "$svnRoot")
18 if [[ -z "$latestRev" ]]; then
19 die
"Could not find out last changed revision."
22 versionInfo
=$
(svn
cat -r "$latestRev" "$svnRoot/version.mk")
23 if [[ -z "$versionInfo" ]]; then
24 die
"Could not get version info."
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!"
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."
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")
40 update-source-version
"$attr" "$majorRelease.$minorRelease.$pointRelease"