RPM Community Forums

Mailing List Message of <rpm-users>

Re: macro args broken

From: Elan Ruusamäe <glen@delfi.ee>
Date: Mon 25 Feb 2008 - 22:34:59 CET
Message-Id: <200802252334.59923.glen@delfi.ee>
On Thursday 21 February 2008 08:45, Ralf S. Engelschall wrote:
> On Wed, Feb 20, 2008, Elan Ruusamäe wrote:
> > ~/.rpmmacros:
> >
> > %argtest(p:b:a:) %{-b:b=%{-b*}} 1=%1
> >
> > $ rpm -E "%argtest -p 1 -b 2 param1 param2"
> > b=2 1=param1
> >
> > $ rpm -E "%argtest param1 param2 -p 1 -b 2"
> >  1=param1
> >
> > thus, if parameters are passed before options, the options are not to be
> > seen
>
> Yes, the RPM macro parser uses positional options and does not support
> permutations of options and arguments (as it was based on getopt and
> because it makes sense for macros anyway). In latest RPM 5.1.DEVEL
> it actually uses POPT and could support permutations but I strongly
> recommend to keep it running like getopt there as else it would break
> lots of macros, I guess.

so this means i should start converting to use options before arguments if i 
want to be compatible with rpm5?

and seems that's not always possible due the nature of the macro the problem 
was first noticed.

%browser_plugins_add_browser %{name} -p %{_libdir}/%{name}/plugins -b <<'EOF'
# opera does not use for .xpt files
*.xpt
EOF

the macro adds 'cat' at the end of the expansion if -b option is present, 
resulting shell code with heredoc:

cat > $RPM_BUILD_ROOT/something <<'EOF'
# opera does not use for .xpt files
*.xpt
EOF

note that i can't make %{name} as last macro argument as it would break 
heredoc.

-- 
glen
Received on Mon Feb 25 22:35:07 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.