Skip to content
This repository has been archived by the owner on Feb 10, 2020. It is now read-only.

Graphical Snaps for Ubuntu Core #755

Merged
merged 51 commits into from Jun 25, 2018
Merged

Graphical Snaps for Ubuntu Core #755

merged 51 commits into from Jun 25, 2018

Conversation

AlanGriffiths
Copy link
Contributor

Guide to creating graphical snaps for Ubuntu Core

@webteam-app
Copy link

User is not a collaborator of this repo. Please start demo manually.

@webteam-app
Copy link

Starting demo at: http://tutorials.ubuntu.com-pr-755.run.demo.haus/

In your ssh session to your device:
```bash
snap refresh core --edge
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That causes a reboot, right? Maybe worth a note?

On your ssh session to your device:
```bash
snap install --dangerous iot-example-graphical-xwayland-snap_0.1_arm64.snap
snap connect iot-example-graphical-xwayland-snap:wayland-socket-dir mir-kiosk:wayland-socket-dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the x11 interface autoconnect here? Also, can you please explain a bit what this does?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it isn't auto-connecting. The plug does apply to itself, i.e. since we declare that we satisfy the x11 plug, then the correct apparmor permissions for an X11 server (here Xwayland) are being automatically applied, i.e. bind to a socket. Here's the profile location:
/var/lib/snapd/apparmor/profiles/snap.iot-example-graphical-xwayland-snap.glxgears-kiosk
and contents on install: https://pastebin.ubuntu.com/p/kTgGBxm4kM/

What this connection should be needed for is to allow an x11 client connect to the X socket. These lines are added to to the apparmor profile: https://pastebin.ubuntu.com/p/5cRyhxw73y/

I don't understand why the application works without this. glxgears shouldn't be able to connect to the X11 socket without this. (glxgears not needing fonts or the other bits really)

Copy link
Contributor

@Saviq Saviq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this, a couple nitpicks left but good for approval already.

content: wayland-socket-dir
interface: content
target: $SNAP_DATA/wayland
default-provider: mir-kiosk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this file as-is, and installing it I got
2018-06-06T13:15:12Z INFO snap "iot-example-graphical-xwayland-snap" has bad plugs or slots: x11-plug (unknown interface "x11-plug")

Seems snapcraft doesn't deal well with having two "plugs" sections. If I combined them into one, that warning was removed.

On your ssh session to your device:
```bash
snap install --dangerous iot-example-graphical-xwayland-snap_0.1_arm64.snap
snap connect iot-example-graphical-xwayland-snap:wayland-socket-dir mir-kiosk:wayland-socket-dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it isn't auto-connecting. The plug does apply to itself, i.e. since we declare that we satisfy the x11 plug, then the correct apparmor permissions for an X11 server (here Xwayland) are being automatically applied, i.e. bind to a socket. Here's the profile location:
/var/lib/snapd/apparmor/profiles/snap.iot-example-graphical-xwayland-snap.glxgears-kiosk
and contents on install: https://pastebin.ubuntu.com/p/kTgGBxm4kM/

What this connection should be needed for is to allow an x11 client connect to the X socket. These lines are added to to the apparmor profile: https://pastebin.ubuntu.com/p/5cRyhxw73y/

I don't understand why the application works without this. glxgears shouldn't be able to connect to the X11 socket without this. (glxgears not needing fonts or the other bits really)

* Ubuntu Core is available on a range of devices.
This guide shows you how to set up an existing device: [https://developer.ubuntu.com/core/get-started/installation-medias](https://developer.ubuntu.com/core/get-started/installation-medias). If there's no supported image that fits your needs you can [create your own core image](https://tutorials.ubuntu.com/tutorial/create-your-own-core-image).
* Using a VM
You don't *have* to have a physical "Target Device", you can follow the tutorial with Ubuntu Core on a VM:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/on a VM/in a VM/

* Using Ubuntu Classic
You don't *have* to use Ubuntu Core, you can use also a "Target Device" with Ubuntu Classic. You just need to install an SSH server on the device.
```bash
sudo apt install openssh-server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssh is a handy metapackage for this

* Ubuntu Core is available on a range of devices.
This guide shows you how to set up an existing device: [https://developer.ubuntu.com/core/get-started/installation-medias](https://developer.ubuntu.com/core/get-started/installation-medias). If there's no supported image that fits your needs you can [create your own core image](https://tutorials.ubuntu.com/tutorial/create-your-own-core-image).
* Using a VM
You don't *have* to have a physical "Target Device", you can follow the tutorial with Ubuntu Core on a VM:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/on a VM/in a VM/

* Using Ubuntu Classic
You don't *have* to use Ubuntu Core, you can use also a "Target Device" with Ubuntu Classic. You just need to install an SSH server on the device.
```bash
sudo apt install openssh-server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssh is a handy metapackage for this.

@webteam-app
Copy link

Starting demo at: http://tutorials.ubuntu.com-pr-755.run.demo.haus/

Copy link
Contributor

@degville degville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great tutorial I really enjoyed reading it, thanks! I'm approving this as I can't see any blocking issues, but I've left plenty of paper cut comments inline you can tackle if you have the time. As some of the text is duplicated, I've only made the comments in the first tutorial. My only general comment is that images would make the tutorial even better.

* Industrial machine User Interface

positive
: The combination of Snap, the "mir-kiosk" Wayland server and Ubuntu Core ensures reliability and security of any graphical embedded device application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensures the reliability


negative
: This tutorial assumes you are familiar with the material in [Graphical Snaps for Ubuntu Core](tutorial/graphical-snaps). In particular, techniques for debugging problems in your snap are not covered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a layout perspective, I'm not sure a negative admonition immediately following a positive one is a good look - maybe make the negative an ordinary sentence beneath the above small list?


* An Ubuntu desktop running any current release of Ubuntu

* Your Target Device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 'Target Device' from one of the following:

* An Ubuntu desktop running any current release of Ubuntu

* Your Target Device
* Ubuntu Core is available on a range of devices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu Core is available on a range of devices. A device running Ubuntu Core.
^ this would also be good with a link to https://www.ubuntu.com/core


* Your Target Device
* Ubuntu Core is available on a range of devices.
This guide shows you how to set up an existing device: [https://developer.ubuntu.com/core/get-started/installation-medias](https://developer.ubuntu.com/core/get-started/installation-medias). If there's no supported image that fits your needs you can [create your own core image](https://tutorials.ubuntu.com/tutorial/create-your-own-core-image).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about supported device rather than existing device, which may confuse the reader.

positive
: **On a Desktop Environment that supports Wayland** you may find that glmark connects to that and not Mir.
This is easy to work around: tell Mir and the snap how to connect to each other:
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing bash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice, but it leads to a stray "bash" in the preformatted block

$SNAP/usr/bin/glmark2-wayland
```

and point the “command:” in the snapcraft.yaml file to it (don’t forget to install it in the snap!!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ellipses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg. ...and point the "command:", to avoid starting with a lower case a.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Because snapping applications can reveal lots of hard-coded paths and assumptions that applications make, which snap confinement will break. It is good to understand the steps needed to debug and solve these problems.

There can be many, many environment variables and support files that need to be set up inside snaps, for applications to run correctly. Much of this work has already been done and automated in the *snapcraft-desktop-helpers* project, we will be using this in a follow-up tutorial.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project , which we will be using this in a follow-up tutorial.


### Device Setup

Open another terminal and ssh login to your device and logged in install the “mir-kiosk” snap.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to your device and from this login install the...

## Snapping to use mir-kiosk
duration: 3:00

Changing this snapcraft.yaml to work with mir-kiosk requires one main alteration: Wayland is provided by another snap: mir-kiosk, so we need to get the Wayland socket from it somehow.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the first colon with a full stop/period - two colons in a sentence seems a little too much.

Copy link
Contributor

@caldav caldav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, I left summary suggestions for both.

@@ -0,0 +1,605 @@
---
id: graphical-snaps
summary: A guide to creating graphical snaps for Ubuntu IoT devices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "A guide to creating graphical snaps for Ubuntu IoT devices. Learn how to build a digital signage app for kiosks, advertising screens and other embedded displays."

@@ -0,0 +1,431 @@
---
id: graphical-snaps-xwayland
summary: A guide to creating graphical snaps for Ubuntu IoT devices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "A guide to creating graphical snaps for Ubuntu IoT devices on top of an XWayland stack. Learn how to build a digital signage app for kiosks, advertising screens and other embedded displays."

@webteam-app
Copy link

Starting demo at: http://tutorials.ubuntu.com-pr-755.run.demo.haus/

@evilnick
Copy link
Contributor

evilnick commented Jun 22, 2018

Let us know when you are happy to publish these and I will merge (you will need to change the status in the metadata to 'published' as well

@AlanGriffiths
Copy link
Contributor Author

@evilnick I'm happy. Pushing the metadata change...

@caldav caldav merged commit a2228dc into canonical-web-and-design:master Jun 25, 2018
@Saviq
Copy link
Contributor

Saviq commented Jun 25, 2018

Aand they're live! https://tutorials.ubuntu.com/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants