From 648f1f96489c29df7d63ec765c28f2c88ab1e3ba Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Sun, 31 Aug 2025 13:58:09 +0300 Subject: [PATCH] yandex-music: workaround of release circle The [repacker project](https://github.com/cucumber-sp/yandex-music-linux) have release circle with moving tags, which breaks package distribution in nixpkgs. This replaces fixing revisions with hashes and implements automatically counting of "rc" parts of version for case of moving tags. Change-Id: I08d800220b0def0b6296ce1b18a9f2217188648e --- pkgs/by-name/ya/yandex-music/package.nix | 3 ++- pkgs/by-name/ya/yandex-music/update.sh | 27 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ya/yandex-music/package.nix b/pkgs/by-name/ya/yandex-music/package.nix index 55d68912fa40..8b6832656389 100644 --- a/pkgs/by-name/ya/yandex-music/package.nix +++ b/pkgs/by-name/ya/yandex-music/package.nix @@ -34,7 +34,8 @@ stdenvNoCC.mkDerivation rec { src = fetchFromGitHub { owner = "cucumber-sp"; repo = "yandex-music-linux"; - rev = "v${version}"; + # tags are retagged for some bug fixes + rev = "066a6c7f503304d2181db04c5ed379a80f9137b8"; hash = "sha256-z+gmUG0/7ykF42+OlFGZC268Tj8+vpfgZRYrW4otpfM="; }; diff --git a/pkgs/by-name/ya/yandex-music/update.sh b/pkgs/by-name/ya/yandex-music/update.sh index c60b8cdf9a2d..67d11fa7e5e2 100755 --- a/pkgs/by-name/ya/yandex-music/update.sh +++ b/pkgs/by-name/ya/yandex-music/update.sh @@ -8,6 +8,7 @@ REPO="yandex-music-linux" URL="https://api.github.com/repos/$OWNER/$REPO" RAW="https://raw.githubusercontent.com/$OWNER/$REPO" +attrname="yandex-music" latest_release="$(curl --silent "$URL/releases/latest")" latest_tag="$(curl --silent "$URL/tags?per_page=1")" commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")" @@ -19,8 +20,32 @@ date=$(jq -r '.created_at' <<<"$latest_release") # truncate time date=${date%T*} +importTree="(let tree = import ./.; in if builtins.isFunction tree then tree {} else tree)" + +# Old version with rc part (e.g. 5.61.1rc3) +oldVersion=$(nix-instantiate --eval -E "with $importTree; $attrname.version" | tr -d '"') +# Rc part of old version (without "rc) (e.g. 3) +oldVersionRc="${oldVersion##*rc}" + +# If old version does not have "rc" part - assume rc is 0 +if [ "$oldVersionRc" == "$oldVersion" ]; then + oldVersionRc="0" +fi +# Old version w/o rc part (e.g 5.61.1) +oldVersion="${oldVersion%%rc*}" +# Remove "rc" part from new version. There should be no "rc" part at all but +# better to play it safe. +version="${version%%rc*}" + +rc="" + +# If new version is the same as old version - increase rc and format rc part +if [ "$version" == "$oldVersion" ]; then + rc="rc$((oldVersionRc + 1))"; +fi + # update version; otherwise fail -update-source-version yandex-music "$version" --ignore-same-hash +update-source-version "$attrname" "$version$rc" --ignore-same-hash --rev="$commit_hash" # set yandex-music dir dir="pkgs/by-name/ya/yandex-music"