Link Search Menu Expand Document

Building Packages

If you have already learned how to build packages using command line interface of the regular Sailfish SDK, you will find the Platform SDK environment quite familiar. There is no surprise about because sfdk, the CLI frontend of the regular Sailfish SDK, is rather a lightweight dispatcher, redirecting your commands to the Platform SDK tools running behind the scene.

The most frequently used Platform SDK tool is mb2, and much of the sfdk commands translate directly to mb2 invocations as in this example:

(host) $ sfdk config --push OPTION1 VALUE
(host) $ sfdk config --push OPTION2
(host) $ sfdk SUBCOMMAND [ARGS...]
     ⇣
(PlatformSDK) $ mb2 --OPTION1 VALUE --OPTION2 SUBCOMMAND [ARGS...]

Here follows a brief introduction for those who jumps directly to Platform SDK use.

Listing installed build targets

You can use the command sdk-assistant list to list available build targets:

$ sdk-assistant list
SailfishOS-4.4.0.58
├─SailfishOS-4.4.0.58-aarch64
├─SailfishOS-4.4.0.58-armv7hl
└─SailfishOS-4.4.0.58-i486

Each build target lets you build software for a specific operating system version running on a specific hardware. Each target is listed under one tooling supporting the given OS version. So, in our example, we have installed one tooling (SailfishOS-4.4.0.58) and three targets for it (aarch64, armv7hl and i486).

Selecting build target

The Platform SDK comes with a convenient tool for building packages, called mb2. It accepts build target name with the command line option --target (or briefly -t). You can also set the default target by creating a shell alias or by similar means:

$ alias mb2='mb2 --target SailfishOS-4.4.0.58-aarch64'

Building packages

Enter a package directory. If you don’t have an existing package available, you can use the sample application as in the following example.

$ git clone https://github.com/sailfishos/sample-app-cppqml.git
$ cd sample-app-cppqml

You can now perform an all-in-one build procedure using the mb2 build command. After a succesfull build the resulting RPM package(s) can be found under the RPMS directory:

$ mb2 build
$ ls ./RPMS
cppqml-1.0-1.aarch64.rpm

The recipe for building the package can be found in a SPEC file in the rpm directory, in our exacmple case rpm/cppqml.spec.

Further reading

The mb2 tool comes with comprehensive built-in documentation. It is accessible with command mb2 --help.