mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
warp-terminal: don't use nix-prefetch-url in update.sh
use fetchurl to calculate hash in update.sh to workaround a bug in nix-prefetch-url. nix-prefetch-url seems to be uncompressing and then calculating the hash when downloading the new warp-terminal. this results in hash mismatch errors as fetchurl calculates the hash using the compressed archive.
This commit is contained in:
parent
e6aefe20a1
commit
3c42579af9
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq moreutils nix-prefetch
|
||||
#!nix-shell -i bash -p cacert curl jq nix moreutils --pure
|
||||
#shellcheck shell=bash
|
||||
set -eu -o pipefail
|
||||
|
||||
@ -7,6 +7,7 @@ dirname="$(dirname "$0")"
|
||||
|
||||
err() {
|
||||
echo "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
json_get() {
|
||||
@ -31,7 +32,6 @@ resolve_url() {
|
||||
;;
|
||||
*)
|
||||
err "Unexpected download type: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
url="https://app.warp.dev/download?package=${pkg}"
|
||||
@ -40,7 +40,7 @@ resolve_url() {
|
||||
url=$(curl -s -o /dev/null -w '%{redirect_url}' "${url}")
|
||||
[[ ${url} != *.${sfx} ]] || break
|
||||
done
|
||||
((i < max_redirects)) || { err "too many redirects"; exit 1; }
|
||||
((i < max_redirects)) || { err "too many redirects"; }
|
||||
echo "${url}"
|
||||
}
|
||||
|
||||
@ -48,13 +48,27 @@ get_version() {
|
||||
echo "$1" | grep -oP -m 1 '(?<=/v)[\d.\w]+(?=/)'
|
||||
}
|
||||
|
||||
# nix-prefect-url seems to be uncompressing the archive then taking the hash
|
||||
# so just get the hash from fetchurl
|
||||
sri_get() {
|
||||
local ouput sri
|
||||
output=$(nix-build --expr \
|
||||
'with import <nixpkgs>{};
|
||||
fetchurl {
|
||||
url = "'"$1"'";
|
||||
}' 2>&1 || true)
|
||||
sri=$(echo "$output" | awk '/^\s+got:\s+/{ print $2 }')
|
||||
[[ -z "$sri" ]] && err "$output"
|
||||
echo "$sri"
|
||||
}
|
||||
|
||||
|
||||
for sys in darwin linux; do
|
||||
url=$(resolve_url ${sys})
|
||||
version=$(get_version "${url}")
|
||||
if [[ ${version} != "$(json_get ".${sys}.version")" ]];
|
||||
then
|
||||
sri=$(nix hash to-sri --type sha256 "$(nix-prefetch-url --type sha256 "${url}")")
|
||||
json_set ".${sys}.version" "${version}"
|
||||
json_set ".${sys}.hash" "${sri}"
|
||||
if [[ ${version} != "$(json_get ".${sys}.version")" ]]; then
|
||||
sri=$(sri_get "${url}")
|
||||
json_set ".${sys}.version" "${version}"
|
||||
json_set ".${sys}.hash" "${sri}"
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user