Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 44 lines 1.7 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p common-updater-scripts coreutils grep jq squashfsTools 3 4set -eu -o pipefail 5 6RELEASES=$(curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/chromium-ffmpeg) 7STABLE_RELEASES=$(echo $RELEASES | jq '."channel-map" | .[] | select(.channel.risk=="stable")') 8 9function max_version() { 10 local versions=$(echo $1 | jq -r '.version') 11 echo "$(echo $versions | grep -E -o '^[0-9]+')" 12} 13 14function update_source() { 15 local platform=$1 16 local selectedRelease=$2 17 local version=$3 18 local url=$(echo $selectedRelease | jq -r '.download.url') 19 source="$(nix-prefetch-url "$url")" 20 hash=$(nix-hash --to-sri --type sha256 "$source") 21 update-source-version vivaldi-ffmpeg-codecs "$version" "$hash" "$url" --ignore-same-version --system=$platform --source-key="sources.$platform" 22} 23 24x86Release="$(echo $STABLE_RELEASES | jq 'select(.channel.architecture=="amd64")')" 25x86CodecVersion=$(max_version "$x86Release") 26arm64Release="$(echo $STABLE_RELEASES | jq -r 'select(.channel.architecture=="arm64")')" 27arm64CodecVersion=$(max_version "$arm64Release") 28 29currentVersion=$(nix-instantiate --eval -E "with import ./. {}; vivaldi-ffmpeg-codecs.version or (lib.getVersion vivaldi-ffmpeg-codecs)" | tr -d '"') 30 31if [[ "$currentVersion" == "$x86CodecVersion" ]]; then 32 exit 0 33fi 34 35# If this fails too often, consider finding the max common version between the two architectures 36if [[ "$x86CodecVersion" != "$arm64CodecVersion" ]]; then 37 >&2 echo "Multiple chromium versions found: $x86CodecVersion (intel) and $arm64CodecVersion (arm); no update" 38 exit 1 39fi 40 41 42 43update_source "x86_64-linux" "$x86Release" "$x86CodecVersion" 44update_source "aarch64-linux" "$arm64Release" "$arm64CodecVersion"