element-{desktop,web-unwrapped}: {fix,modernize} update script
- Does not fetch `-rc` versions anymore - Fixes weird output by `prefetch-yarn-deps` (see https://github.com/NixOS/nixpkgs/pull/407704#issue-3069691545) - Doesn't create any temporary files anymore, since everything is prefetched local builds will be faster too - DRY
This commit is contained in:
parent
1dbbe4d825
commit
31d520ee18
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
|
#!nix-shell -i bash -p nix coreutils prefetch-yarn-deps jq curl
|
||||||
|
|
||||||
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
|
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
|
||||||
echo "Regenerates packaging data for the element packages."
|
echo "Regenerates packaging data for the element packages."
|
||||||
@ -12,54 +12,49 @@ version="$1"
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
version="$(wget -q -O- "https://api.github.com/repos/element-hq/element-desktop/releases?per_page=1" | jq -r '.[0].tag_name')"
|
version="$(curl -fsSL "https://api.github.com/repos/element-hq/element-desktop/releases/latest" | jq -r '.tag_name')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# strip leading "v"
|
# strip leading "v"
|
||||||
version="${version#v}"
|
version="${version#v}"
|
||||||
|
|
||||||
# Element Web
|
|
||||||
web_src="https://raw.githubusercontent.com/element-hq/element-web/v$version"
|
|
||||||
web_src_hash=$(nix-prefetch-github element-hq element-web --rev v${version} | jq -r .hash)
|
|
||||||
|
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
||||||
|
|
||||||
web_tmpdir=$(mktemp -d)
|
nixflags=(
|
||||||
trap 'rm -rf "$web_tmpdir"' EXIT
|
--extra-experimental-features
|
||||||
|
"nix-command flakes"
|
||||||
|
)
|
||||||
|
|
||||||
pushd $web_tmpdir
|
# HACK: prefetch-yarn-deps hashes may output extra clutter on stdout (!) so
|
||||||
wget -q "$web_src/yarn.lock"
|
# we'll need to get the last line, last word
|
||||||
web_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
fixupHash() {
|
||||||
popd
|
local sorta_yarn_hash="$(tail -n1 <<< "$1")"
|
||||||
|
local almost_yarn_hash="${sorta_yarn_hash##* }"
|
||||||
|
local yarn_hash="$(nix "${nixflags[@]}" hash convert --hash-algo sha256 "$almost_yarn_hash")"
|
||||||
|
|
||||||
# Element Desktop
|
printf "%s" "$yarn_hash"
|
||||||
desktop_src="https://raw.githubusercontent.com/element-hq/element-desktop/v$version"
|
}
|
||||||
desktop_src_hash=$(nix-prefetch-github element-hq element-desktop --rev v${version} | jq -r .hash)
|
|
||||||
|
|
||||||
desktop_tmpdir=$(mktemp -d)
|
getHashes() {
|
||||||
trap 'rm -rf "$desktop_tmpdir"' EXIT
|
variant="$1"
|
||||||
|
output="$2"
|
||||||
|
|
||||||
pushd $desktop_tmpdir
|
local url="github:element-hq/element-$variant/v$version"
|
||||||
wget -q "$desktop_src/yarn.lock"
|
local src="$(nix "${nixflags[@]}" flake prefetch --json "$url")"
|
||||||
desktop_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
local src_hash="$(jq -r ".hash" <<< "$src")"
|
||||||
popd
|
local src_path="$(jq -r ".storePath" <<< "$src")"
|
||||||
|
local yarn_hash="$(fixupHash "$(prefetch-yarn-deps "$src_path/yarn.lock")")"
|
||||||
|
|
||||||
cat > ../element-web-unwrapped/element-web-pin.nix << EOF
|
cat > "$output" << EOF
|
||||||
{
|
{
|
||||||
"version" = "$version";
|
"version" = "$version";
|
||||||
"hashes" = {
|
"hashes" = {
|
||||||
"webSrcHash" = "$web_src_hash";
|
"${variant}SrcHash" = "$src_hash";
|
||||||
"webYarnHash" = "$web_yarn_hash";
|
"${variant}YarnHash" = "$yarn_hash";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
cat > element-desktop-pin.nix << EOF
|
getHashes web ../element-web-unwrapped/element-web-pin.nix
|
||||||
{
|
getHashes desktop element-desktop-pin.nix
|
||||||
"version" = "$version";
|
|
||||||
"hashes" = {
|
|
||||||
"desktopSrcHash" = "$desktop_src_hash";
|
|
||||||
"desktopYarnHash" = "$desktop_yarn_hash";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user