0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2024-12-23 22:22:59 +03:00

Merge pull request #45 from ein-shved/master

Pack of different fixes
This commit is contained in:
Andrey Onishchenko 2024-02-11 18:26:56 +03:00 committed by GitHub
commit 6fea354c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 50 additions and 26 deletions

View File

@ -66,8 +66,6 @@ jobs:
- name: Build yandexmusic
run: nix build --impure .#yandexmusic
- name: Build yandexmusic background
run: nix build --impure .#yandexmusic-background
- name: Build yandexmusic without flakes binaries
run: nix build --impure .#yandexmusic-noflakes

View File

@ -16,8 +16,8 @@ case $OS in
"Arch Linux")
echo "Arch Linux"
pacman -S --noconfirm git sudo base-devel jq nix
sh ./utility/generate_packages.sh
git config --global --add safe.directory "*"
sh ./utility/generate_packages.sh
;;
*)
echo "Operating system is not recognized."

View File

@ -18,9 +18,6 @@
{
packages = rec {
yandexmusic = yandexmusic-with pkgs;
yandexmusic-background = yandexmusic.override {
fixQuit = false;
};
yandexmusic-noflakes = pkgs.callPackage ./nix {};
generate_packages = pkgs.callPackage ./nix/generate_packages.nix {};
default = yandexmusic;

View File

@ -10,7 +10,6 @@
, electron
, ymExe ? null
, fixQuit ? true
}:
let
version_info = with builtins; fromJSON (readFile ../utility/version_info.json);
@ -45,7 +44,7 @@ stdenvNoCC.mkDerivation
cp -r $repack ./repack.sh
cp -r $patches ./patches
cp -r $utility ./utility
bash "./repack.sh" ${if !fixQuit then "-q" else ""} -o "./app" "$src"
bash "./repack.sh" -o "./app" "$src"
'';
dontPatch = true;

View File

@ -12,7 +12,7 @@ diff --git a/main/lib/createTray.js b/main/lib/createTray.js
+ {label: 'Open Window', click: () => window.show()},
+ {label: 'Quit YandexMusic', click: () => app.quit()}
+ ]);
+ tray.setToolTip('This is my application.');
+ tray.setToolTip('Yandex Music');
+ tray.setContextMenu(contextMenu);
+
+ tray.on('click', () => {

View File

@ -8,19 +8,19 @@ usage() {
echo " Options:"
echo " -o DIR Path to destination folder"
echo " -x Extract and fix only to destination folder"
echo " -q Do not apply application quit fix"
echo " -p Do not apply patches"
echo " -h Show this help and exit"
}
exe_location=
dst="$PWD/app"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
patch_fix_quit=1
while getopts :xo:qh name; do
nopatch=0
while getopts :xo:ph name; do
case $name in
x) extract_only=1 ;;
o) dst="$OPTARG" ;;
q) patch_fix_quit=0 ;;
p) nopatch=1 ;;
h)
usage
exit 0
@ -84,19 +84,25 @@ done
echo "Title Fixed"
# applying patches
# This function accepts patch file. If it names starts with `XXXX-optional`,
# then this function check is there the variable with tail name of patch and
# prefix patch_ defined to 1 and apply conditionally the patch. So, if the passed
# file has name `0003-optional-some-magic-feature.patch` the function will apply
# it only when the variable `patch_some_magic_feature` defined to `1`.
apply_patch()
{
local patchfile patchname
local patchfile patchname re
patchfile="$(realpath "$1")"
patchname="$(basename "$patchfile")"
patchname="${patchname,,}"
if [[ $patchname =~ [[:digit:]]+\-optional\-(.+).patch ]]; then
re='[[:digit:]]+\-optional\-(.+).patch ]]'
if [[ $patchname =~ $re ]]; then
patchname="${BASH_REMATCH[1]}"
patchname="${patchname//[- ]/_}"
if eval [ \"\$"patch_$patchname"\" != 1 ]; then
echo "Shipping patch '$patchfile'"
echo "Skipping patch '$patchfile'"
return 0
fi
fi
@ -104,20 +110,19 @@ apply_patch()
(cd "$TEMPDIR/app" && patch -p1 < "$patchfile")
}
for f in $(eval echo "$SCRIPT_DIR"/patches/*); do
apply_patch "$f"
done
if [ "$nopatch" != "1" ]; then
for f in $(eval echo "$SCRIPT_DIR"/patches/*.patch); do
apply_patch "$f"
done
fi
mkdir -p "$dst"
if [ -n "$extract_only" ]; then
mkdir -p "$dst"
eval cp -r "$TEMPDIR/app/*" "$dst"
exit 0
fi
mkdir -p "$dst"
echo "Packing"
cd "$curdir"
asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar"

View File

@ -70,10 +70,35 @@ update_pkbuild() {
sed -i "s#%exe_sha256%#$exe_sha256#g" ./PKGBUILD
}
is_nix_version_2_19() {
local version re major minor
version="$(nix --version | awk '{print $3}')"
re='([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)'
if [[ $version =~ $re ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
if [ "$major" -gt 2 ] || [ "$minor" -ge 19 ]; then
return 0
fi
fi
return 1
}
update_flake() {
local nixcmd="nix --extra-experimental-features nix-command --extra-experimental-features flakes"
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
# Starting from 2.19 the interface of `nix flake` command changed. See
# https://nixos.org/manual/nix/stable/release-notes/rl-2.19
if is_nix_version_2_19; then
$nixcmd flake update ymExe
else
$nixcmd flake lock --update-input ymExe
fi
if [[ $(git status --porcelain -- flake.lock) ]]; then
$nixcmd flake update
fi
else
echo "flake.nix was updated, but nix is not installed to update flake.lock"
fi