Reverse dependency generation with zypper
Asked Answered
L

6

14

With zypper, I can get package A depends on package B. However, what I need to know is which packages depend on package B.

Is there a way of generating a reverse dependency list?

Lection answered 29/8, 2012 at 17:55 Comment(0)
A
1

Let's say you want to know who depends on libpng14

In tcsh:

zypper search -i | cut -d \| -f 2 | tr -s '\n' ' ' > z.txt
foreach i ( `cat z.txt` )
  zypper info --requires $i |grep libpng14 &&echo $i
end

And you in a while, you will start getting results like:

libpng14.so.14()(64bit)
libpng14.so.14(PNG14_0)(64bit)
DirectFB
libpng14.so.14()(64bit)
libpng14.so.14(PNG14_0)(64bit)
MPlayer

You need to separate the packages from the grep messages, however.

Amadeo answered 31/12, 2012 at 16:28 Comment(1)
(use the -q modifier of the grepcommand to not echo results)Cheerleader
K
29

You can search (abbreviated with "se") for packages that require a certain package with:

zypper se --requires packagename

Also, you can search only among installed packages with:

zypper se -i --requires packagename

For example, to look for packages requiring libpng:

# zypper se -i --requires libpng
Loading repository data... 
Reading installed packages...
S | Name                        | Summary                                                             | Type   
--+-----------------------------+---------------------------------------------------------------------+--------
i | DirectFB                    | Graphics Library for Framebuffer Devices                            | package
i | MPlayer                     | Multimedia Player                                                   | package
i | cairo-devel                 | Development environment for cairo                                   | package
etc.
Karlee answered 19/11, 2015 at 11:34 Comment(1)
But zypper se --requires gdal shows gdal-devel, while zypper info --requires gdal-devel does not list gdal as requirement. What am I misunderstanding?Kafiristan
B
5

Zypper 1.14.33+ has --requires-pkg which might yield more results than --requires. See here for details.

# zypper se --requires-pkg packagename

# zypper help search | grep -A1 requires-pkg
--requires-pkg          Search for all packages that require any of the provides of the
                        package(s) matched by the input parameters.
Boost answered 28/9, 2021 at 13:17 Comment(2)
An explanation please?Athlete
@Athlete I just know that --requires didn't work for me. I found --requires-pkg in the help and it worked. I don't know why.Boost
A
1

Let's say you want to know who depends on libpng14

In tcsh:

zypper search -i | cut -d \| -f 2 | tr -s '\n' ' ' > z.txt
foreach i ( `cat z.txt` )
  zypper info --requires $i |grep libpng14 &&echo $i
end

And you in a while, you will start getting results like:

libpng14.so.14()(64bit)
libpng14.so.14(PNG14_0)(64bit)
DirectFB
libpng14.so.14()(64bit)
libpng14.so.14(PNG14_0)(64bit)
MPlayer

You need to separate the packages from the grep messages, however.

Amadeo answered 31/12, 2012 at 16:28 Comment(1)
(use the -q modifier of the grepcommand to not echo results)Cheerleader
S
0

If it's already installed, you can use rpm --whatrequires:

--whatrequires CAPABILITY
        Query all packages that require CAPABILITY for proper functioning.
        Note that this does not return what requires a given package. 

If not, you[we]'re out of luck for now.

Summers answered 7/9, 2012 at 23:52 Comment(1)
Thanks - but rpm does not seem to be working correctly. According to rpm nothing in the system is required by anything else. Hence, rpm can uninstall everything by itself :(Lection
C
-1

This works:

rpm -e --test PKGNAME

Source: man rpm

Clip answered 24/6, 2015 at 6:14 Comment(0)
S
-1

I hope it's useful:

betatester@myryzen:~/tmp> rpm -qi --requires \`rpm -qa | grep 'package-name'\`
Spratt answered 18/9, 2020 at 9:56 Comment(1)
How does this compare to the existing answers? Given that this question is answers, and have an answers with over twenty upvotes, it's useful to ensure your answer is adding new information—and to explain to readers why that new information is relevant and useful compared to the existing answers.Herve

© 2022 - 2024 — McMap. All rights reserved.