Hai,
I have an electron app which i am trying to package it as a kiosk following this documentation i am able to snap the app it launches fine,
i am using node-wifi which internally uses nmcli looks like i am unable to access/call nmcli i have seen a bunch of issues mentioning to use network-manager i tried adding it to build-packages
and creating a new part like this:
nmcli:
plugin: nil
stage-packages:
- network-manager
organize:
usr/bin/nmcli: bin/nmcli
but nothing seems to be working from me, from node-wifi i get {"killed":false,"code":1,"signal":null,"cmd":"nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags,device device wifi"}
Thanks in advance.
What plugs do you have defined, and are they connected? use snap connections
to see if they’re connected.
ogra
January 21, 2021, 1:07am
3
nmcli should work fine if you define the network-manager plug for your app so the snap is able to connect to a running network manager via dbus …
note that this indeed means you need to have an network-manager instance running on the host already …
so in case you are using a classic server install to run your kiosk, you want to install the network-manager deb on the host, if you use UbuntuCore you want to install the network-manager snap and connect your app to it.
Thank you for super fast response,
I am new to building snaps so clearly not sure about what you are asking
here is the sample snapcraft.yaml i have.
name: nd
version: '0.1'
summary: nd Staging
description: |
nd
base: core18
confinement: strict
grade: devel
apps:
nd:
command: desktop-launch "$SNAP/nd/nd" "--no-sandbox"
plugs:
- browser-support
- network
- network-bind
- opengl
- pulseaudio
- x11
- network-manager
parts:
nmcli:
plugin: nil
stage-packages:
- network-manager
organize:
usr/bin/nmcli: bin/nmcli
py:
plugin: python
python-version: python2
python-packages: [numpy]
nd:
plugin: nodejs
nodejs-version: 13.5.0
source-type: local
nodejs-package-manager: npm
source: .
after: [desktop-gtk3]
override-build: |
PATH=$PATH:$SNAPCRAFT_PART_SRC/../npm/bin
which node
echo "helllo"
npm config set user 0
npm config set unsafe-perm true
node --version
npm --version
case $SNAPCRAFT_ARCH_TRIPLET in
"i386-linux-gnu") ARCH="ia32";;
"x86_64-linux-gnu") ARCH="x64";;
"arm-linux-gnueabihf") ARCH="armv7l";;
"aarch64-linux-gnu") ARCH="arm64";;
*) echo "ERROR: electron does not support the '$SNAPCRAFT_ARCH_TRIPLET' architecture" && exit 1;;
esac
npm install
npm run clean &&
npm run build-staging &&
./node_modules/.bin/electron-packager . --overwrite --platform=linux --arch=$ARCH --output=release-build --prune=true
cp -v -R ./ND-linux-$ARCH $SNAPCRAFT_PART_INSTALL/nd
stage-packages:
- libasound2
- libgconf-2-4
- libnss3
- libx11-xcb1
- libxss1
- libxtst6
build-packages:
- unzip
- python2.7
- network-manager
# Adapted from snapcraft-desktop-helpers https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml#L183
desktop-gtk3:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: gtk
plugin: make
make-parameters: ["FLAVOR=gtk3"]
build-packages:
- build-essential
- libgtk-3-dev
stage-packages:
- libxkbcommon0 # XKB_CONFIG_ROOT
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libgtk-3-0
- libgdk-pixbuf2.0-0
- libglib2.0-bin
- libgtk-3-bin
- unity-gtk3-module
- libappindicator3-1
- locales-all
- xdg-user-dirs
- ibus-gtk3
- libibus-1.0-5
and i already have network-manager on my ubuntu nmcli
commands works fine here .
Thanks in advance .
ogra
January 21, 2021, 12:30pm
5
and is your network-manager interface connected (you need to do this manually, it does not auto-connect) ?
to check connections of your app, run the command that @lucyllewy suggested above:
snap connections nd
if it is not connected, use:
snap connect nd:network-manager
(btw, i’m not sure if the store actually allows two letter package names)
1 Like
@ogra thanks, it worked,
the app name isn’t nd i just put it there as it is small .
I have one more doubt i came from electron-builder where i had option to copy some static files to location using extraResources
is there a way to specify that on snapcraft.yaml file as well ?
And also is there a way i can specify some place to create my db? when installed using deb the user path is ~/.config/nd/sqlite.db
here it is /snap/nd/x1/.....
but everytime i snap remove
this location is deleted and data is lost but deb files the location is not cleared .
Thanks in advance
ogra
January 21, 2021, 1:34pm
7
charithv:
extraResources
iirc electron-packager allows specifying that via a commandline flag or in package.json:
@electron/get documentation - mirrorOptions: alternate URL options for downloading Electron zips. See @electron/get documentation for details - rejectUnauthorized: whether SSL certs are required to be valid when downloading Electron. Defaults to true, use --no-download.rejectUnauthorized to disable checks. electron-version the version of Electron that is being packaged, see https://github.com/electron/electron/releases electron-zip-dir the local path to a directory containing Electron ZIP files executable-name the name of the executable file, sans file extension. Defaults to appname extra-resource a file to copy into the app's resources directory icon the local path to an icon file to use as the icon for the app. Note: Format depends on platform. ignore do not copy files into app whose filenames RegExp.match this string. See also: https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#ignore and --no-prune. Can be specified multiple times no-deref-symlinks make sure symlinks are not dereferenced within the app source no-junk do not ignore system junk files from the packaged app no-prune do not prune devDependencies from the packaged app out the dir to put the app into at the end. Defaults to current working dir overwrite if output directory for a platform already exists, replaces it rather than
electron-packager-extra-resource.md
This is the example usage of electron-packager that I never found online anywhere else.
To add resource.exe and resource2.dll in the resource folder when you create an installer, this is how you do it with the --extra-resource commandline switch.
## --extra-resource
`electron-packager . --overwrite --asar --extra-resource="resource1.exe" --extra-resource="resource2.dll" --platform=win32 --arch=ia32 --icon=./frontend/dist/assets/icon.ico --prune=true --out=./build --version-string.ProductName='Hot Pan de sal'`
within the backend code you can refer to the files as:
This file has been truncated. show original
keeping user data around should be possible via (automatic) snapshots: