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

Swtiched to .asar + PKGBUILD generation

This commit is contained in:
Andrey Onishchenko 2024-01-29 21:41:52 +03:00
parent 9f68480abb
commit 9bf42b7675
5 changed files with 61 additions and 108 deletions

5
LICENSE.md Normal file
View File

@ -0,0 +1,5 @@
## WARRANTIES OR CONDITIONS
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,45 +0,0 @@
const commonOptions = {
icon: {
"48x48": "build/next-desktop/favicon.png",
"scalable": "build/next-desktop/favicon.svg"
},
desktopTemplate: "./desktop.ejs"
}
module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-zip',
platforms: ['linux']
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
...commonOptions,
maintainer: 'Cucumber Space',
homepage: 'https://github.com/cucumber-sp/yandex-music-linux'
}
}
},
{
name: '@electron-forge/maker-rpm',
config: {
options: {
...commonOptions,
homepage: 'https://github.com/cucumber-sp/yandex-music-linux'
}
}
}
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
],
};

View File

@ -89,83 +89,49 @@ echo "Title Fixed"
echo "Fixing App Quiting" 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" sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" "./main/lib/handlers/handleWindowLifecycleEvents.js"
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
echo Copy forge.config.js and desktop.ejs...
cp ../forge.config.js ../desktop.ejs .
update_license=0
if prompt_yes_no "In order to build the app we'll need to update the license field in package.json. Continue?"; then
update_license=1
fi
if [ "$update_license" -eq 0 ]; then
exit 0
fi
if ! command -v jq &>/dev/null; then if ! command -v jq &>/dev/null; then
echo "Error: jq is not installed. Please install jq to proceed." >&2 echo "Error: jq is not installed. Please install jq to proceed." >&2
exit 1 exit 1
fi fi
jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json
mv tmp_package.json package.json mv tmp_package.json package.json
echo "Updated license field in package.json" echo "Updated license field in package.json"
version=$(jq -r .version package.json) version=$(jq -r .version package.json)
build_x64=0 jq '. + icon: {"48x48": "build/next-desktop/favicon.png", "scalable": "build/next-desktop/favicon.svg"}' package.json > tmp_package.json
build_arm64=0 mv tmp_package.json package.json
echo "Updated icon field in package.json"
if prompt_yes_no "Build for x64?"; then if [ -n "$extract_only" ]; then
build_x64=1 exit 0
fi fi
if prompt_yes_no "Build for arm64?"; then
build_arm64=1
fi
# building
if [ "$build_x64" -eq 1 ]; then
npx electron-forge make --arch="x64"
fi
if [ "$build_arm64" -eq 1 ]; then
npx electron-forge make --arch="arm64"
fi
# moving packages and rename them
cd ../ cd ../
mkdir out mkdir out
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"
fi
if [ "$build_arm64" -eq 1 ]; then echo "Packing"
debpath=$(find "./app/out/make/deb/arm64/" -type f -print -quit) asar pack "./app" "./out/yandexmusic.asar"
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"
fi
rm -rf ./app rm -rf ./app
echo "Done"
cp "./LICENSE.md" "./out/LICENSE.md"
cp "./templates/desktop" "./out/yandexmusic.desktop"
#sha256 hash
asar_hash=$(sha256sum "./out/yandexmusic.asar" | cut -d ' ' -f 1)
desktop_hash=$(sha256sum "./out/yandexmusic.desktop" | cut -d ' ' -f 1)
echo "asar hash: $asar_hash"
echo "desktop hash: $desktop_hash"
echo "Building PKGBUILD"
cp "./templates/PKGBUILD" "./out/PKGBUILD"
sed -i "s/%version%/$version/g" "./out/PKGBUILD"
sed -i "s/%asar_hash%/$asar_hash/g" "./out/PKGBUILD"
sed -i "s/%desktop_hash%/$desktop_hash/g" "./out/PKGBUILD"
echo "Done"

27
templates/PKGBUILD Normal file
View File

@ -0,0 +1,27 @@
pkgname=yandexmusic
pkgver=%version%
pkgrel=1
pkgdesc="Yandex Music Client"
arch=('any')
url="https://github.com/cucumber-sp/yandex-music-linux"
license=('custom')
depends=('electron' 'libpulse')
source=('./yandexmusic.asar' './yandexmusic.desktop' './LICENSE.md')
sha256sums=('%asar_hash%' '%desktop_hash%' 'SKIP')
package() {
mkdir -p "$pkgdir/usr/lib/yandexmusic"
mkdir -p "$pkgdir/usr/share/applications"
mkdir -p "$pkgdir/usr/bin"
install -Dm644 "$srcdir/yandexmusic.asar" "$pkgdir/usr/lib/yandexmusic/yandexmusic.asar"
install -Dm644 "$srcdir/yandexmusic.desktop" "$pkgdir/usr/share/applications/yandexmusic.desktop"
install -Dm644 "$srcdir/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# 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"
chmod 755 "$pkgdir/usr/bin/yandexmusic"
}