How to find the unused packages?

How to find the packages what’s are installed as dependencies while I’m installed an other program.
Example: I’m installed a java game and the package manager installed about 6-7 more programs for dependencies. I don’t like this game, so I’m uninstalled it - but how to remove the other packages what’s are also installed just for this game and doesn’t needed by any other application?
Thanks.

This is not always a strait forward process.

You can do

rpm -qa --last

which will list all packages installed by date. From that info you can probably determine which additional packages were added along with a particular application you installed.

You can also crosscheck with

rpm -qR name_of_application_package

to see which dependencies ‘name_of_application_package’ has.

Okay. Thanks for the suggestion!
So, just to clear out - there is no option to determinate what is “junk”(unused) from your packages.

Not really. Care needs to be exercised when installing additional (potentially useless) application packages so as to avoid package bloat. :slight_smile:

Op Sun, 18 Jan 2009 10:16:01 +0000, schreef ram88:

> Okay. Thanks for the suggestion!
> So, just to clear out - there is no option to determinate what is
> “junk”(unused) from your packages.

I believe this is something worked for the next version for zypper.
Not sure though, maybe it was just a request.


Chris Maaskant

You should have written them down. rotfl!

Uhmm…if you think at sudo apt-get autoremove from Ubuntu, you’re out of luck. Zypper doesn’t have similar feature :frowning:

The dependencies of a package are shown by the Software Package Manager, but unfortunately there’s not a simple GUI way of discovering which packages satisfied the dependencies.

Example, looking at Wesnoth :

libc
libz

libSDL
wesnoth-data-set
wesnoth-data-base
wesnoth-data-full

Unfortunately it won’t let my copy text and paste it.
rpm will tell you the package name that a file belongs in :

rob@fir:~> rpm -qf /usr/lib/libXft.so
xorg-x11-devel-7.2-103.4
rob@fir:~> rpm -qf /usr/lib/libXft.so.2
xorg-x11-libs-7.2-103.4

The ordering appears to be a big clue, without knowing what package bloated the system, it’s hard to know which dependencies are culprits.

There’s probably a way of scripting, to find packages which aren’t required :

rob@fir:~> rpm -q --whatprovides libXft.so.2
xorg-x11-libs-7.2-103.4
rob@fir:~> rpm -q --whatrequires libXft.so.2
v4l-conf-3.95-98
yast2-control-center-qt-2.15.4-12
sax2-tools-8.1-258
pango-1.18.2-4
kpowersave-0.7.3-5
compiz-kde-0.5.4-27
vte-0.16.9-4
grip-3.2.0-171
fvwm2-2.5.23-1.1
xorg-x11-7.2-135.4
kmplayer-0.10.0c-0.pm.2
avahi-qt3-0.6.20-40
kde4-amarok-4.0.svn765209-1.7
koffice-1.6.3-81.1
koffice-illustration-1.6.3-81.1
dbus-1-qt3-0.62-110.1
kvirc-3.2.6-85
libkde4-4.0.4-33.18
libkdegames4-4.0.4-11.49
libkonq4-4.0.4-22.42
kdelibs4-doc-4.0.4-33.18
qt3-3.3.8b-88.2
arts-1.5.10-14.3
kdelibs3-3.5.10-31.1
kdegraphics3-pdf-3.5.10-2.25
kdebase3-runtime-3.5.10-29.1
kdenetwork3-InstantMessenger-3.5.10-15.2
libkcompactdisc4-4.0.4-11.71
libakonadi4-4.1.0-2.1
libkdepimlibs4-4.1.0-2.1
openbox-3.4.7.2-2.3
lxterminal-0.1.3-6.1
ktorrent-2.2.7-0.pm.3
mozilla-xulrunner190-1.9.0.5-3.1
xterm-229-17.2

So looking at the dependencies of the package, rpm -q --whatrequires <dependency> not finding a dependant package, suggests you can remove it safely. rpm -q --requires <package> should give you a list of dependencies to check with --whatrequires.

#!/bin/bash

export LC_ALL=C

for PACKAGE in $(rpm -qa); do
  NEEDED=false
  for PROVIDE in $(rpm -q --provides "$PACKAGE" | awk '{print $1}'); do
    if  $(rpm -q --whatrequires "$PROVIDE" | fgrep -v 'no package requires' | wc -l) -gt 0 ]; then
      NEEDED=true
    fi
  done
  if  "$NEEDED" = false ]; then
    echo "$PACKAGE"
  fi
done

Execute it and the output will make clear why isn’t so simple.
First, there are not just hard dependencies (“requires”), there are also soft deps (“recommends”, “suggests”, “supplements” and “enhances”). But even if you also look at them… no package requires “kdebluetooth4”, does that means that I can remove it? NOOOO!! There are packages that are installed just because the user wants them, not because other packages need them. Start to remove every package that isn’t needed by another one recurrently and you will end removing all the packages.

To implement the “unneeded packages” feature one needs to know why a package was installed. But even this way can fail: suppose there exists a package ‘X’ that needs kdebluetooth4. You install X and so kdebluetooth4 is automatically installed. You want kdebluetooth4 by itself, but since has been automatically installed when you remove ‘X’ kdebluetooth4 will be also removed.

What apt-get/aptitude/etc. do is mark every package like automatically or manually installed. That’s the same that openSUSE will do… but, again, even if it’s better than the script it’s still far from perfect.

Thanks for everyone! Good reason to start experimenting with package management. :wink:

RedDwarf,
You can say whatever you want, your script is still good. :wink:
I wanted to do that but I was busy with different affairs.

Now I think I’ll write some code around this weekend,
I really want to get rid of one or two things…

Well, your example is a little wrong if I did understood well.
You see, kdebluetooth can be user


zypper addlock kdebluetooth

before removing bla…

Another methods like


zypper rm kdebla -kdebluetooth

are useful too. However, there are much better ways to do that.

Now, talking about your “cleaner” script, just adding a


LOCK_PKG=$HOME/.nocleanse

create_locks() {
echo """####################################
# Cleanse locker for user packages #
####################################

##########################################
# Please add here the packages you don't #
# want to be reported by cleaner[TM]     #
##########################################

##########################
# Community suggestions: #
##########################
aria2c
dzen2
mpd
ncmpc
ncmpcpp
rxvt-unicode
slock
""" > $LOCK_PKG
}

noremove() {
    test ! -f $LOCK_PKG && create_locks

    if grep $1 $LOCK_PKG
    then
        return 0
    else
        return 1
    fi
}

nosuggested() {
...
rpm -q --qf "%{SUGGESTSNAME}" $PACKAGE
...
}

noenhances() {
...
rpm -q --qf "%{ENHANCESNAME}" $PACKAGE
...
}


Might help a lot.

All of you,
Ubuntu is too cluttered, please stop comparing openSUSE with that.
If I am using O.S., it’s because of in depth customizations are
possible. You can get rid of most things: e.g. sysinit, without
breaking original or intended functionality in another components.

That is just impossible given Ubuntu’s actual state …]

enhanced user laziness + customizability = genius!!.
That’s all about openSUSE.

I know many of you don’t know well another distros but
those Source Mage Linux (SML) and Gentoo alike, are
years light ahead in this matter.

Try to raise your mental bars :sarcastic: :smiley:

I think that os_cleanse is really possible (given certain limits) and easier than we think.

Lets show some code!