1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p cacert curl jq nix moreutils --pure
15 jq
-r "$1" < "./versions.json"
19 jq
--arg x
"$2" "$1 = \$x" < "./versions.json" | sponge
"./versions.json"
24 local -i i max_redirects
39 err
"Unexpected download type: $1"
42 url
="https://app.warp.dev/download?package=${pkg}"
43 ((max_redirects
= 15))
44 for ((i
= 0; i
< max_redirects
; i
++)); do
45 url
=$
(curl
-s -o /dev
/null
-w '%{redirect_url}' "${url}")
46 [[ ${url} != *.
${sfx} ]] ||
break
48 ((i
< max_redirects
)) ||
{ err
"too many redirects"; }
53 echo "$1" |
grep -oP -m 1 '(?<=/v)[\d.\w]+(?=/)'
56 # nix-prefect-url seems to be uncompressing the archive then taking the hash
57 # so just get the hash from fetchurl
60 output
=$
(nix-build
--expr \
61 "with import $nixpkgs {};
65 sri
=$
(echo "$output" |
awk '/^\s+got:\s+/{ print $2 }')
66 [[ -z "$sri" ]] && err
"$output"
71 for sys
in darwin linux_x86_64 linux_aarch64
; do
73 url
=$
(resolve_url
${sys})
74 version
=$
(get_version
"${url}")
75 if [[ ${version} != "$(json_get ".
${sys}.version
")" ]]; then
76 sri
=$
(sri_get
"${url}")
77 json_set
".${sys}.version" "${version}"
78 json_set
".${sys}.hash" "${sri}"