···1#! /usr/bin/env nix-shell
2-#! nix-shell -i bash -p coreutils gnused curl jq nix-prefetch
3set -euo pipefail
4cd "$(dirname "${BASH_SOURCE[0]}")"
56DRV_DIR="$PWD"
78OLD_VERSION="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
9-# The best_release.json is not always up-to-date
10-# In those cases you can force the version by calling `./update.sh <newer_version>`
11-NEW_VERSION="${1:-$(curl -H "Accept: application/json" 'https://sourceforge.net/projects/sevenzip/best_release.json' | jq '.platform_releases.linux.filename' -r | cut -d/ -f3)}"
1213echo "comparing versions $OLD_VERSION => $NEW_VERSION"
14if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
···26NEW_VERSION_FORMATTED="$(echo "$NEW_VERSION" | tr -d '.')"
27URL="https://7-zip.org/a/7z${NEW_VERSION_FORMATTED}-src.tar.xz"
280002930-NEW_FREE_HASH=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "_7zz.src" --url "$URL")
31-32-NEW_UNFREE_OUT=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "(_7zz.override { enableUnfree = true; }).src" --url "$URL" --output raw --print-path)
33# first line of raw output is the hash
34NEW_UNFREE_HASH="$(echo "$NEW_UNFREE_OUT" | sed -n 1p)"
35# second line of raw output is the src path
···1#! /usr/bin/env nix-shell
2+#! nix-shell -i bash -p curl xq-xml nix-prefetch
3set -euo pipefail
4cd "$(dirname "${BASH_SOURCE[0]}")"
56DRV_DIR="$PWD"
78OLD_VERSION="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
9+NEW_VERSION="$(curl -H 'Accept: application/rss+xml' 'https://sourceforge.net/projects/sevenzip/rss?path=/7-Zip' | xq -x "substring((/rss/channel/item[link[contains(., 'src.tar.xz')]])[1]/title, 8, 5)")"
001011echo "comparing versions $OLD_VERSION => $NEW_VERSION"
12if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
···24NEW_VERSION_FORMATTED="$(echo "$NEW_VERSION" | tr -d '.')"
25URL="https://7-zip.org/a/7z${NEW_VERSION_FORMATTED}-src.tar.xz"
2627+# `nix-prefetch` is broken without flakes
28+# see https://github.com/msteen/nix-prefetch/issues/51
29+NEW_FREE_HASH=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "_7zz.src" --url "$URL" --option extra-experimental-features flakes)
3031+NEW_UNFREE_OUT=$(nix-prefetch -f "$NIXPKGS_ROOT" -E "(_7zz.override { enableUnfree = true; }).src" --url "$URL" --output raw --print-path --option extra-experimental-features flakes)
0032# first line of raw output is the hash
33NEW_UNFREE_HASH="$(echo "$NEW_UNFREE_OUT" | sed -n 1p)"
34# second line of raw output is the src path