mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2025-09-28 01:29:03 +03:00
Add support for NixOS
Additionally - fix some shellcheck warnings in repack.sh Change-Id: I2cbc6516c54a4f4e4ecef817ed9fe90b0a460faa
This commit is contained in:
117
repack.sh
117
repack.sh
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
prompt_yes_no() {
|
||||
local question="$1"
|
||||
local response
|
||||
while true; do
|
||||
read -p "$question (y/n): " response
|
||||
read -rp "$question (y/n): " response
|
||||
case $response in
|
||||
[Yy]*)
|
||||
return 0 # Returning success status code
|
||||
@@ -19,12 +20,47 @@ prompt_yes_no() {
|
||||
done
|
||||
}
|
||||
|
||||
SCRIPTDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [-xh] YANDEX_MUSIC_EXE"
|
||||
echo
|
||||
echo " Options:"
|
||||
echo " -x Extract and fix only to ./app folder"
|
||||
echo " -l Do not update license"
|
||||
echo " -h Show this help and exit"
|
||||
}
|
||||
|
||||
extract_only=
|
||||
exe_location=
|
||||
update_license=1
|
||||
while getopts :xlh name; do
|
||||
case $name in
|
||||
x) extract_only=1 ;;
|
||||
l) update_license= ;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$OPTIND" -le "$#" ]; then
|
||||
shift "$(( OPTIND - 1))"
|
||||
exe_location="$1"
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$exe_location" ]; then
|
||||
echo "No exe file specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# unpacking
|
||||
exe_location=$1
|
||||
|
||||
7z x $exe_location -oExtracted
|
||||
7z x "$exe_location" -oExtracted
|
||||
cp "./Extracted/\$PLUGINSDIR/app-64.7z" "./app-64.7z"
|
||||
rm -rf ./Extracted
|
||||
7z x "./app-64.7z" -oExtracted
|
||||
@@ -34,21 +70,19 @@ rm ./app-64.7z
|
||||
asar extract "./app.asar" "./app"
|
||||
rm "./app.asar"
|
||||
|
||||
# managing npm dependencies
|
||||
cd ./app
|
||||
npm uninstall @yandex-chats/signer
|
||||
npm uninstall electron-notarize
|
||||
npm install @electron/notarize --save-dev
|
||||
npm install --save-dev @electron-forge/cli
|
||||
npx electron-forge import
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
||||
exit 1
|
||||
|
||||
if [ -z "$update_license" ]; then
|
||||
# updating license
|
||||
if ! command -v jq &>/dev/null; then
|
||||
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
||||
exit 1
|
||||
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)
|
||||
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)
|
||||
|
||||
# fixing secretKey issue
|
||||
echo "Fixing SecretKey"
|
||||
@@ -67,6 +101,17 @@ find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
||||
done
|
||||
echo "Title Fixed"
|
||||
|
||||
if [ -n "$extract_only" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# managing npm dependencies
|
||||
npm uninstall @yandex-chats/signer
|
||||
npm uninstall electron-notarize
|
||||
npm install @electron/notarize --save-dev
|
||||
npm install --save-dev @electron-forge/cli
|
||||
npx electron-forge import
|
||||
|
||||
# set some building parameters from config
|
||||
forge_config="module.exports = {
|
||||
packagerConfig: {
|
||||
@@ -105,49 +150,53 @@ forge_config="module.exports = {
|
||||
};
|
||||
"
|
||||
echo Writing Forge Config...
|
||||
echo $forge_config > ./forge.config.js
|
||||
echo "$forge_config" > ./forge.config.js
|
||||
|
||||
build_x64=0
|
||||
build_arm64=0
|
||||
|
||||
prompt_yes_no "Build for x64?"
|
||||
build_x64=$?
|
||||
if prompt_yes_no "Build for x64?"; then
|
||||
build_x64=1
|
||||
fi
|
||||
|
||||
prompt_yes_no "Build for arm64?"
|
||||
build_arm64=$?
|
||||
if prompt_yes_no "Build for arm64?"; then
|
||||
build_arm64=1
|
||||
fi
|
||||
|
||||
# building
|
||||
if [ "$build_x64" -eq 0 ]; then
|
||||
if [ "$build_x64" -eq 1 ]; then
|
||||
npx electron-forge make --arch="x64"
|
||||
fi
|
||||
|
||||
if [ "$build_arm64" -eq 0 ]; then
|
||||
if [ "$build_arm64" -eq 1 ]; then
|
||||
npx electron-forge make --arch="arm64"
|
||||
fi
|
||||
|
||||
# moving packages and rename them
|
||||
cd ../
|
||||
mkdir out
|
||||
if [ "$build_x64" -eq 0 ]; then
|
||||
if [ "$build_x64" -eq 1 ]; then
|
||||
debpath=$(find "./app/out/make/deb/x64/" -type f -print -quit)
|
||||
rpmpath=$(find "./app/out/make/rpm/x64/" -type f -print -quit)
|
||||
zippath=$(find "./app/out/make/zip/linux/x64/" -type f -print -quit)
|
||||
newdeb="./out/yandexmusic.$version.x64.deb"
|
||||
newrpm="./out/yandexmusic.$version.x64.rpm"
|
||||
newzip="./out/yandexmusic.$version.x64.zip"
|
||||
mv $debpath $newdeb
|
||||
mv $rpmpath $newrpm
|
||||
mv $zippath $newzip
|
||||
mv "$debpath" "$newdeb"
|
||||
mv "$rpmpath" "$newrpm"
|
||||
mv "$zippath" "$newzip"
|
||||
fi
|
||||
|
||||
if [ "$build_arm64" -eq 0 ]; then
|
||||
if [ "$build_arm64" -eq 1 ]; then
|
||||
debpath=$(find "./app/out/make/deb/arm64/" -type f -print -quit)
|
||||
rpmpath=$(find "./app/out/make/rpm/arm64/" -type f -print -quit)
|
||||
zippath=$(find "./app/out/make/zip/linux/arm64/" -type f -print -quit)
|
||||
newdeb="./out/yandexmusic.$version.arm64.deb"
|
||||
newrpm="./out/yandexmusic.$version.arm64.rpm"
|
||||
newzip="./out/yandexmusic.$version.arm64.zip"
|
||||
mv $debpath $newdeb
|
||||
mv $rpmpath $newrpm
|
||||
mv $zippath $newzip
|
||||
mv "$debpath" "$newdeb"
|
||||
mv "$rpmpath" "$newrpm"
|
||||
mv "$zippath" "$newzip"
|
||||
fi
|
||||
|
||||
rm -rf ./app
|
||||
rm -rf ./app
|
||||
|
Reference in New Issue
Block a user