List all installed packages?

I see

Surely it must keep track of that information somehow though. For example, consider the following 2 scenarios.

Scenario 1. Lets say I install Vim using zypper. Then, later on I install another application that uses Vim as a dependency (GVim for example). If I uninstall GVim, it should leave Vim installed because it was not originally installed as a dependency for GVim.

Scenario 2. Lets say I install GVim using zypper. It should automatically install Vim as a dependency for it. Then, later on when I remove GVim, it should automatically uninstall Vim as well, because it was installed as a dependency for GVim and is no longer needed.

In order for scenario 1 to work at all, zypper has to know what the initial reason for installing Vim was (dependency vs explicit). I’m not in front of my openSUSE installation right now so I can’t test scenario 1, but I’d be a little horrified to find that zypper removes explicitly installed applications just because I removed another explicitly installed application which has it listed as a dependency.

I’ll definitely take a look. I might write my own script if I necessary.

I’ll do that. Thanks!

On 2014-02-27 18:26, kalantir wrote:
>
> wolfi323;2627476 Wrote:
>> But IIUYC, you could have a look at “rpmorphan” (included in the
>> standard repo). That might just do what you want.
>> http://rpmorphan.sourceforge.net/
> I’ll take a look at that, but I’m really not looking for orphans.
> Explicitly installed packages should not ever be treated as orphans
> since the user went out of their way to make sure it was installed.

But you see, when you tell the installer that you want to install, say,
KDE, or Gnome, or XFCE, those desktops were intentionally installed. You
only clicked once, on KDE, for instance, but that in fact selects a few
patterns, and those bring hundreds of packages. All of them
intentionally installed.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

It does not uninstall anything else by default when you uninstall gvim.

There’s the --clean-deps option which would uninstall all unneeded dependencies, but I have no idea how that works. (I never used that myself)

Btw, apparently zypper does remember how a package got installed.
The history file (/var/log/zypp/history) contains lines such as:

2014-02-27 17:56:18|install|kernel-default-devel|3.11.10-7.1|x86_64||repo-update|d329f54734413a14581659752e93dc55f34f6545fed5d459d2acf6f99239ae52|
2014-02-27 17:56:24|install|kernel-xen-devel|3.11.10-7.1|x86_64||repo-update|073cdfa67e7d2e31982e48b20f4c8573c92486e5a07da059089632631556fa97|
2014-02-27 17:56:25|install|kernel-syms|3.11.10-7.1|x86_64|root@amiga|repo-update|fc636271cfc13eaf80e8634c63b7166d487f3bd1de67ad247ccc5bfeac5b1962|

The part marked in red specifies who installed the package. In this case I (root@amiga) called “zypper in kernel-syms”, so the kernel-syms line has “root@amiga”. The other two packages got installed automatically as dependencies, they have an empty field (could also be “pid:app”, i.e. the process-id and application if known).

For --clean-deps apparently only packages without a user name in that sixth field are uninstalled.
I found this information in this bug report:
https://bugzilla.novell.com/show_bug.cgi?id=679213

On 02/27/2014 12:06 PM, kalantir pecked at the keyboard and wrote:
> wolfi323;2627423 Wrote:
>> Well, “unneeded” just means that no other package requires it.
>>
> So I was right. It does not appear to me that this is really the case
> based on the output I posted above though.
>
>> I don’t know exactly what criterias libzypp uses to decide which
>> packages are “unneeded” though.
>> But it looks like it also takes Suggests and Recommends into account and
>> doesn’t consider recommended/suggested packages as “unneeded”.
>>
> Well that’s really unfortunate. Is there any way at all for me to list
> only explicitly installed packages (meaning it wasn’t installed as a
> dependency. It was installed explicitly through the package manager by
> the user)

Short answer, /NO/.
There will need to be some interaction on your part to fond out what was
installed and when. Since the only user that can install any package
is /root/ you will never find out who physically sat at the keyboard
and installed a package explicitly unless you are the only user with
access to the physical machine. Unlike MS Windows ordinary users do not
have the ability to use any form of the package manager. This is where
linux’s core security comes from.
> which are not required by other applications (for
> clarification, it’s important to note that an explicitly installed
> application can still be required by another application that the user
> installed later)?

Again, only the user root can install rpm packages for system wide use.

Ken

Yes, I would very much like for those packages to show up in my query minus the packages which are required as dependencies for other packages. For example, there are definitely KDE packages which are required as dependencies by other KDE packages. What I’m trying to do would filter those ones out and only show me the relevant ones (the ones that aren’t required as dependencies). The ability to do this is what led me to trim down my KDE installation on Arch. I have a relatively small hard drive (less than 100GB) and trimming down KDE alone saves me a significant amount of space.

I sincerely believe that you have completely misunderstood what I’m asking about on every level. In either case I think I have the answers I need now. I’ll either have to write my own script to parse /var/log/zypp/history and/or file a feature request to add this feature (and probably a few others). More likely I’ll just try out Chakra. That’s the other KDE-centric distro I’ve been meaning to give a proper go.

On 2014-02-27 19:26, kalantir wrote:

> Scenario 2. Lets say I install GVim using zypper. It should
> automatically install Vim as a dependency for it. Then, later on when I
> remove GVim, it should automatically uninstall Vim as well, because it
> was installed as a dependency for GVim and is no longer needed.

There is an experimental feature in YaST, named “cleanup when deleting
packages”. It claims to do just that, but it knows noting about
intentionally installed or not. I think it just attempts to remove
whatever the package you click on lists as dependencies, and keeps them
if some other package claims them as dependencies.

It has been there for some releases, but it has been little tested.

Then there is another related feature, “show history”. It parses
“/var/log/history”. In my system it is broken, it stops reading at June
2013.
…]
Ok, I found why. I have to report a bug.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

I’m thinking that the openSUSE package management isn’t really for me. I can appreciate what has been done in terms of KDE-related patches, but I don’t think the package manager was designed with users like me in mind. I will probably recommend it to other people who want a nice KDE experience out of the box though.

On 2014-02-27 20:06, kalantir wrote:
>
> robin_listas;2627490 Wrote:
>>
>> But you see, when you tell the installer that you want to install, say,
>> KDE, or Gnome, or XFCE, those desktops were intentionally installed. You
>> only clicked once, on KDE, for instance, but that in fact selects a few
>> patterns, and those bring hundreds of packages. All of them
>> intentionally installed.
>>
> Yes, I would very much like for those packages to show up in my query
> minus the packages which are required as dependencies for other
> packages. For example, there are definitely KDE packages which are
> required as dependencies by other KDE packages. What I’m trying to do
> would filter those ones out and only show me the relevant ones (the ones
> that aren’t required as dependencies). The ability to do this is what
> led me to trim down my KDE installation on Arch. I have a relatively
> small hard drive (less than 100GB) and trimming down KDE alone saves me
> a significant amount of space.

But the design goal of openSUSE is not small systems. Certainly not if
you install the KDE pattern.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Ken Schneider wrote:
> Since the only user that can install any package
> is /root/ you will never find out who physically sat at the keyboard
> and installed a package explicitly unless you are the only user with
> access to the physical machine.

Creating such a log is what sudo is for, when correctly configured.

On 2014-02-28 12:12, Dave Howorth wrote:
> Ken Schneider wrote:
>> Since the only user that can install any package
>> is /root/ you will never find out who physically sat at the keyboard
>> and installed a package explicitly unless you are the only user with
>> access to the physical machine.
>
> Creating such a log is what sudo is for, when correctly configured.

The history file will just list “root”, I think. You’ll have to
correlate with the sudo logs.

It would have to be tested, to see who is logged on the history file
when using sudo.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Carlos E. R. wrote:
> The history file will just list “root”, I think. You’ll have to
> correlate with the sudo logs.

Exactly.

Thanks. From this I derived the following solution:


grep '|root@'`hostname` /var/log/zypp/history | grep '|install|' | sort -r

It seems that this does not list patterns actively selected. For example, I installed the Haskell pattern through yast today but it is not in the list.


grep '|patterns' /var/log/zypp/history

shows installed patterns but also includes many patterns I did not select myself (presumably, these are dependencies).

Hope this is useful to others.

Hi
Use zypper?


zypper se -i
zypper se -i -t pattern
zypper se -i|grep patterns

If you want version numbers and repos, there are extra options that can be used…

What if

sudo zypper se --installed-only | awk -F\| ' {print $2} '

?

It returns the same structure of software list, compared to your list on pastebin. Is that you wish to achieve?

I suspect that the issue is that " > zypper search --installed-only --details --sort-by-repo" only supplies a complete and sorted list that’s fairly useful but, it doesn’t indicate which packages have been installed for dependency reasons.

Flipping through “rpm” I haven’t found anything that approaches what maybe needed here even though " # rpm --verify --all" (root user) does display some things which should be reviewed for stable system behaviour.

The only thing that occurs to me, is to dump the entire list of installed package names and then, package for package, with a script, inspect the “rpm --query --triggeredby <Package Name>” output.

This bash “one-liner” may help:


 > zypper search --installed-only --type package --sort-by-repo | cut --delimiter\=' ' --fields\=3 | while read line ; do echo "Package: $line"; rpm --query --triggeredby $line; echo ""; done | less

Or redirect to a file or, whatever . . .
The “one-liner” produces output like this (need to search an awful lot!!):


Package: SuSEfirewall2
no package triggers SuSEfirewall2

Package: a2ps
no package triggers a2ps

Package: aaa_base
**aaa_base-13.2+git20140911.61c1681-3.1.x86_64**

Package: aaa_base-extras
no package triggers aaa_base-extras

Package: acl
no package triggers acl

Package: acpica
no package triggers acpica

Package: adjtimex
no package triggers adjtimex

Package: adwaita-icon-theme
no package triggers adwaita-icon-theme



Package: samba-winbind
no package triggers samba-winbind

Package: samba-winbind-32bit
no package triggers samba-winbind-32bit

Package: sane-backends
**hplip-3.14.6-2.2.4.x86_64**

Package: sane-backends-autoconfig
no package triggers sane-backends-autoconfig

Package: sash
no package triggers sash

Package: sbc
no package triggers sbc


grep '|root@'hostname /var/log/zypp/history | grep '|install|' | sort -r

This is quite neat. Gave me a list of all packages that I manually installed. Just wondering if we could enhance this:

  1. Show only those packages that are still installed on the system
  2. Perhaps a neater output? (I manually replaced all | with ; and saved it as a CSV file so that I can have all the package names in one column)

I’m sure #2 is trivial, #1 maybe not. I’m not sure as I have no experience in bash scripting…