I'm working on updating my rpm packaging to move away from external dependency generation.
Currently I do the following (which works as expected):
%define _use_internal_dependency_generator 0
%define __find_requires /bin/sh -c "/usr/lib/rpm/find-requires | /usr/bin/my-custom-script"
To move to an internal generator, I've been reading this documentation and in the Writing Dependency Generators
section it shows using an internal generator like this:
%__foo_requires /some/script %{NAME} %{VERSION}
So I was thinking that means foo
should be my package name. So I tried %__%{NAME}_requires
. This puts my package name in there as expected, but my custom script does not appear to get called.
This is what I ended up trying:
%__%{NAME}_requires /bin/sh -c "/usr/lib/rpm/find-requires | /usr/bin/my-custom-script"
%define _use_internal_dependency_generator 1
I'm looking for advice on how to properly use an internal dependency generator from within a spec file to create requires
for my rpm package that appear the same as they did with the external generator.
I came back to this a few months later and was able to internalize the details in the RPM dependency generator docs better. I'm not sure if this will ever help anyone else, but here is what I found.
In the /usr/lib/rpm/fileattrs/
directory there are a bunch of .attr
files that define macros that are used during rpmbuild's process.
I'll use the elf.attr
file for reference.
The %__elf_magic
macro provides a regular expression to match what files to apply the %__elf_requires
and other macros in the elf.attr
file to.
The executable set in the %__elf_requires
macro will get its list of files on stdin (not as normal arguments to a bash script).
In my case, I need to modify what goes into the RPM's Requires
field. That is what the elf.attr
's %__elf_requires
does.
One possibility is to create my own mygenerator.attr
file with %__mygenerator_requires /usr/bin/my-custom-script
. I'm not 100% sure where to place this .attr file, I don't necessarily want to install it in the same dir as the others.
Another option is to "override" the %__elf_requires
macro in my spec file templates to something like %define __elf_requires /usr/bin/my-custom-script
.
Since what I want to do is tweak what the elf.attr
does for Requires
, this is most likely the thing I will do.
I'm open to suggestions though.