packages: dovecot/dovecot.spec - TODO was accidentally removed (sorry), but...

Jeff Johnson n3npq at mac.com
Sun Oct 31 02:00:09 CET 2010


On Oct 30, 2010, at 8:08 PM, Paweł Zuzelski wrote:

> On Thu, 28 Oct 2010, caleb wrote:
> 
>> Author: caleb                        Date: Thu Oct 28 09:53:02 2010 GMT
>> Module: packages                      Tag: HEAD
>> ---- Log message:
>> - TODO was accidentally removed (sorry), but having [percent]service in the spec even on a commented line breaks the build. Bug in builder?
> 
> No, it is not a bug.
> 
> '#' is not a comment in spec files. To be precise, it does not
> prevent rpmbuild from expanding %macros. The problem is that
> %service macro is multiline macro, so
> 

Yup: macros are context free, expanded everywhere they are
encountered, within quuoted strings, in comments, everywhere

(aside)
They used to be expanded in the false branch of %if but that was a bit painful ..

MEANWHILE ...

... there's actually a feature hidden ther too.

Let's say you have two sets of macros you need to define, like
Fedora <-> Mandriva have decided to rearrange all the paths
in a package for some reason (I use "vendor" only for clarity, there's lots of
times that you want two rather different sets of values defined in packaging).

If you capture, say, the Fedora != Mandriva differing in what to call "mysql"

%fedora	\\\
Requires: MySqL \\\
#

%mandriva \\\
Requires: mYsQl \\\
#

Then in the spec file you would put

# %{?fedora} %{?mandriva}

Which (assuming no typoes from me) one ends up with multiline expansions
that "drops down" one or the other (or both if both %fedora/%mandriva are defined)
exposing the Requires: (or whatever text one wanted) into the spec file.

I've always wanted to see cleaner packaging using the fact that macros
_ARE_ expanded in comments, rather than the unexpected behavior bug report.

hth

73 de Jeff







More information about the pld-devel-en mailing list