Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the meaing of 1%{?dist} in SPEC file in RPM package

What does 1%{?dist} mean? What does %{?} mean? I didn't find the meaning of this anywhere

Name:           hello
Version:        2.8
Release:        1%{?dist}
Summary:        The "Hello World" program from GNU
License:        GPLv3+
URL:            http://ftp.gnu.org/gnu/%{name}
Source0:        http://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.gz
BuildRequires: gettext
Requires(post): info
Requires(preun): info
%description 

The "Hello World" program, done with all bells and whistles of a proper FOSS project, including configuration, build, internationalization, help files, etc.

%prep
%autosetup
%build
%configure
make %{?_smp_mflags}
like image 406
RahulKrishnan R A Avatar asked Aug 26 '14 14:08

RahulKrishnan R A


2 Answers

The question mark is for conditional evaluation. When a macro has no value rpm leaves the macro tag in place by default. The ? tells rpm to remove the macro tag if there is no value and substitute the value of the macro if there is one:

$ rpm -E 'foo:%{foo}'$'\n''bar:%{?bar}'
foo:%{foo}
bar:

$ rpm -D'foo foov' -E 'foo:%{foo}'$'\n''bar:%{?bar}'
foo:foov
bar:

$ rpm -D'foo foov' -D'bar barv' -E 'foo:%{foo}'$'\n''bar:%{?bar}'
foo:foov
bar:barv

So, as RahulKrishnanRA says, %{?dist} says use the distribution tag (rh, el5, rf, etc.) when one exists and an empty string when it doesn't.

Unfortunately, the only documentation link I have about this is not a particularly good one. http://www.rpm.org/wiki/PackagerDocs/ConditionalBuilds and the linked manual page.

like image 54
Etan Reisner Avatar answered Oct 18 '22 08:10

Etan Reisner


The {?dist} tag is used to mark the distribution revision of a package

like image 39
RahulKrishnan R A Avatar answered Oct 18 '22 08:10

RahulKrishnan R A