Unexpected failed dependencies when uninstalling a package using RPM

Viewed 491

When checking for packages that depend on a particular package (in this case lz4) using rpm it does not list any packages that require either lz4-1.7.5-2.el7.i686 and lz4-1.7.5-2.el7.x86_64...

# rpm -q --whatrequires lz4-1.7.5-2.el7.i686
no package requires lz4-1.7.5-2.el7.i686
# rpm -q --whatrequires lz4-1.7.5-2.el7.x86_64
no package requires lz4-1.7.5-2.el7.x86_64
#

But I can't uninstall either of them without using rpm --nodeps as they appear to be needed by systemd and/or systemd-libs.

# rpm --erase --allmatches lz4
error: Failed dependencies:
        liblz4.so.1()(64bit) is needed by (installed) systemd-libs-219-57.el7_5.1.x86_64
        liblz4.so.1()(64bit) is needed by (installed) systemd-219-57.el7_5.1.x86_64
        liblz4.so.1 is needed by (installed) systemd-libs-219-57.el7_5.1.i686
#

It looks like the output of rpm --whatrequires is wrong but is it? (I doubt that it is actually wrong - but I don't understand why doesn't it include systemd or systemd-libs?

I thought if using rpm --erase --test instead of rpm --whatrequires to identify if packages that have dependencies but is there another more reliable way to do this?

Thanks for your help.

2 Answers

this is a bit tricky. rpm --whatrequires tracks capabilities; not simply packages.

If you try again; you will see that:

rpm --whatrequires "liblz4.so.1()(64bit)"

will provide you the results.

rpm --erase --test seems a good way to go for me. An alternative would be to loop over the capabilities provided by the package that you want to remove; but that will be slower. Here is a small bash script that loops over the capabilities of lz4 and prints the packages who depend on those capabilities:

packageToRemove=lz4
for capability in $(rpm -q $packageToRemove --provides | awk '{print $1}')
do
    echo "packages requiring $capability:"
    rpm -q --whatrequires "$capability"
done

The following command gives me the result I was expecting though I still don't yet understand why rpm --whatrequires doesn't work. (I probably won't figure that out until I build my first package).

# repoquery --alldeps --whatrequires --cache --installed lz4
systemd-0:219-57.el7.x86_64
systemd-libs-0:219-57.el7.i686
systemd-libs-0:219-57.el7.x86_64
#

In some cases however the output can be "interesting"...

# repoquery --alldeps --whatrequires --cache --installed lvm2-libs
lvm2-7:2.02.177-4.el7.x86_64
lvm2-libs-7:2.02.177-4.el7.x86_64
# 

# repoquery --whatrequires --cache --installed lvm2
lvm2-7:2.02.177-4.el7.x86_64
# 
Related