Packaging a custom app or lib

In order to build an package as a rpm you’ll need a .spec file. This file has the package depencencies (build and runtime), how the source has to be compiled and what files will be included. It also has metadata about the package. The .spec file can be generated from a .yaml one, which is easyer to understand and read.

Useful links:

The spectacle (.yaml file) and the .spec file are parts of the rpm workflow. They aren’t Sailfish/Mer specific. Fedora/Red Hat documentation applies.


.spec file is generated automatically from the .yaml one, using the command specify. According to the mer wiki .yaml files are not mandatory, and should not be used in packages that require heavy customization.

[mersdk@SailfishSDK ~]$ specify --help
Usage: specify [options] [yaml-path]

  --version             show program's version number and exit
  -h, --help            show this help message and exit
                        Path of output spec file
  -s, --skip-scm        Skip to check upstream SCM when specified in YAML
  -N, --not-download    Do not try to download newer source files
  -n, --non-interactive
                        Non interactive running, to use default answers
  --new=NEWYAML         Create a new yaml from template
  --newsub=NEWSUB       Append a new sub-package to current yaml

Tags of YAML

YAML spec For full description refer to this link

Note: If a string starts with %, you’ll have to quote or double quote it.

See sphinxbase.yaml example


The spec file could be autogeneradet by the specify command, because of that it’s not recommenden to edit it. Custom tweaks must be done in the correct placeholders. The text between the markers will be kept as is.

Note: sub-package is the name of the sub-package, it is optional. For the main package, the placeholder is >> files. If list is simple, it should have been included in the .yaml file.

Note: Only if Check is specified as yes

Note: Not generated by default, if needed they must be added

Note: Not generated by default, if needed they must be added

Note: Not generated by default, if needed they must be added

Note: Not generated by default, if needed they must be added

See sphinxbase.spec example

For further information: mer wiki.

Variables or macros

See this link for more info

Building the package


Make sure that the “MerSDK” Virtual Box machine is running, since the cross compilation is done inside the Virtual Box. You can start it as explained in Develop without qt-creator

You can run the compile commands through the Virtual Box window. Or log in via ssh to the build engine to run the compile commands. Login as user mersdk.

The sb2 command and it’s helper tools sb2-* are the tool used to do the cross compilation. The Mer wiki has a nice introduction to sb2. In the Build Engine the available sb2 targets are:

[mersdk@SailfishSDK ~]$ sb2-config -l

The SailfishOS-armv7hl target is used to build binaries for the device, the SailfishOS-i486-x86 target can be used for Sailfish OS Emulator Virtual Boxes. So for any sb2 commands you run, use the option -t to tell sb2 with which target you want to operate.

[mersdk@SailfishSDK ~]$ sb2 -t SailfishOS-armv7hl ...

With sb2-config -d SailfishOS-armv7hl you can configure SailfishOS-armv7hl to be the default target. So you don’t need to provide the -t option.

Intalling dependencies

The SailfishOS-armv7hl target might not have all the necesary development tools or headers installed. You can search the packages:

[mersdk@SailfishSDK ~]$ sb2 -t SailfishOS-armv7hl -m sdk-install -R zypper search <package name>

And then, install them:

[mersdk@SailfishSDK ~]$ sb2 -t SailfishOS-armv7hl -m sdk-install -R zypper install

Compile and RPM

Now you can start compiling, use the usual commands just put sb2 -t SailfishOS-armv7hl always in front of it.

To create an RPM package, you need to create the .spec file. If possible create the .yaml file using the instructions here, build the .spec and tweek it according the build engine used. To build the RPM you can use the mb2 tool (it needs the same -t option as sb2):

[mersdk@SailfishSDK ~]$ mb2 -t SailfishOS-armv7hl -s path/to/my_sdl_project.spec build