Re: Piping find output to an rpm macro

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

 



On 09/20/2017 05:28 PM, nicolas.mailhot@xxxxxxxxxxx wrote:
Hi,

I have a set of spec files that perfom the same operations on file lists.
They are bitrotting fast with each spec differing slightly from the other

I'd like to consolidate the operations in a common macro to have a single place to tweak/fix.

So basically I want something like

%mymacro -f outputfile $(find . -iname '*\.foo')

with mymacro defined as

%mymacro(f:) \
%define output_file_list  %{?-f*}%{!?-f*:foo.file-list} \
for file in %* ; do stuff

of course that does not work with rpm failing to parse find output as an argument list

Is there a clean way to make it work? I try very hard to forget everything about rpm macros every time I need to write one


In rpm >= 4.14.0 parametric macro arguments are expanded so you can sort of do this:

%define mymacro() %(for f in %{*}; do echo "XX ${f} XX"; done)

%mymacro %(find /usr/lib/rpm/platform/ -name "*-*"|tr "\n" " " )

...gives something like:

XX /usr/lib/rpm/platform/ppc8260-linux XX
XX /usr/lib/rpm/platform/mipsr6-linux XX
XX /usr/lib/rpm/platform/armv5tel-linux XX
[...]

The "tr" at end is needed because rpm doesn't consider newline as an argument separator for macros. Might be handy if it did, but then you never know what would break...

But of course the problem with all this is that the macros are expanded at spec parse time when you'd typically want to do stuff at time of build instead.

What are you actually trying to do? From the looks of the example you might be better off with shell functions instead, but hard to say without more context.

	- Panu -
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list



[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux