I’m attaching below the final configuration for my Electron-based app. It uses electron-builder and snapcraft to create core20-based snap packages for amd64, arm64 and armhf architectures. The packages are working fine and so far I haven’t recieved any complains from users.
Native node modules and building from GitHub repositories using Snapcraft’s remote build system are also supported with this configuration.
Thanks again @James-Carroll for all the hints, without your help and encouragement I would probably give up and drop the Linux support.
Directory structure
* snap/
* snapcraft.yaml
* gui/
* boxy-svg.desktop
* boxy-svg.svg (the app icon)
* app.zip
* package.json
* src/ (JavaScript code of the Electron app goes here)
* main.js
* package.json
snapcraft.yaml
name: boxy-svg
version: "3.73.1"
summary: Scalable Vector Graphics (SVG) editor.
description: |
Boxy SVG project goal is to create the best tool for editing SVG files.
For beginners as well as for professional web designers and web developers.
On any device and operating system.
license: Proprietary
base: core20
grade: stable
confinement: strict
compression: lzo
architectures:
- build-on: amd64
run-on: amd64
- build-on: arm64
run-on: arm64
- build-on: armhf
run-on: armhf
parts:
electron-app:
plugin: dump
source: app.zip
source-type: zip
override-build: |
# Bugfix: https://forum.snapcraft.io/t/problems-with-remote-build/24373/2
if [ -z ${http_proxy+x} ];
then
echo "Not using proxy"
else
echo "Using proxy"
export ELECTRON_GET_USE_PROXY=1
export GLOBAL_AGENT_HTTP_PROXY="${http_proxy}"
export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy}"
npm config set proxy $http_proxy
npm config set https-proxy $https_proxy
fi
# Bugfix: Need to move the unarchived files manually because `source-subdir: app` does not seem to work
mv ./app/* .
# Install electron-builder and other dependencies from NPM
npm install
npm --prefix ./src install
# Generate linux-unpacked directory containing Electron binaries
if [ ${SNAP_ARCH} = "armhf" ];
then
./node_modules/.bin/electron-builder --armv7l
else
./node_modules/.bin/electron-builder
fi
# Copy over the linux-unpacked directory contents
mkdir -p $SNAPCRAFT_PART_INSTALL/opt/boxy-svg || true
cp -ar ./dist/*-unpacked/* $SNAPCRAFT_PART_INSTALL/opt/boxy-svg/
build-snaps:
- node/14/stable
build-packages:
- build-essential
- git
- libfontconfig-dev
stage-packages:
- libappindicator3-1
- libxss1
- libnspr4
- libnss3
- libglu1-mesa
- libnotify4
- libnotify-bin
- libpulse0
apps:
boxy-svg:
command: opt/boxy-svg/boxy-svg --no-sandbox
plugs:
- desktop
- desktop-legacy
- home
- removable-media
- x11
- unity7
- wayland
- browser-support
- network
- opengl
- audio-playback
extensions: [gnome-3-38]
environment:
DISABLE_WAYLAND: 1
GTK_USE_PORTAL: 1
TMPDIR: ${XDG_RUNTIME_DIR}
PATH: ${SNAP}/usr/sbin:${SNAP}/usr/bin:${SNAP}/sbin:${SNAP}/bin:${PATH}
SNAP_DESKTOP_RUNTIME: ${SNAP}/gnome-platform
gui/boxy-svg.desktop
[Desktop Entry]
Name=Boxy SVG
Comment=Scalable Vector Graphics (SVG) editor
Exec=boxy-svg %u
Icon=${SNAP}/meta/gui/boxy-svg.svg
Type=Application
Terminal=false
Categories=Graphics
StartupWMClass=Boxy SVG
MimeType=image/svg+xml;image/png;image/jpeg;image/gif;image/webp;application/pdf;application/illustrator;
Keywords=SVG;Vector;Graphics;Editor;
app.zip/package.json
{
"name": "boxy-svg",
"version": "3.73.1",
"description": "Scalable Vector Graphics (SVG) editor.",
"license": "Proprietary",
"author": "Jarosław Foksa",
"homepage": "https://boxy-svg.com/",
"build": {
"productName": "Boxy SVG",
"appId": "com.boxy-svg.BoxySVG",
"copyright": "© 2012-2022 Jarosław Foksa",
"compression": "normal",
"asar": true,
"asarUnpack": [
"**/*.node"
],
"directories": {
"app": "src",
"output": "dist"
},
"linux": {
"target": [
"dir"
],
"executableName": "boxy-svg"
}
},
"devDependencies": {
"electron": "16.0.5",
"electron-builder": "22.14.5"
}
}
app.zip/src/package.json
{
"name": "boxy-svg",
"productName": "Boxy SVG",
"version": "3.73.1",
"description": "Scalable Vector Graphics (SVG) editor.",
"license": "Proprietary",
"author": "Jarosław Foksa",
"homepage": "https://boxy-svg.com/",
"main": "main.js",
"dependencies": {
"local-fonts-manager": "git+https://github.com/jarek-foksa/local-fonts-manager.git"
}
}