Help with first rpm package


I’m kinda struggling trying to create my first rpm package here. I’m using a new music player called Olivia (GitHub - keshavbhatt/olivia: Elegant music player for LINUX) as an example and this is what I have so far:

The first couple sections are quite clear by now (naming and versioning, release, summary, buildarch, licensing, url and source) , then it’s when it’s start getting confusing.

If i go to this app’s website/where the source code is stored on github the creator posted some instructions which are working in my case. To install from source in this case it’s just a matter of running qmake-qt5 and then make , this I tested and it works, once I do that I end up with a binary which i can run with ./

Now the first question is: to install from source there’s several methods depending on a lot of things, in this case it’s 2 commands. Do I always have to put those commands (whatever they are) under the %build section whenever I’m creating a new .spec file? In my spec file i added qmake-qt5 and make but I’m not really sure that’s the way it’s supposed to be written.

On another note, for the BuildRequires dependencies I just checked the exact name of the packages that were required with “yum whatprovides name-of-package-required” and added that package to the requirement. Is that fine or something else needs to be done here?

And lastly and probably most important, what’s the difference between the %build and %install sections? I’m not really sure about my install section in this example, didn’t look much into it cause I was already struggling with the rest.

Apologies for the long post, the information on how to do packaging seems either too simple (some hello world script) or overcomplicated.

Name:           olivia
Version:        1
Release:        1%{?dist}
Summary:        A cool and new music player

BuildArch:      noarch
License:        MIT
Source0:        %{name}.tar.gz

BuildRequires: qt5-devel
BuildRequires: coreutils
BuildRequires: socat
BuildRequires: python
BuildRequires: wget

Cool new music player

%setup -q


mkdir -p %{buildroot}%{_bindir}
install -p -m 755 %{name} %{buildroot}%{_bindir}/%{name}


1 Like

Here’s a rough description of the sections:

  • %prep is where you “prepare” the sources for building: patch files, extract archives, etc. This distinction is important because %prep is the only step out of these three that gets run when you build a source RPM, which consists of the package sources and spec file but no binary files. Therefore, %prep’s job is basically to get everything ready for a build.
  • %build and %install are actually pretty much what their names imply: %build is where you build the application’s files, and %install is where you install those files into your buildroot.

So, your organization looks roughly correct.

All the qt5-devel packages pull in qt5-rpm-macros, which provides some macros you can use instead of manually calling qmake/make. Based on the qt-creator spec file, I believe your ideal %build section would be:

export QTDIR="%{_qt5_prefix}"
export PATH="%{_qt5_bindir}:$PATH"

%install wouldn’t need any changes here.

You could maybe be a bit more specific with your BuildRequire; in particular, qt5-devel will probably pull in more Qt libraries than your app needs. I also think you can drop coreutils. (These are pretty minor tweaks you could probably leave for later.)

BuildArch: noarch is only for packaging that have no platform-specific binaries, so that line should probably be dropped. Also, you might need to add -D to your install command (or if it works as-is then you could probably leave it).

For testing your spec file, fedpkg mockbuild is great because it builds your package inside an isolated chroot, so any BuildRequires you forgot will give an error here.

I know rpm packaging can be kinda weird at times, hopefully this info dump helps a bit. ¯\_(ツ)_/¯

1 Like

First, it requires mpv, don’t forget it.

I made a GIST with some corrections… But you need fix “Installed (but unpackaged) file(s) found”. Remember the use de macros here. I am not tested the “.spec” file…


  1. Creating RPM packages. Here (General). and Here explained your questions…

  2. Read about Git Sources guidelines. Here

  1. About macros Fedora. Here

  2. Wiki about how to use mock. Here

  3. Complementary… Using Shell Variables. Here