1 #!/usr/bin/env nix-shell
2 #! nix-shell -i oil -p jq moreutils nix-prefetch-github gnused
4 # TODO set to `verbose` or `extdebug` once implemented in oil
6 # we need failures inside of command subs to get the correct cargoHash
7 shopt --unset inherit_errexit
9 const directory
= $
(dirname $0 |
xargs realpath
)
10 const owner
= "solana-labs"
12 const latest_rev
= $
(curl
-q https
://api.github.com
/repos
/${owner}/${repo}/releases
/latest | \
14 const latest_version
= $
(echo ${latest_rev#v})
15 const current_version
= $
(jq
-r '.version' $directory/pin.json
)
16 if ("$latest_version" === "$current_version") {
17 echo "solana is already up-to-date"
20 const tarball_meta
= $
(nix-prefetch-github
$owner $repo --rev "$latest_rev")
21 const tarball_hash
= $
(echo $tarball_meta | jq
-r '.hash')
23 jq
".version = \"$latest_version\" | \
24 .\"hash\" = \"$tarball_hash\" | \
25 .\"cargoHash\" = \"\"" $directory/pin.json | sponge
$directory/pin.json
27 const new_cargo_hash
= $
(nix-build
-A solana-validator
2>&1 | \
32 jq
".cargoHash = \"$new_cargo_hash\"" $directory/pin.json | sponge
$directory/pin.json