RPM Community Forums

Mailing List Message of <rpm-users>

Re: conditionally define %_rpmfilename macro

From: Jeff Johnson <n3npq@mac.com>
Date: Fri 09 Jan 2009 - 20:56:52 CET
Message-id: <DECDE134-9069-4EA5-BB12-EF03A40A0300@mac.com>

On Jan 9, 2009, at 2:40 PM, Jeff Putsch wrote:

> Howdy,
> I'd like the format for the rpm filename to depend on whether the  
> RPM is a 'noarch' package or for a specific architecture.
> I'd like to do something like the following in /etc/rpm/rpmmacros  
> (borrowing from spec file format):
> %ifnarch noarch
> %_rpmfilename  %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}.rpm
> %else
> %_rpmfilename  %%{NAME}-%%{VERSION}-%%{RELEASE}.%noarch.rpm
> %endif
> I've googled, read the docs, and the source macro files that come  
> with rpm5, to no avail.
> I'm clearly too much of a newbie to RPM macro files to know how to  
> properly do what I'd like.

The simplest way to achieve what you want is to isolate
the per-arch difference into Yet Another Macro.

So you want a single constant-valued

    %_rpmfilename  %%{NAME}-%%{VERSION}-%%{RELEASE}.%{myarchsuffix}.rpm

template, with the details buried in %{myarchsuffix}.

Default into a per-noarch case and a fallback:
	%myarchprefix	%{?mynoarchsuffix}%{!?mynoarchsuffix:%%{ARCH}-%%{OS}}

This is basically a if ... then ... else ... fi construct based on
the existence of a %mynoarchsuffix macro (the value of which will be  
used if defined)
with an %{!?...:...} else clause for "everything but noarch".

Finally, supply a definition in the noarch macro configuration,
usually in /usr/lib/rpm/noarch-linux/macros (but could be elsewhere) as
	%mynoarchsuffix		whateveryouwant


73 de Jeff

  • application/pkcs7-signature attachment: smime.p7s
Received on Fri Jan 9 20:57:08 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.