mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-25 06:44:38 +03:00
Merge pull request #17 from ein-shved/main
[nix] Add to version bumping script
This commit is contained in:
commit
558db5e840
@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
description = "Native Yandex Music desktop client";
|
description = "Native Yandex Music desktop client";
|
||||||
inputs = {
|
inputs = {
|
||||||
ymExe = {
|
ymExe.url = https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.8.exe;
|
||||||
url = https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.8.exe;
|
ymExe.flake = false;
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
outputs = { self, ymExe, nixpkgs, flake-utils }:
|
outputs = { self, ymExe, nixpkgs, flake-utils }:
|
||||||
let
|
let
|
||||||
@ -23,6 +21,7 @@
|
|||||||
yandex-music-backgroud = yandex-music.override {
|
yandex-music-backgroud = yandex-music.override {
|
||||||
fixQuit = false;
|
fixQuit = false;
|
||||||
};
|
};
|
||||||
|
generate_packages = pkgs.callPackage ./nix/generate_packages.nix {};
|
||||||
default = yandex-music;
|
default = yandex-music;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,43 +2,85 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
TEMPDIR=
|
||||||
|
exe_link=
|
||||||
|
version=
|
||||||
|
exe_name=
|
||||||
|
exe_sha256=
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
rm -rf "$TEMPDIR"
|
rm -rf "$TEMPDIR"
|
||||||
}
|
}
|
||||||
TEMPDIR="$(mktemp -d)"
|
TEMPDIR="$(mktemp -d)"
|
||||||
trap clear EXIT
|
trap clear EXIT
|
||||||
|
|
||||||
# loading json from file https://music-desktop-application.s3.yandex.net/stable/download.json
|
check_dep() {
|
||||||
curl -s https://music-desktop-application.s3.yandex.net/stable/download.json > "$TEMPDIR"/download.json
|
if ! command -v "$@" &>/dev/null; then
|
||||||
|
echo "$@" not installed. >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
exe_link=$(jq -r '.windows' "$TEMPDIR"/download.json)
|
check_deps() {
|
||||||
version="$(echo "$exe_link" | grep -oP '(?<=x64_).*(?=.exe)')"
|
check_dep sed
|
||||||
exe_name="$(basename "$exe_link")"
|
check_dep curl
|
||||||
|
check_dep jq
|
||||||
|
}
|
||||||
|
|
||||||
echo "Windows url: $exe_link"
|
load_current_version() {
|
||||||
echo "Version: $version"
|
# loading json from file https://music-desktop-application.s3.yandex.net/stable/download.json
|
||||||
echo "Exe name: $exe_name"
|
curl -s https://music-desktop-application.s3.yandex.net/stable/download.json > "$TEMPDIR"/download.json
|
||||||
|
|
||||||
curl "$exe_link" > "$TEMPDIR/$exe_name"
|
exe_link=$(jq -r '.windows' "$TEMPDIR"/download.json)
|
||||||
|
version="$(echo "$exe_link" | grep -oP '(?<=x64_).*(?=.exe)')"
|
||||||
|
exe_name="$(basename "$exe_link")"
|
||||||
|
|
||||||
exe_sha256="$(sha256sum "$TEMPDIR/$exe_name" | awk '{print $1}')"
|
echo "Windows url: $exe_link"
|
||||||
|
echo "Version: $version"
|
||||||
|
echo "Exe name: $exe_name"
|
||||||
|
|
||||||
echo "Exe sha256: $exe_sha256"
|
curl "$exe_link" > "$TEMPDIR/$exe_name"
|
||||||
|
|
||||||
rm -rf ./version_info.json
|
exe_sha256="$(sha256sum "$TEMPDIR/$exe_name" | awk '{print $1}')"
|
||||||
|
|
||||||
echo "{
|
echo "Exe sha256: $exe_sha256"
|
||||||
\"version\": \"$version\",
|
}
|
||||||
\"exe_name\": \"$exe_name\",
|
|
||||||
\"exe_link\": \"$exe_link\",
|
|
||||||
\"exe_sha256\": \"$exe_sha256\"
|
|
||||||
}" > ./version_info.json
|
|
||||||
|
|
||||||
rm -rf ./PKGBUILD
|
update_version() {
|
||||||
cp ./templates/PKGBUILD ./PKGBUILD
|
rm -rf ./version_info.json
|
||||||
|
|
||||||
sed -i "s#%version%#$version#g" ./PKGBUILD
|
cat > ./version_info.json <<EOF
|
||||||
sed -i "s#%release%#1#g" ./PKGBUILD
|
{
|
||||||
sed -i "s#%exe_name%#$exe_name#g" ./PKGBUILD
|
"version": "$version",
|
||||||
sed -i "s#%exe_link%#$exe_link#g" ./PKGBUILD
|
"exe_name": "$exe_name",
|
||||||
sed -i "s#%exe_sha256%#$exe_sha256#g" ./PKGBUILD
|
"exe_link": "$exe_link",
|
||||||
|
"exe_sha256": "$exe_sha256"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update_pkbuild() {
|
||||||
|
cp ./templates/PKGBUILD ./PKGBUILD
|
||||||
|
|
||||||
|
sed -i "s#%version%#$version#g" ./PKGBUILD
|
||||||
|
sed -i "s#%release%#1#g" ./PKGBUILD
|
||||||
|
sed -i "s#%exe_name%#$exe_name#g" ./PKGBUILD
|
||||||
|
sed -i "s#%exe_link%#$exe_link#g" ./PKGBUILD
|
||||||
|
sed -i "s#%exe_sha256%#$exe_sha256#g" ./PKGBUILD
|
||||||
|
}
|
||||||
|
|
||||||
|
update_flake() {
|
||||||
|
sed -i 's#\(ymExe\.url\s*=\s*\).*;#\1'"$exe_link"';#' ./flake.nix
|
||||||
|
if check_dep nix; then
|
||||||
|
nix flake lock --update-input ymExe
|
||||||
|
else
|
||||||
|
echo "flake.nix was updated, but nix not installed to update flake.lock"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_deps
|
||||||
|
load_current_version
|
||||||
|
update_version
|
||||||
|
update_pkbuild
|
||||||
|
update_flake
|
||||||
|
25
nix/generate_packages.nix
Normal file
25
nix/generate_packages.nix
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{ jq
|
||||||
|
, curl
|
||||||
|
, runCommand
|
||||||
|
, lib
|
||||||
|
, makeWrapper
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
paths = lib.makeBinPath [ jq curl ];
|
||||||
|
in
|
||||||
|
runCommand "generate_config"
|
||||||
|
{
|
||||||
|
src = ../generate_packages.sh;
|
||||||
|
name = "generate_packages";
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
} ''
|
||||||
|
mkdir -p "$out/bin"
|
||||||
|
bin="$out/bin/$name"
|
||||||
|
cp "$src" "$bin"
|
||||||
|
chmod +x "$bin"
|
||||||
|
patchShebangs "$bin"
|
||||||
|
wrapProgram "$bin" \
|
||||||
|
--prefix PATH : ${paths}
|
||||||
|
''
|
Loading…
Reference in New Issue
Block a user