SailfishOS RPM packaging - Part 2

A small example

The most common use case for packaging is to have the output of a GNU make setup be wrapped into a neat .rpm file. But we will take something more simple for this example - we only want to install a single configuration file.

You can view the finished project at github.

So, first we need to decide what we want to install and where to. In our case, the file is a configuration file that tells journald to save the system logs across reboots. It shall end up in /etc/system/journald.conf.d/journald-porting.conf. We now put the source files of the package into sparse/*.

Now we need to tell the packaging system some metadata about our project.
marina-porter-tools.spec

Name:	    marina-porter-tools
Summary:    Extra debugging tools and configs for porting
Version:    1
Release:    1

The interesting part is the %install section:

%install
mkdir -p %{buildroot}/
cp -r sparse/* %{buildroot}/

This tells the packaging system to install all files from sparse to the RPM temporary buildroot, creating the final filesystem hierarchy already.

Now we need to tell rpm explicitly which files are contained inside the finished package. We could do it the easy way:

%files
/etc/systemd/journald.conf.d/journald-porting.conf

But we can tell the package manager more about the installed files. In our case, we want the user to be able to overwrite the config files we installed, so we supply more metadata:

%files
%defattr(-,root,root,-)
%config /etc/systemd/journald.conf.d/journald-porting.conf

And that’s it. Assuming you cloned the example repo to hybris/mw/marina-porter-tools, you can now use the droid-hal-device helper script to build the finished .rpm:

./rpm/dhd/helpers/build_packages.sh \
    --build hybris/mw/marina-porter-tools \
    --spec rpm/marina-porter-tools.spec

Copy the generated .rpm file from droid-local-repo/$DEVICE to your phone and install it via pkcon - or add the package to your device’s build requirements to ease early porting.


Further references

Published by

Edit source on Github