Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpmbuild %{dist} not defined on CentOS 5.5?

Tags:

I'm attempting to use the %{dist} tag in my RPM spec file to provide distribution-specific dependencies between Fedora Core (e.g. fc12), CentOS 5 (e.g. el5) and Amazon's Linux AMI:

Release: %_svn_revision%{?dist} 

and

# Depencencies %{?rhel:Requires: ...} %{?fedora:Requires: ...} 

Unfortunately, %{dist} doesn't appear to be defined in CentOS 5.5, and I haven't found a distribution-specific conditional that matches CentOS 5.5 (I thought el5 would match, but doesn't appear to). This ticket reported the missing %{dist} in CentOS in 2008, but hasn't been updated since 2009.

How can I get %{dist} defined in CentOS and what conditional should I use to match CentOS 5? Can any RPM gurus point me in the right direction?

like image 759
Barry Wark Avatar asked Feb 27 '11 19:02

Barry Wark


People also ask

What is Rpmbuild?

rpmbuild is used to build both binary and source software packages. A package consists of an archive of files and meta- data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package.


1 Answers

The dist macros isn't defined on CentOS 5 because it isn't in /etc/rpm/macros.disttag - there is a RPM named buildsys-macros-rhel that provides it, or buildsys-macros on fedora, but for some reason it is not repackaged by Centos.

Option 1) Download and install fedora build-macros from here

Option 2) invoke rpmbuild --define 'dist .el5' every time

Option 3) Manually edit /etc/rpm/macros.disttag to add macro definitions for rhel (5) and dist (.el5).

You can then use conditionals like this in your spec file:

%if 0%{?rhel}  == 5 %{Requires: foo} %endif  
like image 138
ggiroux Avatar answered Sep 19 '22 14:09

ggiroux