Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 40 lines 1.5 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -p bash -p subversion -p common-updater-scripts -i bash 3 4die() { 5 echo "error: $1" >&2 6 exit 1 7} 8 9attr=netpbm 10svnRoot=https://svn.code.sf.net/p/netpbm/code/advanced 11 12oldRev=$(nix-instantiate --eval -E "with import ./. {}; $attr.src.rev" | tr -d '"') 13if [[ -z "$oldRev" ]]; then 14 die "Could not extract old revision." 15fi 16 17latestRev=$(svn info --show-item "last-changed-revision" "$svnRoot") 18if [[ -z "$latestRev" ]]; then 19 die "Could not find out last changed revision." 20fi 21 22versionInfo=$(svn cat -r "$latestRev" "$svnRoot/version.mk") 23if [[ -z "$versionInfo" ]]; then 24 die "Could not get version info." 25fi 26 27nixFile=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/') 28if [[ ! -f "$nixFile" ]]; then 29 die "Could not evaluate '$attr.meta.position' to locate the .nix file!" 30fi 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 34sed -i "$nixFile" -re '/(\brev\b\s*=\s*)"'"$oldRev"'"/{ s||\1"'"$latestRev"'"|; h }; ${x; /./{x; q1}; x}' && die "Unable to update revision." 35 36majorRelease=$(grep --perl-regex --only-matching 'NETPBM_MAJOR_RELEASE = \K.+' <<< "$versionInfo") 37minorRelease=$(grep --perl-regex --only-matching 'NETPBM_MINOR_RELEASE = \K.+' <<< "$versionInfo") 38pointRelease=$(grep --perl-regex --only-matching 'NETPBM_POINT_RELEASE = \K.+' <<< "$versionInfo") 39 40update-source-version "$attr" "$majorRelease.$minorRelease.$pointRelease"