I’ve recently been wanting to ensure my Mir changes don’t break qtmir. Unfortunately, QtMir is actually rather hard to build in my Cosmic Cuttlefish development environment due to all the missing dependencies.

So I wanted to try testing in an LXD container; it’s easy to spin up a 18.04 container, which UBports supports. This mostly works, and for anyone else wanting a relatively easy development environment, here’s the process:

Unfortunately, that’s not quite enough; the Mir build generates files in the source tree, which won’t work - the container users do not have (usually) write access to the source tree. We can “fix” this with chmod -R a+w $PATH_TO_MIR_SOURCE to make the Mir source tree world-writable.

However: the root user in the container isn’t privileged and doesn’t have access to /dev/tty*, so --console-provider=vt won’t work. Likewise, the container doesn’t have access to the host’s DBus bus, and so --console-provider=logind won’t work either. The new MinimalConsoleServices implementation will work, though.

Although drmSetMaster will fail (as the container user doesn’t have real root privileges), opening the drm device when there is no current DRM master will implicitly gain DRM master. Yay!

There’s one final problem - input. Although you can pass through arbitrary character devices (such as /dev/input/event3), it doesn’t seem like the libinput platform can access them correctly, possibly because they don’t show up correctly in udev? Anyway, we can test without input by loading the stub input platform.

So now, we can switch to a VT (so that any existing display server drops their DRM master) and run

CLion Bonus Round!

One of the new features of the CLion IDE is remote build support. This means you can get full refactoring and source navigation support even if your local machine can’t build the project. Such as here, where 18.10 can’t build qtmir!

For this you’ll want a passphrase-less SSH key so CLion can access the LXD container without user interaction, and enable root logins in the container, like so:

In CLion you can now go to File→Settings→Build, Execution, Deployment→Toolchains and add a new “QtMir LXD” toolchain. Select “Remote Host”, configure the credentials to be the IP address of your lxd container, user: root, and use the OpenSSH config and authentication agent auth type.

Boom! You can now build QtMir in the LXD container from the comfort of your own IDE, and CLion will have a buildsystem to parse and generate all the code-completion goodness!