nixos/kubernetes/kubelet: Fix sandbox image load on containerd 2.x (#364558)
[NixPkgs.git] / pkgs / applications / audio / plexamp / update-plexamp.sh
blob44ad9b9250147682bdc4dde4c53de3e7fccfbdf2
1 #! /usr/bin/env nix-shell
2 #! nix-shell -p yq bash curl bc ripgrep
3 #! nix-shell -i bash
5 set -Eeuxo pipefail
7 cleanup() {
8 rm -rf "$TMPDIR"
11 trap cleanup EXIT
13 ROOT="$(dirname "$(readlink -f "$0")")"
14 if [ ! -f "$ROOT/default.nix" ]; then
15 echo "ERROR: cannot find default.nix in $ROOT"
16 exit 1
19 if [ "$(basename "$ROOT")" != plexamp ]; then
20 echo "ERROR: folder not named plexamp"
21 exit 1
24 TMPDIR="$(mktemp -d)"
26 VERSION_FILE="$TMPDIR/version.yml"
27 VERSION_URL="https://plexamp.plex.tv/plexamp.plex.tv/desktop/latest-linux.yml"
28 curl "$VERSION_URL" -o "$VERSION_FILE"
30 VERSION="$(yq -r .version "$VERSION_FILE")"
31 SHA512="$(yq -r .sha512 "$VERSION_FILE")"
33 DEFAULT_NIX="$ROOT/default.nix"
34 WORKING_NIX="$TMPDIR/default.nix"
35 cp "$DEFAULT_NIX" "$WORKING_NIX"
37 sed -i "s@version = .*;@version = \"$VERSION\";@g" "$WORKING_NIX"
39 if diff "$DEFAULT_NIX" "$WORKING_NIX"; then
40 echo "WARNING: no changes"
41 exit 0
44 # update sha hash (convenietly provided)
45 sed -i "s@hash.* = .*;@hash = \"sha512-$SHA512\";@g" "$WORKING_NIX"
47 # update the changelog ("just" increment the number)
48 # manually check that the changelog corresponds to our Plexamp version
49 CHANGELOG_URL=$(rg --only-matching 'changelog = "(.+)";' --replace '$1' $WORKING_NIX)
50 CHANGELOG_NUMBER=$(rg --only-matching '.*/([0-9]+)' --replace '$1' <<< $CHANGELOG_URL)
51 NEXT_CHANGELOG=$(($CHANGELOG_NUMBER + 1))
52 NEXT_URL=$(rg --only-matching '(.*)/[0-9]+' --replace "\$1/$NEXT_CHANGELOG" <<< $CHANGELOG_URL)
53 sed -i "s@changelog = \".*\";@changelog = \"$NEXT_URL\";@" $WORKING_NIX
55 mv $WORKING_NIX $DEFAULT_NIX