mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2025-03-13 22:03:43 +03:00
Merge pull request #11 from ein-shved/main
Some fixes after shipping to asar package
This commit is contained in:
commit
39358d959a
@ -56,13 +56,13 @@
|
||||
"ymExe": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-JEtqtRkBhbUN7+rcVzTrf2DjaIgr4MwSpunQPDV9/O0=",
|
||||
"narHash": "sha256-HeqFJ+hY/8TjViz6SjfklMoVpX6+54pL0Vl1cI1Qlkw=",
|
||||
"type": "file",
|
||||
"url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.7.exe"
|
||||
"url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.8.exe"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.7.exe"
|
||||
"url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.8.exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2,7 +2,7 @@
|
||||
description = "Native Yandex Music desktop client";
|
||||
inputs = {
|
||||
ymExe = {
|
||||
url = https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.7.exe;
|
||||
url = https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.0.8.exe;
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
@ -20,6 +20,9 @@
|
||||
{
|
||||
packages = rec {
|
||||
yandex-music = yandex-music-with pkgs;
|
||||
yandex-music-backgroud = yandex-music.override {
|
||||
fixQuit = false;
|
||||
};
|
||||
default = yandex-music;
|
||||
};
|
||||
}
|
||||
|
@ -1,21 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p ./tmp
|
||||
set -e
|
||||
|
||||
clear() {
|
||||
rm -rf "$TEMPDIR"
|
||||
}
|
||||
TEMPDIR="$(mktemp -d)"
|
||||
trap clear EXIT
|
||||
|
||||
# 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 > ./tmp/download.json
|
||||
curl -s https://music-desktop-application.s3.yandex.net/stable/download.json > "$TEMPDIR"/download.json
|
||||
|
||||
exe_link=$(jq -r '.windows' ./tmp/download.json)
|
||||
version=$(echo $exe_link | grep -oP '(?<=x64_).*(?=.exe)')
|
||||
exe_name=$(basename $exe_link)
|
||||
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 > ./tmp/$exe_name
|
||||
curl "$exe_link" > "$TEMPDIR/$exe_name"
|
||||
|
||||
exe_sha256=$(sha256sum ./tmp/$exe_name | awk '{print $1}')
|
||||
exe_sha256="$(sha256sum "$TEMPDIR/$exe_name" | awk '{print $1}')"
|
||||
|
||||
echo "Exe sha256: $exe_sha256"
|
||||
|
||||
@ -36,5 +42,3 @@ 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
|
||||
|
||||
rm -rf ./tmp
|
@ -10,6 +10,7 @@
|
||||
, jq
|
||||
|
||||
, ymExe
|
||||
, fixQuit ? true
|
||||
}:
|
||||
let
|
||||
app = runCommand "yandex-music-app"
|
||||
@ -18,14 +19,13 @@ let
|
||||
repack = ./../repack.sh;
|
||||
src = ymExe;
|
||||
} ''
|
||||
bash "$repack" -x "$src"
|
||||
mv ./app "$out"
|
||||
bash "$repack" ${if !fixQuit then "-q" else ""} -o "$out" "$src"
|
||||
'';
|
||||
launcher = writeShellApplication {
|
||||
name = "yandex-music";
|
||||
runtimeInputs = [ electron ];
|
||||
text = ''
|
||||
electron ${app} "$@"
|
||||
electron ${app}/yandexmusic.asar "$@"
|
||||
'';
|
||||
};
|
||||
desktopItem = makeDesktopItem {
|
||||
@ -34,7 +34,7 @@ let
|
||||
comment = "Yandex Music - we collect music for you";
|
||||
exec = "${launcher}/bin/yandex-music";
|
||||
terminal = false;
|
||||
icon = "${app}/build/next-desktop/favicon.svg";
|
||||
icon = "${app}/favicon.svg";
|
||||
categories = [ "Audio" "Music" "Player" "AudioVideo" ];
|
||||
extraConfig = {
|
||||
"Name[ru]" = "Яндекс Музыка";
|
||||
|
83
repack.sh
83
repack.sh
@ -1,38 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
prompt_yes_no() {
|
||||
local question="$1"
|
||||
local response
|
||||
while true; do
|
||||
read -rp "$question (y/n): " response
|
||||
case $response in
|
||||
[Yy]*)
|
||||
return 0 # Returning success status code
|
||||
;;
|
||||
[Nn]*)
|
||||
return 1 # Returning failure status code
|
||||
;;
|
||||
*)
|
||||
echo "Please enter 'y' (yes) or 'n' (no)."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [-xh] YANDEX_MUSIC_EXE"
|
||||
echo "Usage: $(basename "$0") [-xqh] [ -o DIR] YANDEX_MUSIC_EXE"
|
||||
echo
|
||||
echo " Options:"
|
||||
echo " -x Extract and fix only to ./app folder"
|
||||
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 " -h Show this help and exit"
|
||||
}
|
||||
|
||||
extract_only=
|
||||
exe_location=
|
||||
while getopts :xh name; do
|
||||
dst="$PWD/app"
|
||||
fix_quit=1
|
||||
while getopts :xo:qh name; do
|
||||
case $name in
|
||||
x) extract_only=1 ;;
|
||||
o) dst="$OPTARG" ;;
|
||||
q) fix_quit=0 ;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
@ -56,18 +43,27 @@ if [ -z "$exe_location" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# unpacking
|
||||
7z x "$exe_location" -oExtracted
|
||||
cp "./Extracted/\$PLUGINSDIR/app-64.7z" "./app-64.7z"
|
||||
rm -rf ./Extracted
|
||||
7z x "./app-64.7z" -oExtracted
|
||||
cp "./Extracted/resources/app.asar" "./app.asar"
|
||||
rm -rf ./Extracted
|
||||
rm ./app-64.7z
|
||||
asar extract "./app.asar" "./app"
|
||||
rm "./app.asar"
|
||||
clear() {
|
||||
rm -rf "$TEMPDIR"
|
||||
}
|
||||
TEMPDIR="$(mktemp -d)"
|
||||
trap clear EXIT
|
||||
|
||||
cd ./app
|
||||
|
||||
EXTRACTED="$TEMPDIR/Extracted"
|
||||
# unpacking
|
||||
7z x "$exe_location" -o"$EXTRACTED"
|
||||
mv "$EXTRACTED/\$PLUGINSDIR/app-64.7z" "$TEMPDIR/app-64.7z"
|
||||
rm -rf "$EXTRACTED"
|
||||
7z x "$TEMPDIR/app-64.7z" -o"$EXTRACTED"
|
||||
mv "$EXTRACTED/resources/app.asar" "$TEMPDIR/app.asar"
|
||||
rm -rf "$EXTRACTED"
|
||||
rm "$TEMPDIR/app-64.7z"
|
||||
asar extract "$TEMPDIR/app.asar" "$TEMPDIR/app"
|
||||
rm "$TEMPDIR/app.asar"
|
||||
|
||||
curdir="$PWD"
|
||||
cd "$TEMPDIR/app"
|
||||
|
||||
# fixing secretKey issue
|
||||
echo "Fixing SecretKey"
|
||||
@ -86,8 +82,11 @@ find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
||||
done
|
||||
echo "Title Fixed"
|
||||
|
||||
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"
|
||||
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
|
||||
|
||||
if ! command -v jq &>/dev/null; then
|
||||
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
||||
@ -97,22 +96,24 @@ fi
|
||||
jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json
|
||||
mv tmp_package.json package.json
|
||||
echo "Updated license field in package.json"
|
||||
version=$(jq -r .version package.json)
|
||||
|
||||
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"
|
||||
|
||||
if [ -n "$extract_only" ]; then
|
||||
mkdir -p "$(dirname "$dst")"
|
||||
mv "$TEMPDIR/app" "$dst"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd ../
|
||||
mkdir -p out
|
||||
mkdir -p "$dst"
|
||||
|
||||
echo "Packing"
|
||||
asar pack "./app" "./out/yandexmusic.asar"
|
||||
|
||||
rm -rf ./app
|
||||
cd "$curdir"
|
||||
asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar"
|
||||
for ext in png svg; do
|
||||
mv "$TEMPDIR/app/build/next-desktop/favicon.$ext" "$dst"
|
||||
done
|
||||
|
||||
echo "Done"
|
@ -27,12 +27,12 @@ package() {
|
||||
mkdir -p "$pkgdir/usr/bin"
|
||||
|
||||
install -Dm644 "$srcdir/out/yandexmusic.asar" "$pkgdir/usr/lib/yandexmusic/yandexmusic.asar"
|
||||
install -Dm644 "$srcdir/out/favicon.png" "$pkgdir/usr/share/pixmaps/yandexmusic.png"
|
||||
install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/yandexmusic.desktop"
|
||||
install -Dm644 "$srcdir/yandex-music-linux/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
install -Dm644 "$srcdir/yandex-music-linux/templates/icon.png" "$pkgdir/usr/share/pixmaps/yandexmusic.png"
|
||||
|
||||
# Create a script to launch the app with Electron
|
||||
echo "#!/bin/sh" > "$pkgdir/usr/bin/yandexmusic"
|
||||
echo "electron /usr/lib/yandexmusic/yandexmusic.asar" >> "$pkgdir/usr/bin/yandexmusic"
|
||||
echo 'exec electron /usr/lib/yandexmusic/yandexmusic.asar "$@"' >> "$pkgdir/usr/bin/yandexmusic"
|
||||
chmod 755 "$pkgdir/usr/bin/yandexmusic"
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 544 B |
Loading…
Reference in New Issue
Block a user