Add extra generated RPM requires - how?

Steve Grubb sgrubb at redhat.com
Fri Dec 18 21:25:49 UTC 2009


On Friday 18 December 2009 03:54:53 pm Adam Jackson wrote:
> On Fri, 2009-12-18 at 20:26 +0000, Richard W.M. Jones wrote:
> > For libguestfs [RHBZ#547496] I want to add some extra 'Requires'
> > dependencies by running a shell script over a particular file that
> > gets generated during the build.
> >
> > What's the best way, or a way, to do this?
> 
> It's... not easy.  You want to overload the %__find_provides macro to
> invoke your script as well as the standard script for things like
> library sonames. 

I used something like this:

#%_use_internal_dependency_generator     0
#%__find_requires       /home/sgrubb/bin/find-requires

and then ran a shell script that had this piece in it where $1 was a file 
suspected of being a bash script by running the file command. Since people have 
a habit of using a script name and not its full path, it uses which to resolve 
the full path. This might be better done using the full rpm database that yum 
operates off of. Anyways...this was the core of it:

# Then check its requirements
cmds=`/bin/bash --rpm-requires "$1" | sort | uniq | tr '()' ' ' | awk '{ print 
$2 }'`
for c in $cmds
do
        tgt=`which $c 2>/dev/null`
        if [ x"$tgt" = x ] ; then
                echo "$c cannot be resolved" 1>&2
                continue
        fi
        tmp_r="`rpm -qf $tgt`"
        if [ $? -eq 0 -a $RPM -eq 1 ] ; then
                # Only use good results for rpms
                r="$r\n$tmp_r"
        else
                r="$r\n$tgt"
        fi
done

echo -e $r | sort | uniq
exit 0


-Steve




More information about the fedora-devel-list mailing list