HTML5 game without electron

Where can I find a WORKING example with packaging html5 game to ubuntu snappy package?
(pyqtwebkit or qmlscene, or something else)

Sure. It depends a bit on the platform. Is there a particular platform you’re using such as construct2/3, phaser.io, Unity3D, GameMaker or Godot?

Sure, here’s an example. Put your game in a ./gamedir, and download nwjs for linux and plop it in the same directory. Run snapcraft and this will build a snap of your game, bundled with the nwjs runtime.

name: gamename # short name for game, all lower case
version: '1.0' # arbitrary version number, can be any text
summary: Game Name # Short human readable name of the application
description: |
  This is a game ...  # Multi-line 79 column wide description of game

grade: stable
confinement: strict # strictly confined application

# The apps section exposes a command to the running system
# The plugs allow access to the network, display, sound and input
# devices
apps:
  gamename:
    command: desktop-launch $SNAP/nw
    plugs:
      - network
      - network-bind
      - x11
      - wayland
      - desktop
      - opengl
      - pulseaudio
      - browser-support
      - screen-inhibit-control
      - joystick

# 3 parts are needed
# metadata: directory containing a package.json used by nwjs to describe the application
# and set the initial screen resolution of the window
# nwjs: dumps the build of nwjs into the snap as-is. This was just downloaded from the nwjs
# website and is unchanged. Will get unpacked into the snap
# game: the actual unpacked game itself. Will also get dumped into the root of the snap
# along with nwjs.
parts:
  metadata:
    plugin: dump
    source: metadata/
  nwjs:
    plugin: dump
    source: nwjs-v0.28.0-linux-x64.tar.gz
  game:
    plugin: dump
    source: ./gamedir
    after:
      - nwjs-support
      - desktop-gtk3

1 Like

Thank you for help, but I have this error:

Priming desktop-gtk3 
Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:
usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
The GLIBC version of the targeted core is 2.23. A newer libc will be required for the following files:
- /home/michal/mygame/prime/usr/lib/x86_64-linux-gnu/libgnutls.so.30.14.10 (requires GLIBC 2.25)
- /home/michal/mygame/prime/lib/x86_64-linux-gnu/libexpat.so.1.6.7 (requires GLIBC 2.25)
- /home/michal/mygame/prime/usr/lib/x86_64-linux-gnu/libp11-kit.so.0.3.0 (requires GLIBC 2.26)
- /home/michal/mygame/prime/usr/lib/x86_64-linux-gnu/libexpatw.so.1.6.7 (requires GLIBC 2.25)
- /home/michal/mygame/prime/lib/x86_64-linux-gnu/libbsd.so.0.8.7 (requires GLIBC 2.25)
'libc6' is required inside the snap for this part to work properly.
Add it as a `stage-packages` entry for this part.

I guess you’re doing this on something other than Ubuntu 16.04? You should do this in a 16.04 VM or use lxc or some other container to ensure the libs that get pulled in are 16.04 releases.

Personally I use lxc which is covered in this doc. Build on LXD

Figured as much. Use 16.04.

I just drop gamename.png and gamename.desktop in snap/gui and it gets picked up by snapcraft. Make sure the png and desktop files have the same name as the snap itself.

Ah. The filename must be jmemorize.desktop, not gamename.desktop - and the same for the png.

I think you need to take a step back a moment. You’ve taken a template, where the word “gamename” needs to be changed everywhere. Do that first. Note that in your screenshot you have a gamename_1.0_amd64.snap - that should surely be jmemorize_1.0_amd64.snap? To do that, check the yaml, and change any instance of “gamename” to “jmemorize”. Then the name will match the names of the desktop file / icon.

Hope that helps.

Yeah, I assumed you’d change the gamename :slight_smile:

error while Preparing to pull desktop-gtk3
am on ubuntu 16.04 with latest snapcraft

tar: ./usr/share/themes/Radiance/gtk-3.0/assets: Cannot open: File exists
tar: Exiting with failure status due to previous errors
dpkg-deb: error: subprocess tar returned error exit status 2
Error while provisioning '/home/bulld/code/A-snap/nwjs/parts/desktop-gtk3/ubuntu/download/light-themes_16.10+16.10.20161024-0ubuntu1~ubuntu16.04.1_all.deb'