From af2fd342cd7114b7d5c39a4fd37c1a89c15c6496 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Sun, 4 Nov 2012 23:52:19 +0400 Subject: [PATCH] Updating SBCL to freshest release 1.1.1. Replacing SBCL upstream tracking expression with a new version in a new format. Minuses: gave up on defining everything in Nix language (now update expression is a series of actions to do when downloading fresh release, it is actually interpreted by shell), now Nix expression contains meaningful whitespace (the area to regenerate is determined by the line with a specific comment and the closing brace on the otherwise empty line). Plusses: only one extra file which could even be moved out-of-tree if desired, clean semantics for traversing multiple links (it is not found in either Debian uscan or Gentoo euscan), the main expression is in one file and is less different from usual style. --- .../upstream-updater/update-walker.sh | 127 ++++++++++++++++++ pkgs/development/compilers/sbcl/default.nix | 11 +- .../compilers/sbcl/default.upstream | 9 ++ .../compilers/sbcl/src-for-default.nix | 9 -- .../compilers/sbcl/src-info-for-default.nix | 7 - 5 files changed, 146 insertions(+), 17 deletions(-) create mode 100755 pkgs/build-support/upstream-updater/update-walker.sh create mode 100644 pkgs/development/compilers/sbcl/default.upstream delete mode 100644 pkgs/development/compilers/sbcl/src-for-default.nix delete mode 100644 pkgs/development/compilers/sbcl/src-info-for-default.nix diff --git a/pkgs/build-support/upstream-updater/update-walker.sh b/pkgs/build-support/upstream-updater/update-walker.sh new file mode 100755 index 00000000000..12b12a11e89 --- /dev/null +++ b/pkgs/build-support/upstream-updater/update-walker.sh @@ -0,0 +1,127 @@ +#! /bin/sh + +own_dir="$(cd "$(dirname "$0")"; pwd)" + +CURRENT_URL= + +url () { + CURRENT_URL="$1" +} + +version_unpack () { + sed -re ' + s/[.]/ /g; + s@/@ / @g + s/-(rc|pre)/ -1 \1 /g; + s/-(gamma)/ -2 \1 /g; + s/-(beta)/ -3 \1 /g; + s/-(alpha)/ -4 \1 /g; + ' +} + +version_repack () { + sed -re ' + s/ -[0-9]+ ([a-z]+) /-\1/g; + s@ / @/@g + s/ /./g; + ' +} + +version_sort () { + version_unpack | + sort -t ' ' -k 1n -k 2n -k 3n -k 4n -k 5n -k 6n -k 7n -n | tac | + version_repack +} + +position_choice () { + head -n "${1:-1}" | tail -n "${2:-1}" +} + +matching_links () { + "$own_dir"/urls-from-page.sh "$CURRENT_URL" | grep -E "$1" +} + +link () { + CURRENT_URL="$(matching_links "$1" | position_choice "$2" "$3")" + echo "Linked by: $*" + echo "URL: $CURRENT_URL" >&2 +} + +version_link () { + CURRENT_URL="$(matching_links "$1" | version_sort | position_choice "$2" "$3")" + echo "Linked version by: $*" + echo "URL: $CURRENT_URL" >&2 +} + +redirect () { + CURRENT_URL="$(curl -I -L --max-redirs "${1:-99}" "$CURRENT_URL" | + grep -E '^Location: ' | position_choice "${2:-999999}" "$3" | + sed -e 's/^Location: //; s/\r//')" + echo "Redirected: $*" + echo "URL: $CURRENT_URL" >&2 +} + +replace () { + sed -re "s $1 $2 g" +} + +process () { + CURRENT_URL="$(echo "$CURRENT_URL" | replace "$1" "$2")" + echo "Processed: $*" + echo "URL: $CURRENT_URL" >&2 +} + +version () { + CURRENT_VERSION="$(echo "$CURRENT_URL" | replace "$1" "$2")" + echo "Version: $CURRENT_VERSION" >&2 +} + +hash () { + CURRENT_HASH="$(nix-prefetch-url "$CURRENT_URL")" +} + +name () { + CURRENT_NAME="$1" +} + +retrieve_version () { + PACKAGED_VERSION="$(nix-instantiate --eval-only '' -A "$CURRENT_NAME".meta.version | xargs)" +} + +target () { + CURRENT_TARGET="$1" +} + +update_found () { + echo "Compare: $CURRENT_VERSION vs $PACKAGED_VERSION" + [ "$CURRENT_VERSION" != "$PACKAGED_VERSION" ] +} + +do_regenerate () { + cat "$1" | grep -F '# Generated upstream information' -B 999999; + echo " rec {" + echo " baseName=\"$CURRENT_NAME\";" + echo " version=\"$CURRENT_VERSION\";" + echo ' name="${baseName}-${version}";' + echo " hash=\"$CURRENT_HASH\";" + echo " url=\"$CURRENT_URL\";" + cat "$1" | grep -F '# Generated upstream information' -A 999999 | grep -E '^ *[}]; *$' -A 999999; +} + +do_overwrite () { + hash + do_regenerate "$1" > "$1.new.tmp" + mv "$1.new.tmp" "$1" +} + +full_path () { + echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" +} + +process_config () { + source "$(full_path "$1")" + retrieve_version + update_found && do_overwrite "$CURRENT_TARGET" +} + +process_config "$1" diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix index eb3f47a15c0..adffb7c5074 100644 --- a/pkgs/development/compilers/sbcl/default.nix +++ b/pkgs/development/compilers/sbcl/default.nix @@ -1,7 +1,14 @@ a : let fetchurl = a.fetchurl; - s= import ./src-for-default.nix; + s= # Generated upstream information + rec { + baseName="sbcl"; + version="1.1.1"; + name="${baseName}-${version}"; + hash="1gkwz0248zl2nhx79ck5wiyxj8407c10gcrpgg1c67102pgyiikv"; + url="mirror://sourceforge/project/sbcl/sbcl/1.1.1/sbcl-1.1.1-source.tar.bz2"; + }; buildInputs = with a; [ clisp makeWrapper ]; @@ -73,12 +80,14 @@ rec { '') ["doBuild" "minInit" "addInputs"]; inherit(s) name; + inherit(s) version; meta = { description = "Lisp compiler"; homepage = "http://www.sbcl.org"; license = "bsd"; maintainers = [a.lib.maintainers.raskin]; platforms = with a.lib.platforms; all; + inherit(s) version; }; } diff --git a/pkgs/development/compilers/sbcl/default.upstream b/pkgs/development/compilers/sbcl/default.upstream new file mode 100644 index 00000000000..de69a2828c6 --- /dev/null +++ b/pkgs/development/compilers/sbcl/default.upstream @@ -0,0 +1,9 @@ +name sbcl +target default.nix +url http://sf.net/projects/sbcl/files/sbcl/ +version_link '/sbcl/[0-9.]+/$' +link "source.tar.bz2" +version '.*/sbcl-([0-9.]+)-source.*' '\1' +redirect +process 'http://[a-z]+[.]dl[.]sourceforge[.]net/' 'mirror://sourceforge/' +process '[?].*' '' diff --git a/pkgs/development/compilers/sbcl/src-for-default.nix b/pkgs/development/compilers/sbcl/src-for-default.nix deleted file mode 100644 index fc23f901e5a..00000000000 --- a/pkgs/development/compilers/sbcl/src-for-default.nix +++ /dev/null @@ -1,9 +0,0 @@ -rec { - version="1.1.0"; - name="sbcl-1.1.0"; - hash="128zb7i6w2a93yjvh8mc6f36w47psnda671y81a9yl6mr5696k00"; - url="http://downloads.sourceforge.net/project/sbcl/sbcl/1.1.0/sbcl-1.1.0-source.tar.bz2"; - advertisedUrl="http://downloads.sourceforge.net/project/sbcl/sbcl/1.1.0/sbcl-1.1.0-source.tar.bz2"; - - -} diff --git a/pkgs/development/compilers/sbcl/src-info-for-default.nix b/pkgs/development/compilers/sbcl/src-info-for-default.nix deleted file mode 100644 index 597aded1792..00000000000 --- a/pkgs/development/compilers/sbcl/src-info-for-default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - baseName = "sbcl"; - downloadPage = "http://sourceforge.net/projects/sbcl/files/sbcl/"; - choiceCommand = "head -n 1 | sed -re 's%.*/([0-9.]+)/%http://downloads.sourceforge.net/project/sbcl/sbcl/\\1/sbcl-\\1-source.tar.bz2%'"; - sourceRegexp = "[/][0-9.]+/\$"; - versionExtractorSedScript = "s/.*-([0-9.rc]+)-.*/\\1/"; -}