From 55fa3c1180fc2a4fde3cea0c718ede99aa9770a7 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Sat, 6 Apr 2019 13:11:58 -0400 Subject: [PATCH] spotify: Auto-commit on update Also, replace tabs with spaces --- pkgs/applications/audio/spotify/update.sh | 40 +++++++++-------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/pkgs/applications/audio/spotify/update.sh b/pkgs/applications/audio/spotify/update.sh index 0e19ca1920b..e4f2f41a785 100755 --- a/pkgs/applications/audio/spotify/update.sh +++ b/pkgs/applications/audio/spotify/update.sh @@ -29,10 +29,10 @@ spotify_nix="$nixpkgs/pkgs/applications/audio/spotify/default.nix" # create bash array from snap info snap_info=($( - curl -H 'X-Ubuntu-Series: 16' \ - "https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=$channel" \ - | jq --raw-output \ - '.revision,.download_sha512,.version,.last_updated' + curl -H 'X-Ubuntu-Series: 16' \ + "https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=$channel" \ + | jq --raw-output \ + '.revision,.download_sha512,.version,.last_updated' )) # "revision" is the actual version identifier on snapcraft, the "version" is @@ -50,8 +50,8 @@ echo "Latest $channel release is $upstream_version from $last_updated." # current_nix_version=$( - grep 'version\s*=' "$spotify_nix" \ - | sed -Ene 's/.*"(.*)".*/\1/p' + grep 'version\s*=' "$spotify_nix" \ + | sed -Ene 's/.*"(.*)".*/\1/p' ) echo "Current nix version: $current_nix_version" @@ -61,36 +61,28 @@ echo "Current nix version: $current_nix_version" # if [[ "$current_nix_version" = "$upstream_version" ]]; then - echo "Spotify is already up ot date" - exit 0 + echo "Spotify is already up ot date" + exit 0 fi echo "Updating from ${current_nix_version} to ${upstream_version}, released on ${last_updated}" # search-and-replace revision, hash and version sed --regexp-extended \ - -e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \ - -e 's/sha512\s*=\s*"[^"]*"\s*;/sha512 = "'"${sha512}"'";/' \ - -e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \ - -i "$spotify_nix" + -e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \ + -e 's/sha512\s*=\s*"[^"]*"\s*;/sha512 = "'"${sha512}"'";/' \ + -e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \ + -i "$spotify_nix" # # try to build the updated version # if ! nix-build -A spotify "$nixpkgs"; then - echo "The updated spotify failed to build." - exit 1 + echo "The updated spotify failed to build." + exit 1 fi -# -# give instructions for upstreaming -# - +# Commit changes git add "$spotify_nix" -# show changes for review -git status -echo 'Please review and test the changes (./result/bin/spotify).' -echo 'Then stage the changes with `git add` and commit with:' -# prepare commit message -echo "git commit -m 'spotify: $current_nix_version -> $upstream_version'" +git commit -m "spotify: ${current_nix_version} -> ${upstream_version}"