Skip to content

Commit 6521643

Browse files
committed
feat: add update.sh script to teku
1 parent e5851a2 commit 6521643

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

pkgs/teku/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
2424
wrapProgram $out/bin/${pname} --set JAVA_HOME "${jre}"
2525
'';
2626

27-
passtrhu.updateScript = ./update.sh;
27+
passthru.updateScript = ./update.sh;
2828

2929
meta = with lib; {
3030
description = "Java Implementation of the Ethereum 2.0 Beacon Chain";

pkgs/teku/update.sh

100644100755
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env nix-shell
22
#!nix-shell -i bash -p curl jq nix sd
33

4-
set -e
4+
set -ex
55

66
dirname="$(dirname "$0")"
77
rootDir="$(git -C "$dirname" rev-parse --show-toplevel)"
@@ -15,19 +15,13 @@ updateVersion() {
1515
updateHash() {
1616
local version=$1
1717
local url="https://artifacts.consensys.net/public/${pname}/raw/names/${pname}.tar.gz/versions/${version}/${pname}-${version}.tar.gz"
18-
19-
local output=$(nix store prefetch-file --json "$url")
20-
local sriHash=$(echo "$output" | jq -r .hash)
21-
22-
sd "\"hash\" = \"[a-zA-Z0-9\/+-=]*\";" "\"hash\" = \"$sriHash\";" "${dirname}/default.nix"
18+
local sriHash=$(nix store prefetch-file --json "$url" | jq -r '.hash')
19+
sd 'hash = "[a-zA-Z0-9/+-=]*";' "hash = \"$sriHash\";" "${dirname}/default.nix"
2320
}
2421

25-
currentVersion=$(nix show-derivation "${rootDir}#${pname}" | jq -r '.[].env.version')
22+
currentVersion=$(nix derivation show "${rootDir}#${pname}" | jq -r '.[].env.version')
2623
latestVersion=$(curl -s "https://api.github.com/repos/ConsenSys/teku/releases/latest" | jq -r '.tag_name')
2724

28-
# Optionally strip leading 'v' if present in the tag name
29-
latestVersion=${latestVersion#v}
30-
3125
if [[ "$currentVersion" == "$latestVersion" ]]; then
3226
echo "${pname} is up to date: ${currentVersion}"
3327
exit 0

0 commit comments

Comments
 (0)