How to see which packages are installed by user, and which are just dependencies of another?

Or, sort of, find roots of rpm dependency tree?

Note, its not the same as find orphans. Though such a package can indeed be an orphan.

Try the following commands:

zypper packages --recommended

and check the “status” column, packages marked with an “i+” are installed on user request, those marked with an “i” alone are recommended by other packages;

zypper packages --suggested

lists suggested packages, few of which are likely actually installed.

“man zypper” and check description of “search” subcommand (status field).

Alas, neither of above answers the original question.

zypper manages both patterns and packages. There is no through answer to your original question.

The following refers to the after installation snapshot (#2) of Tumbleweed 20210706 with KDE desktop being selected during installation. Some examples are given:

**erlangen:~ #** zypper repos -uEP 
# | Alias                            | Name                            | Enabled | GPG Check | Refresh | Priority | URI 
--+----------------------------------+---------------------------------+---------+-----------+---------+----------+------------------------------------------------------ 
1 | download.opensuse.org-non-oss    | Haupt-Repository (NON-OSS)      | Yes     | (r ) Yes  | Yes     |   99     | http://download.opensuse.org/tumbleweed/repo/non-oss/ 
2 | download.opensuse.org-oss        | Haupt-Repository (OSS)          | Yes     | (r ) Yes  | Yes     |   99     | http://download.opensuse.org/tumbleweed/repo/oss/ 
3 | download.opensuse.org-tumbleweed | Hauptaktualisierungs-Repository | Yes     | (r ) Yes  | Yes     |   99     | http://download.opensuse.org/update/tumbleweed/ 
4 | openSUSE-20210706-0              | openSUSE-20210706-0             | Yes     | (r ) Yes  | Yes     |   99     | http://download.opensuse.org/tumbleweed/repo/oss/ 
**erlangen:~ #**

#2 and #4 refer to the same repository. Hence duplicate entries occur below:

**erlangen:~ #** zypper search --type pattern --installed-only --details  
Loading repository data... 
Reading installed packages... 

S  | Name          | Type    | Version       | Arch   | Repository 
---+---------------+---------+---------------+--------+----------------------- 
i  | apparmor      | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i  | apparmor      | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i+ | base          | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i+ | base          | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i  | documentation | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i  | documentation | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i+ | enhanced_base | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i+ | enhanced_base | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i  | fonts         | pattern | 20170319-5.8  | x86_64 | Haupt-Repository (OSS) 
i  | fonts         | pattern | 20170319-5.8  | x86_64 | openSUSE-20210706-0 
i  | games         | pattern | 20170319-2.8  | x86_64 | Haupt-Repository (OSS) 
i  | games         | pattern | 20170319-2.8  | x86_64 | openSUSE-20210706-0 
i+ | kde           | pattern | 20181130-7.1  | noarch | Haupt-Repository (OSS) 
i+ | kde           | pattern | 20181130-7.1  | noarch | openSUSE-20210706-0 
i  | kde_pim       | pattern | 20181130-7.1  | noarch | Haupt-Repository (OSS) 
i  | kde_pim       | pattern | 20181130-7.1  | noarch | openSUSE-20210706-0 
i  | kde_plasma    | pattern | 20181130-7.1  | noarch | Haupt-Repository (OSS) 
i  | kde_plasma    | pattern | 20181130-7.1  | noarch | openSUSE-20210706-0 
i  | minimal_base  | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i  | minimal_base  | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i  | multimedia    | pattern | 20201106-1.3  | x86_64 | Haupt-Repository (OSS) 
i  | multimedia    | pattern | 20201106-1.3  | x86_64 | openSUSE-20210706-0 
i  | office        | pattern | 20170506-3.8  | x86_64 | Haupt-Repository (OSS) 
i  | office        | pattern | 20170506-3.8  | x86_64 | openSUSE-20210706-0 
i  | sw_management | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i  | sw_management | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i+ | x11           | pattern | 20200505-21.1 | x86_64 | Haupt-Repository (OSS) 
i+ | x11           | pattern | 20200505-21.1 | x86_64 | openSUSE-20210706-0 
i+ | **yast2_basis**   | pattern | 20201210-1.3  | x86_64 | Haupt-Repository (OSS) 
i+ | yast2_basis   | pattern | 20201210-1.3  | x86_64 | openSUSE-20210706-0 
i  | yast2_desktop | pattern | 20201210-1.3  | x86_64 | Haupt-Repository (OSS) 
i  | yast2_desktop | pattern | 20201210-1.3  | x86_64 | openSUSE-20210706-0 
**erlangen:~ #**

Sample information on pattern:

**erlangen:~ #** zypper info --type pattern yast2_basis                               
Loading repository data... 
Reading installed packages... 


Information for pattern yast2_basis: 
------------------------------------ 
Repository      : Haupt-Repository (OSS) 
Name            : yast2_basis 
Version         : 20201210-1.3 
Arch            : x86_64 
Vendor          : openSUSE 
Installed       : Yes 
Visible to User : Yes 
Summary         : YaST Base Utilities 
Description     :  
    YaST tools for basic system administration. 
Contents        :  
    S  | Name                      | Type    | Dependency 
    ---+---------------------------+---------+------------ 
    i  | libyui-ncurses-pkg15      | package | Required 
    i+ | patterns-yast-yast2_basis | package | Required 
    i  | **yast2**                     | package | Required 
    i  | yast2-alternatives        | package | Required 
    i  | yast2-firewall            | package | Required 
    i  | yast2-packager            | package | Required 
    i  | yast2-theme               | package | Required 
    i  | yast2-metapackage-handler | package | Recommended 
    i  | yast2-vm                  | package | Recommended 

**erlangen:~ #**

There are requirements and recommendations for each package being selected:

**erlangen:~ #** zypper info --requires --recommends yast2 
Loading repository data... 
Reading installed packages... 


Information for package yast2: 
------------------------------ 
Repository     : Haupt-Repository (OSS) 
Name           : yast2 
Version        : 4.4.14-1.1 
Arch           : x86_64 
Vendor         : openSUSE 
Installed Size : 2.5 MiB 
Installed      : Yes (automatically) 
Status         : up-to-date 
Source package : yast2-4.4.14-1.1.src 
Summary        : YaST2 Main Package 
Description    :  
    This package contains scripts and data needed for SUSE Linux 
    installation with YaST2 
Requires       : [26] 
    coreutils 
    /bin/bash 
    /usr/bin/perl 
    gpg2 
    cpio 
    rpm 
    augeas-lenses 
    hostname 
    rubygem(ruby:2.7.0:nokogiri) 
    yast2-perl-bindings 
    yast2-hardware-detection 
    rubygem(ruby:2.7.0:cfa) 
    yast2-logs 
    rubygem(ruby:2.7.0:abstract_method) 
    rubygem(ruby:2.7.0:cheetah) 
    rubygem(ruby:2.7.0:simpleidn) 
    yui_backend 
    sysconfig >= 0.80.0 
    yast2-core >= 2.23.0 
    yast2-pkg-bindings >= 4.3.7 
    yast2-ruby-bindings >= 3.2.10 
    yast2-ycp-ui-bindings >= 4.3.3 
    /bin/sh 
    /usr/bin/touch 
    /usr/bin/mkdir 
    fillup 
Recommends     : xdg-utils 

**erlangen:~ #**

Happy browsing with your installation.:wink:

I’m not a native English speaker, but the basic original question is:

How to see which packages are installed by user,

and the basic answer is “Look for an ‘i+’ in the status field of the output of several zypper commands”
and

which are just dependencies of another?

the basic answer is “Look for an ‘i’ in the status field of the output of several zypper commands”.
As examples by @karlmistelberger show, often at the “roots” of the dependency tree we find a “pattern”; then we must consider that a “package” might be recommended or required by several other packages, so that the “dependency tree” is all but simple in most cases.
If you explain what your problem really is maybe we can help with a better sequence to find what you are looking for.

Well there are lines like

i+ | Main Repository (OSS) | irqbalance                                 | 1.8.0-1.2                             | x86_64

and i clearly didn’t install the irqbalance myself. So its not installed by user and is a dependency of some other package.

Thank you Herr Karl!

Is there a sort of root pattern from which all others derived? or is it just installer selects which of them to install, based on the user choices? Like install the kde pattern if user made the choice in the installer.

If it’s the latter, how outdated patterns are handled? Like when, for example, x11 becomes outdated and you want to push wayland on all the users.

And the patterns are only handled by zypper, so dpkg doesn’t know anything about them, right?

Hi
Perhaps zypper se --help may lead to to more info…


zypper se --requires-pkg irqbalance

Then on down the rabbit hole… better to look at the image build?

Yes, and that is exactly the answer to your question in the title of this thread. If you wanted to ask something different, you need to explain your question.

No.

or is it just installer selects which of them to install, based on the user choices?

Yes.

Like when, for example, x11 becomes outdated and you want to push wayland on all the users.

Define “becomes outdated”. Your example makes little sense simply because there is no “wayland” pattern.

Patterns are not mandatory or necessary at all. They are used as shortcut, nothing more.

And the patterns are only handled by zypper, so dpkg doesn’t know anything about them, right?

Patterns are just packages with special names. Zypper knows how to transform “-t pattern” into package name. I do not know how dpkg comes into play here or what exactly are you asking.

Whenever you make a selection in installer involved patterns are labelled as user install:

**erlangen:~ #** zypper se --type pattern enhanced_base 
Loading repository data... 
Reading installed packages... 

S  | Name          | Summary              | Type 
---+---------------+----------------------+-------- 
i+ | enhanced_base | Enhanced Base System | pattern 
**erlangen:~ #**

As pattern enhanced_base recommends package irqbalance the latter gets installed and is labelled too as user install.

**erlangen:~ #** zypper se irqbalance 
Loading repository data... 
Reading installed packages... 

S  | Name          | Summary                                | Type 
---+---------------+----------------------------------------+-------- 
i+ | irqbalance    | Daemon to balance IRQs on SMP machines | package 
i  | irqbalance-ui | UI for IRQ balance Daemon              | package 
**erlangen:~ #**

If we view pattern as simply name for collection of packages - makes sense. I missed this. Thank you.

Ok. So it’s rpm analogues are:


ds@ppk:~> rpm -q --whatrequires irqbalance
irqbalance-ui-1.8.0-1.2.x86_64
ds@ppk:~> rpm -q --whatrecommends irqbalance
patterns-base-enhanced_base-20200505-21.1.x86_64

And when both of the above queries show that nothing requires a package or recommends it, that means that the package is one of the “roots” of the package dependency tree, and was either installed by the user or distribution installer.

Thanks guys!