How to remove dependencies with packages?

When one installs an application,it brings in other stuff too as dependencies.

When this application is removed,will zypper remove the dependencies that came with it and are not needed by other installed packages?

Is it possible to check before and after removal?

Yep.

Nope, still not possible. Write them down during install and remove them by hand (I do this often when I do a short try-out of a product), or forget about them being there (on todays disks it takes almost no space).

I do not understand exactly what you want to check, but you can always make lists using the* rpm -qa *command and compare them.

Thanks Henk.

I thought I read somewhere (in RPM manpage?) that RPM can list packages not needed by any other package.But today I cannot find the option.Perhaps I am missing it.

Well, one should study the* man rpm* page thouroughly because IIRC there is a way to list the dependencies of an RPM (about the same you remember vaguely). On could then write a script that checks if an RPM is mentiond nowhere in the list of all packages that are dependent on another one (on a rainy day). But take care: such a package may be dependent on no other one and still very much wanted. E.g. I do not know if the kernel draws in dependencies, but you do not want it to be deinstalled by such a script, want you?

And I think this shows some of the problems that emerge when one tries do do what you want. And deep inside myself I suppose that that is the reason it is not done until now.

I browsed through the man page and found

rpm -e --test* PACKAGE_NAME*

which will remove the package and thus show errors when another one is dependent on it. Because of the* --test* it will not do the removing.

I am realy tempted to dig into this :), but then I need a sandbox system. I will not test such a script on my production ones rotfl!

Hello pbhat,

I’m not aware of any function capable of that.

But I found a program that will do it for you.
It’s available in the packman repository and it’s called rpmorphan.

This program only shows packages which have no other packages depending on their installation.
This doesn’t mean you don’t need that package!

I never heard of the parameter --test before but it looks handy!

Good luck!:wink:

I first looked at what* rpm -q could do. There it says that when you want to see dependencies then go for rpm -e --test*. So it may not look very logic to go for an rpm -e version, but the man page is handling this very good.

BTW thanks for the info about rpmorphan. Very usefull.

And I am also glad you stress that human intervention is needed and an automatic deinstall functionality, which is asked for very often, can not easily be inplemented.

Having used Debian before converting to openSuse a few years ago, I must admit that one thing that I do miss is deborphan, which will list all files which have no more use, ie the file which was dependent on them has been removed. And, an easy to access install history. The history was especially good as when dependencies were installed along with a main programme which was then removed, the dependencies can be easily removed by a quick check at the history within the packet manager.

Thanks Edward for mentioning rpmorphan and reminding me the whole thing.The man page for rpmorphan says it is run after distribution upgrade to clean up the system of un-needed packages.But hcw’s caution is very important.I have seen even if a distribution upgrade removes packages it thinks are no more needed,lot of fossils remain around.The algorithm involved may be more than just remove what rpmorphan lists.
@Dwarfer99
Even in Ubuntu,removing a package does not remove the child dependencies.
Perhaps rpmorphan and deborphan are only meant for helping manual purging of the system.

In your terminal, type “zypper remove”, and you will get all the removal options. “zypper remove -u” or “zypper remove --clean-deps” will “Automatically remove unneeded dependencies”.

I just removed the package OpenOffice_org using the command “zypper remove -u OpenOffice_org”, and zypper alerted me to all the additional associated packages that were no longer necessary, such as jpackage-utils, OpenOffice_org-branding-openSUSE, xalan-j2, xerces-j2, OpenOffice-org-components, etc… Typed “y” to agree to removal, and openoffice and all the associated, unused dependencies were removed. Its a handy trick.

YaST is able to this by default in 11.4.I think zypper should suggest that it will try and remove “Dependencies” when “zypper rm OpenOffice_org” is fired instead of forcing
trying “zypper remove -u OpenOffice_org”.If intuitive facilities are present in command mode then more users will use command mode instead of GUI.The console/command modes are still catering to power users rather than regular users who need more intuitive interface.

If intuitive facilities are present in command mode then more users will use command mode instead of GUI.The console/command modes are still catering to power users rather than regular users who need more intuitive interface.

In Yast Software Management, you can select in the Menu Options, which will clean all unneeded dependencies.

If removal of unneeded dependencies can be the default behaviour, maybe after confirmation from user, it would be better.

In Yast Software Management, you can select in the Menu Options, which will clean all unneeded dependencies.

Yes. The box to check in the Options menus is called “Cleanup when deleting packages”. This will delete a package and its dependencies as far as they are not required by other packages.

Dear RPM developers: What would Apt have done:

When you request to install a package, resulting in other
packages being installed to satisfy its dependencies, the dependencies
are marked as being automatically installed. Once these automatically
installed packages are no longer depended on by any manually installed
packages, they will be removed

So Apt stores the distinction between

  1. packages installed as being directly required, and
  2. packages installed as dependencies of others.

It automatically removes packages only from category 2 (the automatically installed ones). As if the user counts as dependency in the reference counting. I believe this is the most sane behavior.

As far as I know, this info isn’t stored in the RPM database, which I presume is the reason Zypper/YaST lets you remove from both categories (or none by default).

Exactly. I think nobody wants precisely that. It mostly works, because packages being depended on (e.g. libraries) tend not to be useful on their own, but it happens:

  1. Suppose I want to have “vlc” installed, for its own sake, even if no package depends on it.
  2. Then, as a test, I install “phonon-backend-vlc” (which depends on vlc).
  3. Now, with one dependency on vlc, will “zypper rm -u phonon-backend-vlc” throw out precious vlc with the bath water?