mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-24 14:34:39 +03:00
Merge pull request #39 from ein-shved/use_patches
Ship from sed and jq to applying patches
This commit is contained in:
commit
13a6e87a40
@ -19,11 +19,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1707451808,
|
"lastModified": 1707347730,
|
||||||
"narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=",
|
"narHash": "sha256-0etC/exQIaqC9vliKhc3eZE2Mm2wgLa0tj93ZF/egvM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "442d407992384ed9c0e6d352de75b69079904e4e",
|
"rev": "6832d0d99649db3d65a0e15fa51471537b2c56a6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -29,6 +29,8 @@ stdenvNoCC.mkDerivation
|
|||||||
];
|
];
|
||||||
|
|
||||||
repack = ./../repack.sh;
|
repack = ./../repack.sh;
|
||||||
|
patches = ./../patches;
|
||||||
|
utility = ./../utility;
|
||||||
desktopItem = ../templates/desktop;
|
desktopItem = ../templates/desktop;
|
||||||
src =
|
src =
|
||||||
if ymExe != null
|
if ymExe != null
|
||||||
@ -40,8 +42,12 @@ stdenvNoCC.mkDerivation
|
|||||||
};
|
};
|
||||||
|
|
||||||
unpackPhase = ''
|
unpackPhase = ''
|
||||||
bash "$repack" ${if !fixQuit then "-q" else ""} -o "./app" "$src"
|
cp -r $repack ./repack.sh
|
||||||
|
cp -r $patches ./patches
|
||||||
|
cp -r $utility ./utility
|
||||||
|
bash "./repack.sh" ${if !fixQuit then "-q" else ""} -o "./app" "$src"
|
||||||
'';
|
'';
|
||||||
|
dontPatch = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p "$out/share/nodejs"
|
mkdir -p "$out/share/nodejs"
|
||||||
|
15
patches/0001-Add-package-licence.patch
Normal file
15
patches/0001-Add-package-licence.patch
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/package.json b/package.json
|
||||||
|
index 5844bdb..c1bab0e 100644
|
||||||
|
--- a/package.json
|
||||||
|
+++ b/package.json
|
||||||
|
@@ -39,5 +39,6 @@
|
||||||
|
"COPYRIGHT": "Яндекс Музыка",
|
||||||
|
"TRADEMARK": "Яндекс Музыка",
|
||||||
|
"DEEPLINK_PROTOCOL": "yandexmusic"
|
||||||
|
- }
|
||||||
|
+ },
|
||||||
|
+ "license": "UNLICENSED"
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.42.0
|
||||||
|
|
18
patches/0002-Add-package-icon.patch
Normal file
18
patches/0002-Add-package-icon.patch
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
diff --git a/package.json b/package.json
|
||||||
|
index c1bab0e..d66268b 100644
|
||||||
|
--- a/package.json
|
||||||
|
+++ b/package.json
|
||||||
|
@@ -40,5 +40,9 @@
|
||||||
|
"TRADEMARK": "Яндекс Музыка",
|
||||||
|
"DEEPLINK_PROTOCOL": "yandexmusic"
|
||||||
|
},
|
||||||
|
- "license": "UNLICENSED"
|
||||||
|
+ "license": "UNLICENSED",
|
||||||
|
+ "icon": {
|
||||||
|
+ "48x48": "build/next-desktop/favicon.png",
|
||||||
|
+ "scalable": "build/next-desktop/favicon.svg"
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.42.0
|
||||||
|
|
15
patches/0003-Optional-fix-quit.patch
Normal file
15
patches/0003-Optional-fix-quit.patch
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/main/lib/handlers/handleWindowLifecycleEvents.js b/main/lib/handlers/handleWindowLifecycleEvents.js
|
||||||
|
index 269d1f6..ff744b4 100644
|
||||||
|
--- a/main/lib/handlers/handleWindowLifecycleEvents.js
|
||||||
|
+++ b/main/lib/handlers/handleWindowLifecycleEvents.js
|
||||||
|
@@ -36,6 +36,7 @@ const handleWindowLifecycleEvents = (window) => {
|
||||||
|
checkAndUpdateApplicationData(window);
|
||||||
|
});
|
||||||
|
window.on('close', (event) => {
|
||||||
|
+ electron_1.app.quit();
|
||||||
|
if (!state_js_1.state.willQuit) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (window.isFullScreen()) {
|
||||||
|
--
|
||||||
|
2.42.0
|
||||||
|
|
13
patches/0004-Fix-window-resize.patch
Normal file
13
patches/0004-Fix-window-resize.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js
|
||||||
|
index 771e24c..e3794a7 100644
|
||||||
|
--- a/main/lib/createWindow.js
|
||||||
|
+++ b/main/lib/createWindow.js
|
||||||
|
@@ -16,8 +16,6 @@ const createWindow = async () => {
|
||||||
|
x: 16,
|
||||||
|
y: 10
|
||||||
|
},
|
||||||
|
- minWidth: 1024,
|
||||||
|
- minHeight: 800,
|
||||||
|
width: 1280,
|
||||||
|
height: 800,
|
||||||
|
webPreferences: {
|
50
repack.sh
50
repack.sh
@ -15,12 +15,12 @@ usage() {
|
|||||||
exe_location=
|
exe_location=
|
||||||
dst="$PWD/app"
|
dst="$PWD/app"
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
fix_quit=1
|
patch_fix_quit=1
|
||||||
while getopts :xo:qh name; do
|
while getopts :xo:qh name; do
|
||||||
case $name in
|
case $name in
|
||||||
x) extract_only=1 ;;
|
x) extract_only=1 ;;
|
||||||
o) dst="$OPTARG" ;;
|
o) dst="$OPTARG" ;;
|
||||||
q) fix_quit=0 ;;
|
q) patch_fix_quit=0 ;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
@ -66,6 +66,7 @@ rm "$TEMPDIR/app.asar"
|
|||||||
curdir="$PWD"
|
curdir="$PWD"
|
||||||
cd "$TEMPDIR/app"
|
cd "$TEMPDIR/app"
|
||||||
|
|
||||||
|
|
||||||
# fixing secretKey issue
|
# fixing secretKey issue
|
||||||
echo "Fixing SecretKey"
|
echo "Fixing SecretKey"
|
||||||
find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= read -r -d $'\0' file; do
|
find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= read -r -d $'\0' file; do
|
||||||
@ -74,40 +75,47 @@ find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= re
|
|||||||
done
|
done
|
||||||
echo "SecretKey replaced"
|
echo "SecretKey replaced"
|
||||||
|
|
||||||
|
# fixing titile
|
||||||
echo "Fixing Title"
|
echo "Fixing Title"
|
||||||
#fixing title
|
|
||||||
find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
||||||
# Use 'sed' to perform the replacement in-place
|
# Use 'sed' to perform the replacement in-place
|
||||||
sed -i "s/Яндекс Музыка — собираем музыку для вас/Яндекс Музыка/g" "$file"
|
sed -i "s/Яндекс Музыка — собираем музыку для вас/Яндекс Музыка/g" "$file"
|
||||||
done
|
done
|
||||||
echo "Title Fixed"
|
echo "Title Fixed"
|
||||||
|
|
||||||
if [ "$fix_quit" == "1" ]; then
|
# applying patches
|
||||||
echo "Fixing App Quiting"
|
apply_patch()
|
||||||
sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" \
|
{
|
||||||
"./main/lib/handlers/handleWindowLifecycleEvents.js"
|
local patchfile patchname
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v jq &>/dev/null; then
|
patchfile="$(realpath "$1")"
|
||||||
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
patchname="$(basename "$patchfile")"
|
||||||
exit 1
|
patchname="${patchname,,}"
|
||||||
fi
|
|
||||||
|
|
||||||
jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json
|
if [[ $patchname =~ [[:digit:]]+\-optional\-(.+).patch ]]; then
|
||||||
mv tmp_package.json package.json
|
patchname="${BASH_REMATCH[1]}"
|
||||||
echo "Updated license field in package.json"
|
patchname="${patchname//[- ]/_}"
|
||||||
|
if eval [ \"\$"patch_$patchname"\" != 1 ]; then
|
||||||
|
echo "Shipping patch '$patchfile'"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Applying patch '$patchfile'"
|
||||||
|
(cd "$TEMPDIR/app" && patch -p1 < "$patchfile")
|
||||||
|
}
|
||||||
|
|
||||||
jq '. + {icon: {"48x48": "build/next-desktop/favicon.png", "scalable": "build/next-desktop/favicon.svg"}}' package.json > tmp_package.json
|
for f in $(eval echo "$SCRIPT_DIR"/patches/*); do
|
||||||
mv tmp_package.json package.json
|
apply_patch "$f"
|
||||||
echo "Updated icon field in package.json"
|
done
|
||||||
|
|
||||||
if [ -n "$extract_only" ]; then
|
if [ -n "$extract_only" ]; then
|
||||||
mkdir -p "$(dirname "$dst")"
|
mkdir -p "$dst"
|
||||||
mv "$TEMPDIR/app" "$dst"
|
eval cp -r "$TEMPDIR/app/*" "$dst"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p "$dst"
|
mkdir -p "$dst"
|
||||||
|
|
||||||
echo "Packing"
|
echo "Packing"
|
||||||
|
Loading…
Reference in New Issue
Block a user