How to add files to RPM during packaging?

Hi there

For specific reason I need to ship a binary with my app. I compiled it for three architectures, and I want the files to be in /opt/myapp/bin, say.
In SPEC file I think I can add it in %files, however it has to be in build root. The question is, how do I force qmake or whatever packages application (I use Qt Creator from Sailfish IDE) to copy some files to build root, which, say, are in bin directory in my project root?
I understand I need to deal with pro file, however I tried few things and nothing seems to copy the bin directory to build root, where SPEC file could do its job.

I’d be grateful for help,
Wunder

I suggest reading the documentation about packaging: Packaging | Sailfish OS Documentation

Even though the page doesn’t directly answer your question, have a look at how sailfishapp.prf handles installation of desktop and icon files. The same mechanism works in a pro file as well.

1 Like

You can either use your build system (qmake,cmake or whatever), or do it in the %install phase in the rpm spec.

For spec, do something like

%install
install -d %{_buildroot}/opt/
install -p -m 0755 out/bin/mybinary %{_buildroot}/opt/bin/

%files
/opt/bin/mybinary

For qmake, in a .pro or .pri file:

INSTALLS += mybinaries
mybinaries.files = out/bin/mybinary
mybinaries.path = /opt/bin

… and again use the %files snippet in the .spec.

HTH

(… but unless you have a really good reason to use hardcoded /opt/bin, you really should use %{_bindir} and $${PREFIX}/bin and similar

5 Likes

As @nephros showed above and the way I do it is in the %install phase in the spec-file: examples/sokoban/platforms/sailfish-os/harbour-sokoban.spec · master · eql / LQML · GitLab

1 Like

Thanks a lot for help.

To the pro file I added:

INSTALLS += sshpass
sshpass.files += bin/sshpass.aarch64 \
    bin/sshpass.armv7hl \
    bin/sshpass.i486
sshpass.path = /usr/share/$${TARGET}/bin/

To SPEC file some dirty changes like:

AutoReq: no
%define _unpackaged_files_terminate_build 0
%define _binaries_in_noarch_packages_terminate_build 0

Along with following in %files to ensure they are 755:

%attr(0755, root, root) %{_datadir}/%{name}/bin

Without those defines it complained, because the app is technically noarch, but contains binaries. I know this is not the best way, but the app won’t be published in Harbour anyway (as it calls external processes), so I don’t really care… Big thanks for help!

2 Likes