[SailfishDevel] Lab experiment: running MerSDK as a container

Jussi Pakkanen jussi.pakkanen at jolla.com
Tue Jun 16 15:00:36 UTC 2015


Hello

To celebrate the newly released SDK we present some fun experimental 
science from the Jolla Airship Research Laboratories. As you might guess 
the following is very much not supported, and might break, maybe even 
spectacularly. Proceed at your own risk.

We have looked into running the Mer build machine in a container rather 
than in VirtualBox on Linux hosts. The main reason for this is 
performance improvements due to the following:

- a container sees all CPUs on the machine
- a container sees all the RAM on the machine
- no virtual machine disk access penalty

After some experimenting we got this working so you can build working 
RPMs in a container sdk machine. If you want to try it yourself, here 
are the instructions. Note that this requires a fairly new Linux 
installation. As an example Ubuntu versions older than 15/04 do not work.

For this we use the vdi image that comes with SailfishOS SDK. First 
create a subdirectory and cd into it. Then do this to mount the image 
(use sufficient amount of sudo/su according to taste):

cp ~/SailfishOS/mersdk/mer.vdi .
mkdir mersdk
qemu-nbd -c /dev/nbd0 mer.vdi
mount /dev/nbd0p1 mersdk

The build engine is set up so that it expects to be running inside 
VirtualBox. We need to alter it a bit to work standalone. First tell 
systemd that this directory is a full operating system install:

touch mersdk/etc/os-release

Then edit the ssh config file to allow password login and use port 22 
(obviously you can set it up according to your own taste).

nano mersdk/etc/ssh/sshd_config_engine

Remove an unneeded vbox dependency:

rm 
mersdk/etc/systemd/system/sshd.service.requires/etc-ssh-authorized_keys.mount

That should be it. Now we can start the container:

systemd-nspawn -bD mersdk

Note that there is a bug in Ubuntu at least where the console becomes 
unresponsive after a boot. There's a separate bug so that 'machinectl 
login' does not work. So we need to use ssh:

ssh -lnemo 10.0.1.10 (password nemo)
su

Now you have root login to a running MerSDK instance and you can 
configure it up to your liking. As an example set a password for the 
mersdk user or put your public key in authorized_keys.

To compile you need to put your code so that the mersdk user can see it. 
This can be done with scp, a git checkout, bind mounting a directory 
from outside the container or whatever you prefer.

After all that building a package is simple:

mb2 -t SailfishOS-armv7hl build (in your source root as user mersdk)

When you are done, log out and shutdown the container:

machinectl poweroff mersdk

Do try it out and let us know if it a) works and b) makes things better 
for you. Just remember that if it breaks, you get to keep both pieces. :)

Thanks and enjoy,


More information about the Devel mailing list