0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2025-09-28 01:29:03 +03:00

Utility folder

This commit is contained in:
Andrey Onishchenko
2024-02-09 15:07:50 +03:00
parent 18145ed163
commit a28db76a6b
8 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,86 @@
#!/bin/bash
set -e
TEMPDIR=
exe_link=
version=
exe_name=
exe_sha256=
clear() {
rm -rf "$TEMPDIR"
}
TEMPDIR="$(mktemp -d)"
trap clear EXIT
check_dep() {
if ! command -v "$@" &>/dev/null; then
echo "$@" not installed. >&2
return 1
fi
}
check_deps() {
check_dep sed
check_dep curl
check_dep jq
}
load_current_version() {
# loading json from file https://music-desktop-application.s3.yandex.net/stable/download.json
curl -s https://music-desktop-application.s3.yandex.net/stable/download.json > "$TEMPDIR"/download.json
exe_link=$(jq -r '.windows' "$TEMPDIR"/download.json)
version="$(echo "$exe_link" | grep -oP '(?<=x64_).*(?=.exe)')"
exe_name="$(basename "$exe_link")"
echo "Windows url: $exe_link"
echo "Version: $version"
echo "Exe name: $exe_name"
curl "$exe_link" > "$TEMPDIR/$exe_name"
exe_sha256="$(sha256sum "$TEMPDIR/$exe_name" | awk '{print $1}')"
echo "Exe sha256: $exe_sha256"
}
update_version() {
rm -rf ./utility/version_info.json
cat > ./utility/version_info.json <<EOF
{
"version": "$version",
"exe_name": "$exe_name",
"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 --extra-experimental-features 'nix-command flakes' flake update
else
echo "flake.nix was updated, but nix is not installed to update flake.lock"
fi
}
check_deps
load_current_version
update_version
update_pkbuild
update_flake

View File

@@ -0,0 +1,6 @@
{
"version": "5.0.10",
"exe_name": "Yandex_Music_x64_5.0.10.exe",
"exe_link": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.10.exe",
"exe_sha256": "cd8d86ab8cc27c215726599e40482b2aab90a33fb0a98d883e4f7e985d7cb725"
}