[CentOS] Trying to find packages that depend on package X.

Fri May 26 23:44:13 UTC 2006
Rodrigo Barbosa <rodrigob at suespammers.org>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, May 26, 2006 at 07:37:13PM -0400, William L. Maltby wrote:
> > > On Fri, 2006-05-26 at 14:06 -0300, Rodrigo Barbosa wrote:
> > > <snip>
> > > 
> > > > rpm -q --provides PACKAGE_NAME | sed 's/^/"/;s/\([^[:space:]]\) *
> > > > $/\1"/;/=/{h;s/ =.*$/"/;G}' | xargs rpm -q --whatrequires | grep -v -E
> > > > '^no package'
> > > 
> > > Still needs some work, Ran it here and only got 38 packages, s/b 207
> > > here. Timing on 1st run was
> > > 
> > >    real    0m0.701s
> > >    user    0m0.186s
> > >    sys     0m0.019s
> > > 
> > > By the time we get 207 pkgs, I suspect a little overhead penalty.
> > 
> > I didn't change it to improve performance, for to get all the
> > results correctly (previous one was missing some of them).
> 
> I ran the new one on that test. Yours might be right, but yum indicates
> not.

Considering my sed trick doesn't cross reference the provides data,
it is bound to differ from yum at some point.

You see, lets consider exim and sendmail. Both provide smtpd.
If a package requires smtpd and you try to remove exim, sendmail
still fullfils tnat requirements. Yum will detect this.

> > I really don't think there is any faster way to do it, since rpm
> > accessing its db3 files is what costs so much on this. 10 or 100
> > dependencies should make little difference.
> 
> Maybe it's just 'cause I've been around too long, but string processing
> is expensive and I expect that if your script found 5.5 times as many
> entries we would see a substantial increase. But as you say, that's not
> the issue.

Actually, that is why I'm using sed. Sed is very fast doing this kind of
thing. And yes, I have seen instances where string processing was a big
problem.

> I've not looked at the individual step's output in the pipeline you
> provided, but I'll have to learn a lot more about the output of rpm
> before I can dink around with it to find what's missing. Since yum can
> do it, as long as I can remember to "Just Say No" (TM), I don't feel
> like chasing it myself.

You might want to install apt for this trick. apt has an option where it
will only check, but not execute anything. So you will be pretty safe.

> I'm still interested to know if you think it's worth asking yum to do.
> It's got to be a simple thing since remove does everything we need it to
> do already.
> 
> What say ye: yea or nay?

Well, the _correct_ way to do this would be to use rpmlib directly
(either in C, python, perl etc). However, you can use apt for this.
It will do what yum does, with the added benefit you can tell it
not to execute anything.

- -- 
Rodrigo Barbosa <rodrigob at suespammers.org>
"Quid quid Latine dictum sit, altum viditur"
"Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEd5LNpdyWzQ5b5ckRAk3XAKC+hWryhVqSMST07fkjLryRGTlKnQCglxbB
bhfd9C/KuSY+/8oXycdnJy0=
=VkTk
-----END PGP SIGNATURE-----