[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Defining a macro if it is NOT yet defined



Hello.

I'm trying to hack together a SPEC file which should build identically
on RedHat, Mandrake and Debian machines.  However, for the Mandrake
build, I'd like to use some predefined macros (like %{update_menus}).
Now, since I'd put %{update_menus} in the %post scriptlet, I want to
have a "real" value there, and not just %{update_menus}, so that when a
Mandrake user installs this package which is built on a Debian PC (where
%update_menus is not defined) he'll still get the "real" value of
%%update_menus.

What I'm looking for is a way to %define a macro, if it's not yet
defined.  So something likd ifndef would be of good use here.

I'm currently trying something like:

%if %(echo %{?update_menus:1})
        # do nothing - update_menus is already defined
%else
        %define update_menus some value here
%endif

But that's not working :(  If %update_menus is already defined, the TRUE
part is executed (which contains nothing but the comment).  However, if
update_menus is not defined, I'll get this error message:

error: /home/askwar/rpm/SPECS/test.spec:41: parseExpressionBoolean returns -1

Is there a way to do this?

---- a little later... ----

Ah!  I figured it out.  I now have:

%if !%(test "%{?update_menus:1}" = 1 && echo 1 || echo 0)
        %define update_menus some value
%endif

However, that's a little "clumsy".  Is there a shorter way to do this?

Thanks,

Alexander Skwar
-- 
How to quote:	http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:	http://www.iso-top.de      |     Jabber: askwar@charente.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
                       Uptime: 12 days 20 hours 7 minutes





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []