1

I'm building packages on a few different VMs (CentOS5 32 & 64, CentOS6 32 & 64, Fedora, etc). and the resulting RPM file contains the name.version.release.arch.rpm, as in:

foo-1.1-1.i386.rpm

But instead, I want it to output as:

foo-1.1-1.el5.i386.rpm

Where (in the spec file? .rpmmacros?) and how do I do that?

Thanks in advance.

2 Answers 2

3

In .spec file use this:

Release: 1%{?dist}

This is substituted to e.g. el6 RHEL6 etc. At least on Oracle Linux 6.5 with installed '@Development tools' and rpmdevtools.

1

In the Release tag:

Release: 1.el5

Often, people create a custom definition and then include that:

%define OSshort el5
Release: 1%{?OSshort}

Then, you could also use logic to define OSshort based upon what OS you're building on.

Updated: I modified the Release tag to only use OSshort if it's defined. Then, you can leave it undefined in the spec file and define it during the build command

$ rpmbuild -bb --define 'OSshort _el5'

Writing logic to test OS/distributions and automatically generate that involves parsing that's a bit more complex and I can't find an example right now.

2
  • Thanks - I'm very new to rpmbuild. Can you give a little more detail as to what type of logic I could use to generate the OS tag? Ideally, I'd love to use an identical spec file across all systems, and be able to share the spec file with others so it "just works."
    – SteveJ
    Aug 15, 2011 at 22:01
  • My answer below works without defining anything. SteveJ, consider marking my answer as the solution. Feb 5, 2014 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.