ipfs / ipfs-desktop

An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.
https://docs.ipfs.tech/install/ipfs-desktop/
MIT License
6.01k stars 865 forks source link

Packaging question: Is a locally installed electron helpful? #1974

Closed RubenKelevra closed 2 years ago

RubenKelevra commented 2 years ago

I'm maintaining the AUR package for Arch Linux.

Going through the dependencies I notice that the previous maintainer added a lot of dependencies of Electron instead of specifying Electron itself.

I was wondering if the current build script would notice a locally installed Electron and not download it again in the prepare() step.

And I was wondering how the electron version is properly chosen/specified.

The Electron package (currently version 16) on Arch does provide the following:

``` electron /usr/ electron /usr/bin/ electron /usr/bin/electron electron /usr/bin/electron16 electron /usr/lib/ electron /usr/lib/electron/ electron /usr/lib/electron/LICENSE electron /usr/lib/electron/LICENSES.chromium.html electron /usr/lib/electron/chrome-sandbox electron /usr/lib/electron/chrome_100_percent.pak electron /usr/lib/electron/chrome_200_percent.pak electron /usr/lib/electron/chrome_crashpad_handler electron /usr/lib/electron/electron electron /usr/lib/electron/libEGL.so electron /usr/lib/electron/libGLESv2.so electron /usr/lib/electron/libvk_swiftshader.so electron /usr/lib/electron/libvulkan.so.1 electron /usr/lib/electron/locales/ electron /usr/lib/electron/locales/am.pak electron /usr/lib/electron/locales/ar.pak electron /usr/lib/electron/locales/bg.pak electron /usr/lib/electron/locales/bn.pak electron /usr/lib/electron/locales/ca.pak electron /usr/lib/electron/locales/cs.pak electron /usr/lib/electron/locales/da.pak electron /usr/lib/electron/locales/de.pak electron /usr/lib/electron/locales/el.pak electron /usr/lib/electron/locales/en-GB.pak electron /usr/lib/electron/locales/en-US.pak electron /usr/lib/electron/locales/es-419.pak electron /usr/lib/electron/locales/es.pak electron /usr/lib/electron/locales/et.pak electron /usr/lib/electron/locales/fa.pak electron /usr/lib/electron/locales/fi.pak electron /usr/lib/electron/locales/fil.pak electron /usr/lib/electron/locales/fr.pak electron /usr/lib/electron/locales/gu.pak electron /usr/lib/electron/locales/he.pak electron /usr/lib/electron/locales/hi.pak electron /usr/lib/electron/locales/hr.pak electron /usr/lib/electron/locales/hu.pak electron /usr/lib/electron/locales/id.pak electron /usr/lib/electron/locales/it.pak electron /usr/lib/electron/locales/ja.pak electron /usr/lib/electron/locales/kn.pak electron /usr/lib/electron/locales/ko.pak electron /usr/lib/electron/locales/lt.pak electron /usr/lib/electron/locales/lv.pak electron /usr/lib/electron/locales/ml.pak electron /usr/lib/electron/locales/mr.pak electron /usr/lib/electron/locales/ms.pak electron /usr/lib/electron/locales/nb.pak electron /usr/lib/electron/locales/nl.pak electron /usr/lib/electron/locales/pl.pak electron /usr/lib/electron/locales/pt-BR.pak electron /usr/lib/electron/locales/pt-PT.pak electron /usr/lib/electron/locales/ro.pak electron /usr/lib/electron/locales/ru.pak electron /usr/lib/electron/locales/sk.pak electron /usr/lib/electron/locales/sl.pak electron /usr/lib/electron/locales/sr.pak electron /usr/lib/electron/locales/sv.pak electron /usr/lib/electron/locales/sw.pak electron /usr/lib/electron/locales/ta.pak electron /usr/lib/electron/locales/te.pak electron /usr/lib/electron/locales/th.pak electron /usr/lib/electron/locales/tr.pak electron /usr/lib/electron/locales/uk.pak electron /usr/lib/electron/locales/vi.pak electron /usr/lib/electron/locales/zh-CN.pak electron /usr/lib/electron/locales/zh-TW.pak electron /usr/lib/electron/resources.pak electron /usr/lib/electron/resources/ electron /usr/lib/electron/resources/default_app.asar electron /usr/lib/electron/snapshot_blob.bin electron /usr/lib/electron/swiftshader/ electron /usr/lib/electron/swiftshader/libEGL.so electron /usr/lib/electron/swiftshader/libGLESv2.so electron /usr/lib/electron/v8_context_snapshot.bin electron /usr/lib/electron/version electron /usr/lib/electron/vk_swiftshader_icd.json electron /usr/share/ electron /usr/share/applications/ electron /usr/share/applications/electron.desktop electron /usr/share/licenses/ electron /usr/share/licenses/electron/ electron /usr/share/licenses/electron/LICENSE electron /usr/share/licenses/electron/LICENSES.chromium.html electron /usr/share/pixmaps/ electron /usr/share/pixmaps/electron.png ```

While for example, electron15 does provide the following:

``` electron15 /usr/ electron15 /usr/bin/ electron15 /usr/bin/electron15 electron15 /usr/lib/ electron15 /usr/lib/electron15/ electron15 /usr/lib/electron15/LICENSE electron15 /usr/lib/electron15/LICENSES.chromium.html electron15 /usr/lib/electron15/chrome-sandbox electron15 /usr/lib/electron15/chrome_100_percent.pak electron15 /usr/lib/electron15/chrome_200_percent.pak electron15 /usr/lib/electron15/chrome_crashpad_handler electron15 /usr/lib/electron15/electron electron15 /usr/lib/electron15/libEGL.so electron15 /usr/lib/electron15/libGLESv2.so electron15 /usr/lib/electron15/libvk_swiftshader.so electron15 /usr/lib/electron15/libvulkan.so.1 electron15 /usr/lib/electron15/locales/ electron15 /usr/lib/electron15/locales/am.pak electron15 /usr/lib/electron15/locales/ar.pak electron15 /usr/lib/electron15/locales/bg.pak electron15 /usr/lib/electron15/locales/bn.pak electron15 /usr/lib/electron15/locales/ca.pak electron15 /usr/lib/electron15/locales/cs.pak electron15 /usr/lib/electron15/locales/da.pak electron15 /usr/lib/electron15/locales/de.pak electron15 /usr/lib/electron15/locales/el.pak electron15 /usr/lib/electron15/locales/en-GB.pak electron15 /usr/lib/electron15/locales/en-US.pak electron15 /usr/lib/electron15/locales/es-419.pak electron15 /usr/lib/electron15/locales/es.pak electron15 /usr/lib/electron15/locales/et.pak electron15 /usr/lib/electron15/locales/fa.pak electron15 /usr/lib/electron15/locales/fi.pak electron15 /usr/lib/electron15/locales/fil.pak electron15 /usr/lib/electron15/locales/fr.pak electron15 /usr/lib/electron15/locales/gu.pak electron15 /usr/lib/electron15/locales/he.pak electron15 /usr/lib/electron15/locales/hi.pak electron15 /usr/lib/electron15/locales/hr.pak electron15 /usr/lib/electron15/locales/hu.pak electron15 /usr/lib/electron15/locales/id.pak electron15 /usr/lib/electron15/locales/it.pak electron15 /usr/lib/electron15/locales/ja.pak electron15 /usr/lib/electron15/locales/kn.pak electron15 /usr/lib/electron15/locales/ko.pak electron15 /usr/lib/electron15/locales/lt.pak electron15 /usr/lib/electron15/locales/lv.pak electron15 /usr/lib/electron15/locales/ml.pak electron15 /usr/lib/electron15/locales/mr.pak electron15 /usr/lib/electron15/locales/ms.pak electron15 /usr/lib/electron15/locales/nb.pak electron15 /usr/lib/electron15/locales/nl.pak electron15 /usr/lib/electron15/locales/pl.pak electron15 /usr/lib/electron15/locales/pt-BR.pak electron15 /usr/lib/electron15/locales/pt-PT.pak electron15 /usr/lib/electron15/locales/ro.pak electron15 /usr/lib/electron15/locales/ru.pak electron15 /usr/lib/electron15/locales/sk.pak electron15 /usr/lib/electron15/locales/sl.pak electron15 /usr/lib/electron15/locales/sr.pak electron15 /usr/lib/electron15/locales/sv.pak electron15 /usr/lib/electron15/locales/sw.pak electron15 /usr/lib/electron15/locales/ta.pak electron15 /usr/lib/electron15/locales/te.pak electron15 /usr/lib/electron15/locales/th.pak electron15 /usr/lib/electron15/locales/tr.pak electron15 /usr/lib/electron15/locales/uk.pak electron15 /usr/lib/electron15/locales/vi.pak electron15 /usr/lib/electron15/locales/zh-CN.pak electron15 /usr/lib/electron15/locales/zh-TW.pak electron15 /usr/lib/electron15/resources.pak electron15 /usr/lib/electron15/resources/ electron15 /usr/lib/electron15/resources/default_app.asar electron15 /usr/lib/electron15/snapshot_blob.bin electron15 /usr/lib/electron15/swiftshader/ electron15 /usr/lib/electron15/swiftshader/libEGL.so electron15 /usr/lib/electron15/swiftshader/libGLESv2.so electron15 /usr/lib/electron15/v8_context_snapshot.bin electron15 /usr/lib/electron15/version electron15 /usr/lib/electron15/vk_swiftshader_icd.json electron15 /usr/share/ electron15 /usr/share/applications/ electron15 /usr/share/applications/electron15.desktop electron15 /usr/share/licenses/ electron15 /usr/share/licenses/electron15/ electron15 /usr/share/licenses/electron15/LICENSE electron15 /usr/share/licenses/electron15/LICENSES.chromium.html electron15 /usr/share/pixmaps/ electron15 /usr/share/pixmaps/electron15.png ```

So as soon as electron 17 comes out, I need a way to specify that version 16 should be used, by specifying a path for that.

Build script for reference

# Maintainer: @RubenKelevra
# Contributor: Alex Henrie <alexhenrie24@gmail.com>
pkgname=ipfs-desktop
pkgver=0.18.1
pkgrel=2
pkgdesc="Desktop client for the InterPlanetary File System"
arch=(x86_64)
url="https://github.com/ipfs/$pkgname"
license=(MIT)
depends=(c-ares ffmpeg gtk3 http-parser libevent libvpx libxslt libxss minizip nss re2 snappy libnotify libappindicator-gtk3)
makedepends=("nodejs>=16" npm node-gyp)
install=$pkgname.install
source=("https://github.com/ipfs/ipfs-desktop/archive/refs/tags/v$pkgver.tar.gz")
b2sums=('d23f2c574d7d3fbe9ff4fda1836efc2b2023721cf9e2182cce9b7ce99da14a43abf1fab26b5b1e70e4377daba5e7bfaf1012c08ca6af81d2f5ff126081a47f4d')

prepare() {
    cd "$pkgname-$pkgver"
    npm ci --no-audit --progress=false --cache "$srcdir/npm-cache"
}

build() {
    cd "$pkgname-$pkgver"
    npm run-script build
    npx electron-builder build --linux pacman
}

package() {
    cd "$pkgname-$pkgver"
    tar -xf dist/$pkgname-$pkgver-linux-x64.pacman -C "$pkgdir"
    mv "$pkgdir/.INSTALL" "../$pkgname.install"
    rm "$pkgdir/.MTREE" "$pkgdir/.PKGINFO"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    mv "$pkgdir/opt/IPFS Desktop/LICENSE.electron.txt" "$pkgdir/usr/share/licenses/$pkgname"
    mv "$pkgdir/opt/IPFS Desktop/LICENSES.chromium.html" "$pkgdir/usr/share/licenses/$pkgname"
    mkdir -p "$pkgdir/usr/bin"
    ln -s '/opt/IPFS Desktop/ipfs-desktop' "$pkgdir/usr/bin/ipfs-desktop"
}
lidel commented 2 years ago

Electron version is specified in package.json: https://github.com/ipfs/ipfs-desktop/blob/3bc3a8a29e16473a11786fa0b9f1d42365f436af/package.json#L56 npm ci will download it into node_modules/electron.

My (biased) opinion is that investing time in anything non-standard around Electron is not worth your time, disk space is less valuable than the time wasted on chasing bugs introduced by custom build.

RubenKelevra commented 2 years ago

@lidel so electron itself will be fetched into the built environment. But it won't fetch the dependencies.

If I install electron as a system package it will fetch a lot of dependencies. Are they necessary for the built environment's electron as well?

Name            : electron
Version         : 16.0.8-1
Description     : Build cross platform desktop apps with web technologies
Architecture    : x86_64
URL             : https://electronjs.org/
Licenses        : MIT  custom
Groups          : None
Provides        : electron16
Depends On      : c-ares  ffmpeg  gtk3  libevent  libxslt  minizip  nss  re2  snappy
Optional Deps   : kde-cli-tools: file deletion support (kioclient5)
                  libappindicator-gtk3: StatusNotifierItem support
                  pipewire: WebRTC desktop sharing under Wayland
                  trash-cli: file deletion support (trash-put)
                  xdg-utils: open URLs with desktop's default (xdg-email, xdg-open)