Learner
Learner

Reputation: 1644

Building RPM from source, how to install packages required to build in spec file

I'm new to building RPM packages and writing spec file for that. I have to write a spec file for building a package from github source code written in golang. Instead of installing golang, I'm trying to download tar and extract and use that because installation of that is not allowed in production system. Everything is working fine except the part that when I try to build the code using bin/go build it fails with a system header file : fatal error: systemd/sd-journal.h: No such file or directory. This works well when I install the system-devel package on that system. But how do I install it by mentioning in spec file rather than manually. When I specify it in the BuildRequires or Requires section, it fails in the starting. I can not yum install because that needs sudo access and rpm is being build with non-sudo access. How else can I install it , any suggestion is appreciable .

Thanks

Upvotes: 1

Views: 3283

Answers (1)

omajid
omajid

Reputation: 15223

Building RPM works in 2 different phases here:

  1. All the dependencies are installed.

  2. The RPM is compiled

The second phase is the actual rpmbuild command. It can only use Require or BuildRequire for dependencies. As you noticed, it runs as a normal user, so it can not install the dependencies. It can only check for them and abort. This is normal (and expected).

The first phase is actually run by the build servers (eg, Fedora's koji), or manually, but it's outside the scope of rpmbuild. It's perfectly fine if you manually have to sudo yum install systemd-devel before rpmbuild will work. But build servers actually automate it using the yum-builddep (or dnf build-dep) commands. These commands take a spec file and install all of their listed dependencies.

Upvotes: 2

Related Questions