lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 22.05-pre 88 lines 2.8 kB view raw
1#!/usr/bin/env nix-shell 2#! nix-shell -i bash -p curl jq git gnused gnugrep 3 4 5# executing this script without arguments will 6# - find the newest stable spotify version avaiable on snapcraft (https://snapcraft.io/spotify) 7# - read the current spotify version from the current nix expression 8# - update the nix expression if the versions differ 9# - try to build the updated version, exit if that fails 10# - give instructions for upstreaming 11 12# Please test the update manually before pushing. There have been errors before 13# and because the service is proprietary and a paid account is necessary to do 14# anything with spotify automatic testing is not possible. 15 16# As an optional argument you can specify the snapcraft channel to update to. 17# Default is `stable` and only stable updates should be pushed to nixpkgs. For 18# testing you may specify `candidate` or `edge`. 19 20 21channel="${1:-stable}" # stable/candidate/edge 22nixpkgs="$(git rev-parse --show-toplevel)" 23spotify_nix="$nixpkgs/pkgs/applications/audio/spotify/default.nix" 24 25 26# 27# find the newest stable spotify version avaiable on snapcraft 28# 29 30# create bash array from snap info 31snap_info=($( 32 curl -s -H 'X-Ubuntu-Series: 16' \ 33 "https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=$channel" \ 34 | jq --raw-output \ 35 '.revision,.download_sha512,.version,.last_updated' 36)) 37 38# "revision" is the actual version identifier on snapcraft, the "version" is 39# just for human consumption. Revision is just an integer that gets increased 40# by one every (stable or unstable) release. 41revision="${snap_info[0]}" 42sha512="${snap_info[1]}" 43upstream_version="${snap_info[2]}" 44last_updated="${snap_info[3]}" 45 46echo "Latest $channel release is $upstream_version from $last_updated." 47 48# 49# read the current spotify version from the currently *committed* nix expression 50# 51 52current_nix_version=$( 53 grep 'version\s*=' "$spotify_nix" \ 54 | sed -Ene 's/.*"(.*)".*/\1/p' 55) 56 57echo "Current nix version: $current_nix_version" 58 59# 60# update the nix expression if the versions differ 61# 62 63if [[ "$current_nix_version" = "$upstream_version" ]]; then 64 echo "Spotify is already up-to-date" 65 exit 0 66fi 67 68echo "Updating from ${current_nix_version} to ${upstream_version}, released on ${last_updated}" 69 70# search-and-replace revision, hash and version 71sed --regexp-extended \ 72 -e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \ 73 -e 's/sha512\s*=\s*"[^"]*"\s*;/sha512 = "'"${sha512}"'";/' \ 74 -e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \ 75 -i "$spotify_nix" 76 77# 78# try to build the updated version 79# 80 81if ! nix-build -A spotify "$nixpkgs"; then 82 echo "The updated spotify failed to build." 83 exit 1 84fi 85 86# Commit changes 87git add "$spotify_nix" 88git commit -m "spotify: ${current_nix_version} -> ${upstream_version}"