cassandra: Make updateScript update individual version
This commit is contained in:
parent
ab55499253
commit
0038244d60
|
@ -16,6 +16,7 @@
|
|||
, version
|
||||
, sha256
|
||||
, extraMeta ? { }
|
||||
, callPackage
|
||||
, ...
|
||||
}:
|
||||
|
||||
|
@ -114,7 +115,7 @@ stdenv.mkDerivation rec {
|
|||
test;
|
||||
};
|
||||
|
||||
updateScript = ./update.sh;
|
||||
updateScript = callPackage ./update-script.nix { inherit generation; };
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
|
|
45
pkgs/servers/nosql/cassandra/update-script.nix
Normal file
45
pkgs/servers/nosql/cassandra/update-script.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{ git
|
||||
, lib
|
||||
, runtimeShell
|
||||
, writeScript
|
||||
, generation
|
||||
}:
|
||||
let
|
||||
inherit (lib) makeBinPath;
|
||||
filename = lib.strings.replaceStrings [ "_" ] [ "." ] generation + ".nix";
|
||||
regex = lib.strings.replaceStrings [ "_" ] [ "[.]" ] generation;
|
||||
in
|
||||
writeScript "update-cassandra_${generation}" ''
|
||||
#!${runtimeShell}
|
||||
set -eux -o pipefail
|
||||
test -d pkgs -a -d nixos -a -d lib || {
|
||||
echo >&2 "$0 expects to be run in a nixpkgs checkout"
|
||||
exit 1
|
||||
}
|
||||
cd pkgs/servers/nosql/cassandra
|
||||
PATH="${makeBinPath [git]}:$PATH"
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# get numeric-only versions, sort them latest first
|
||||
git ls-remote --tags https://github.com/apache/cassandra \
|
||||
| awk '{ if (match($0, /refs.tags.cassandra-([0-9.]*)$/, m)) print m[1] }' \
|
||||
| sort -V \
|
||||
| tac >$tmp/versions
|
||||
|
||||
version="$(grep -E '^${regex}' <$tmp/versions | head -n 1)"
|
||||
hash="$(nix-prefetch-url "mirror://apache/cassandra/$version/apache-cassandra-$version-bin.tar.gz")"
|
||||
cat >${filename} <<EOF
|
||||
# GENERATED BY update.sh
|
||||
{ callPackage, ... } @ args:
|
||||
callPackage ./generic.nix (args // {
|
||||
version = "$version";
|
||||
sha256 = "$hash";
|
||||
generation = "${generation}";
|
||||
})
|
||||
EOF
|
||||
''
|
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash
|
||||
#!nix-shell -p git
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
set -eux -o pipefail
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# get numeric-only versions, sort them latest first
|
||||
git ls-remote --tags https://github.com/apache/cassandra \
|
||||
| awk '{ if (match($0, /refs.tags.cassandra-([0-9.]*)$/, m)) print m[1] }' \
|
||||
| sort -V \
|
||||
| tac >$tmp/versions
|
||||
|
||||
version="$(grep -E '3[.]11[.]' <$tmp/versions | head -n 1)"
|
||||
hash="$(nix-prefetch-url "mirror://apache/cassandra/${version}/apache-cassandra-${version}-bin.tar.gz")"
|
||||
cat >3.11.nix <<EOF
|
||||
# GENERATED BY update.sh
|
||||
{ callPackage, ... } @ args:
|
||||
callPackage ./generic.nix (args // {
|
||||
version = "$version";
|
||||
sha256 = "$hash";
|
||||
generation = "3_11";
|
||||
})
|
||||
EOF
|
||||
|
||||
version="$(grep -E '3[.]0[.]' <$tmp/versions | head -n 1)"
|
||||
hash="$(nix-prefetch-url "mirror://apache/cassandra/${version}/apache-cassandra-${version}-bin.tar.gz")"
|
||||
cat >3.0.nix <<EOF
|
||||
# GENERATED BY update.sh
|
||||
{ callPackage, ... } @ args:
|
||||
callPackage ./generic.nix (args // {
|
||||
version = "$version";
|
||||
sha256 = "$hash";
|
||||
generation = "3_0";
|
||||
})
|
||||
EOF
|
Loading…
Reference in a new issue