From 9bf42b7675b081ade9805ca687af0b84bea4df66 Mon Sep 17 00:00:00 2001 From: Andrey Onishchenko Date: Mon, 29 Jan 2024 21:41:52 +0300 Subject: [PATCH] Swtiched to .asar + PKGBUILD generation --- LICENSE.md | 5 ++ forge.config.js | 45 ---------------- repack.sh | 92 ++++++++++---------------------- templates/PKGBUILD | 27 ++++++++++ desktop.ejs => templates/desktop | 0 5 files changed, 61 insertions(+), 108 deletions(-) create mode 100644 LICENSE.md delete mode 100644 forge.config.js create mode 100644 templates/PKGBUILD rename desktop.ejs => templates/desktop (100%) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..0f7143e --- /dev/null +++ b/LICENSE.md @@ -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. \ No newline at end of file diff --git a/forge.config.js b/forge.config.js deleted file mode 100644 index 847540a..0000000 --- a/forge.config.js +++ /dev/null @@ -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: {}, - }, - ], -}; \ No newline at end of file diff --git a/repack.sh b/repack.sh index e391713..b62820e 100755 --- a/repack.sh +++ b/repack.sh @@ -89,83 +89,49 @@ 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 [ -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 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) -build_x64=0 -build_arm64=0 +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 prompt_yes_no "Build for x64?"; then - build_x64=1 +if [ -n "$extract_only" ]; then + exit 0 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 ../ 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 - 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" -fi +echo "Packing" +asar pack "./app" "./out/yandexmusic.asar" 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" \ No newline at end of file diff --git a/templates/PKGBUILD b/templates/PKGBUILD new file mode 100644 index 0000000..4d6ef00 --- /dev/null +++ b/templates/PKGBUILD @@ -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" +} diff --git a/desktop.ejs b/templates/desktop similarity index 100% rename from desktop.ejs rename to templates/desktop