mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-23 22:22:59 +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": {
|
||||
"locked": {
|
||||
"lastModified": 1707451808,
|
||||
"narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=",
|
||||
"lastModified": 1707347730,
|
||||
"narHash": "sha256-0etC/exQIaqC9vliKhc3eZE2Mm2wgLa0tj93ZF/egvM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "442d407992384ed9c0e6d352de75b69079904e4e",
|
||||
"rev": "6832d0d99649db3d65a0e15fa51471537b2c56a6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -29,6 +29,8 @@ stdenvNoCC.mkDerivation
|
||||
];
|
||||
|
||||
repack = ./../repack.sh;
|
||||
patches = ./../patches;
|
||||
utility = ./../utility;
|
||||
desktopItem = ../templates/desktop;
|
||||
src =
|
||||
if ymExe != null
|
||||
@ -40,8 +42,12 @@ stdenvNoCC.mkDerivation
|
||||
};
|
||||
|
||||
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 = ''
|
||||
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=
|
||||
dst="$PWD/app"
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
fix_quit=1
|
||||
patch_fix_quit=1
|
||||
while getopts :xo:qh name; do
|
||||
case $name in
|
||||
x) extract_only=1 ;;
|
||||
o) dst="$OPTARG" ;;
|
||||
q) fix_quit=0 ;;
|
||||
q) patch_fix_quit=0 ;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
@ -66,6 +66,7 @@ rm "$TEMPDIR/app.asar"
|
||||
curdir="$PWD"
|
||||
cd "$TEMPDIR/app"
|
||||
|
||||
|
||||
# fixing secretKey issue
|
||||
echo "Fixing SecretKey"
|
||||
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
|
||||
echo "SecretKey replaced"
|
||||
|
||||
|
||||
# fixing titile
|
||||
echo "Fixing Title"
|
||||
#fixing title
|
||||
find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
||||
# Use 'sed' to perform the replacement in-place
|
||||
sed -i "s/Яндекс Музыка — собираем музыку для вас/Яндекс Музыка/g" "$file"
|
||||
done
|
||||
echo "Title Fixed"
|
||||
|
||||
if [ "$fix_quit" == "1" ]; then
|
||||
echo "Fixing App Quiting"
|
||||
sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" \
|
||||
"./main/lib/handlers/handleWindowLifecycleEvents.js"
|
||||
fi
|
||||
# applying patches
|
||||
apply_patch()
|
||||
{
|
||||
local patchfile patchname
|
||||
|
||||
if ! command -v jq &>/dev/null; then
|
||||
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
||||
exit 1
|
||||
fi
|
||||
patchfile="$(realpath "$1")"
|
||||
patchname="$(basename "$patchfile")"
|
||||
patchname="${patchname,,}"
|
||||
|
||||
jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json
|
||||
mv tmp_package.json package.json
|
||||
echo "Updated license field in package.json"
|
||||
if [[ $patchname =~ [[:digit:]]+\-optional\-(.+).patch ]]; then
|
||||
patchname="${BASH_REMATCH[1]}"
|
||||
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
|
||||
mv tmp_package.json package.json
|
||||
echo "Updated icon field in package.json"
|
||||
for f in $(eval echo "$SCRIPT_DIR"/patches/*); do
|
||||
apply_patch "$f"
|
||||
done
|
||||
|
||||
if [ -n "$extract_only" ]; then
|
||||
mkdir -p "$(dirname "$dst")"
|
||||
mv "$TEMPDIR/app" "$dst"
|
||||
mkdir -p "$dst"
|
||||
eval cp -r "$TEMPDIR/app/*" "$dst"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
mkdir -p "$dst"
|
||||
|
||||
echo "Packing"
|
||||
|
Loading…
Reference in New Issue
Block a user