zypper command to list packages installed from a repo

I use six added openSUSE repos in 15.3, These are science, education, electronics, games, graphics, and application/geo. I have installed many packages from them (probably about 100). I want to avoid reloading all of these packages after the upgrade but I am not confident that the online upgrade process will be handled properly for these “extra” repos. Amongst other things, the formatting scheme of the URL names for the repos is different between 15.3 and 15.4 repos making releasever scheme not workable.

I wish to make a backup list of what packages I have currently installed from each of the repos I have selected from: https://download.opensuse.org/repositories/

I need someone more proficient with zypper than me to layout a cli command to list packages installed from a selected repo. I can make six lists. I can keep those lists and use them for reinstall if needed.

thanks, tom kosvic

zypper pa -ir <repo_name_or_number>

or

zypper search -i -r <repo alias|#|URI>

I searched the “education” repo with commands provided. !st command gave extensive list. See code below:

(base) tom@mydesktop:~> sudo zypper pa -ir https://download.opensuse.org/repositories
/Education/openSUSE_Leap_15.3/
Loading repository data...
Reading installed packages...
S | Repository             | Name                     | Version             | Arch
--+------------------------+--------------------------+---------------------+-------
v | leap 15.3 -- education | blas-devel               | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | blas-devel-static        | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | cblas-devel              | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | fftw3-devel              | 3.3.10-lp153.5.1    | x86_64
v | leap 15.3 -- education | fftw3-threads-devel      | 3.3.10-lp153.5.1    | x86_64
v | leap 15.3 -- education | javapackages-filesystem  | 5.3.1-lp153.131.1   | x86_64
v | leap 15.3 -- education | javapackages-tools       | 5.3.1-lp153.131.1   | x86_64
v | leap 15.3 -- education | lapack-devel             | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | libamd2                  | 2.4.6-lp153.93.1    | x86_64
v | leap 15.3 -- education | libblas3                 | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | libbox2d2                | 2.4.1-lp153.16.1    | x86_64
v | leap 15.3 -- education | libbtf1                  | 1.2.6-lp153.93.1    | x86_64
v | leap 15.3 -- education | libcamd2                 | 2.4.6-lp153.93.1    | x86_64
v | leap 15.3 -- education | libcblas3                | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | libccolamd2              | 2.9.6-lp153.93.1    | x86_64
v | leap 15.3 -- education | libcholmod3              | 3.0.14-lp153.93.1   | x86_64
v | leap 15.3 -- education | libcolamd2               | 2.9.6-lp153.93.1    | x86_64
v | leap 15.3 -- education | libColPack0              | 1.0.10-lp153.20.1   | x86_64
v | leap 15.3 -- education | libcxsparse3             | 3.2.0-lp153.93.1    | x86_64
v | leap 15.3 -- education | libenca0                 | 1.19-lp153.41.1     | x86_64
v | leap 15.3 -- education | libfftw3-3               | 3.3.10-lp153.5.1    | x86_64
v | leap 15.3 -- education | libfftw3_threads3        | 3.3.10-lp153.5.1    | x86_64
v | leap 15.3 -- education | libinotifytools0         | 3.14-lp153.4.1      | x86_64
v | leap 15.3 -- education | libklu1                  | 1.3.9-lp153.93.1    | x86_64
v | leap 15.3 -- education | liblapack3               | 3.9.0-lp153.42.1    | x86_64
v | leap 15.3 -- education | libportmidi0             | 217-lp153.2.1       | x86_64
i | leap 15.3 -- education | libspqr2                 | 2.1.0-lp153.93.1    | x86_64
v | leap 15.3 -- education | libsuitesparseconfig5    | 5.12.0-lp153.93.1   | x86_64
v | leap 15.3 -- education | libtar1                  | 1.2.20-lp153.9.1    | x86_64
v | leap 15.3 -- education | libtbbmalloc2            | 2021.5.0-lp153.87.1 | x86_64
v | leap 15.3 -- education | libumfpack5              | 5.7.9-lp153.93.1    | x86_64
v | leap 15.3 -- education | oce                      | 0.18.3-lp153.34.1   | x86_64
v | leap 15.3 -- education | oce-devel                | 0.18.3-lp153.34.1   | x86_64
v | leap 15.3 -- education | opencl-headers           | 1.2-lp153.2.1       | noarch
v | leap 15.3 -- education | python2-service_identity | 21.1.0-lp153.29.1   | noarch
v | leap 15.3 -- education | python3-PyAudio          | 0.2.11-lp153.11.1   | x86_64
v | leap 15.3 -- education | python3-service_identity | 21.1.0-lp153.29.1   | noarch
v | leap 15.3 -- education | R-base                   | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-base-devel             | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-boot                   | 1.3.28-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-class                  | 7.3.20-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-cluster                | 2.1.3-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-codetools              | 0.2.18-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-compiler               | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-core                   | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-core-devel             | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-core-doc               | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-core-libs              | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-core-packages          | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-datasets               | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-foreign                | 0.8.82-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-graphics               | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-grDevices              | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-grid                   | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-KernSmooth             | 2.23.30-lp153.47.1  | x86_64
v | leap 15.3 -- education | R-lattice                | 0.20.45-lp153.47.1  | x86_64
v | leap 15.3 -- education | R-MASS                   | 7.3.56-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-Matrix                 | 1.4.1-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-methods                | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-mgcv                   | 1.8.40-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-nlme                   | 3.1.157-lp153.47.1  | x86_64
v | leap 15.3 -- education | R-nnet                   | 7.3.17-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-parallel               | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-recommended-packages   | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-rpart                  | 4.1.16-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-spatial                | 7.3.15-lp153.47.1   | x86_64
v | leap 15.3 -- education | R-splines                | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-stats                  | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-stats4                 | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-survival               | 3.3.1-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-tcltk                  | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-tools                  | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | R-utils                  | 4.2.0-lp153.47.1    | x86_64
v | leap 15.3 -- education | timidity                 | 2.15.0-lp153.4.1    | x86_64
v | leap 15.3 -- education | xplanet                  | 1.3.1-lp153.38.1    | x86_64


2nd co9mmand searching same repo only gave 1 response. See below:

(base) tom@mydesktop:~> sudo zypper search -i -r https://download.opensuse.org/reposi
tories/Education/openSUSE_Leap_15.3/
Loading repository data...
Reading installed packages...

S | Name     | Summary                | Type
--+----------+------------------------+--------
i | libspqr2 | Multifrontal Sparse QR | package
(base) tom@mydesktop:~> 

Perhaps all the above packages are included in the Multifrontal Sparse QR package

I think the 1st command gives me what I need to reinstall back to what I had installed.

thanks, tom kosvic

According to man zypper:

In the Status column the search command distinguishes between user installed packages (i+) and automatically installed packages (i).

The v status is only shown if the version or the repository matters (see --details or --repo), and the installed instance differs from the one listed in version or repository.

Apparently zypper search -ir will only list packages installed by the user or the system (e.g., a needed dependency or part of a installation pattern), while [FONT=monospace]zypper pa -ir will list all installed packages listed in the repo, even if they came from another repo (v flag). Here I have, for the KDE:Extra repo (#2 in my repo list):

[/FONT]

[FONT=monospace][FONT=monospace]**#** LANG=C zypper pa -ir 2 
Loading repository data... 
Reading installed packages... 
S  | Repository | Name                                 | Version                                    | Arch 
---+------------+--------------------------------------+--------------------------------------------+------- 
v  | KDE:Extra  | calligra-extras-filemanagertemplates | 3.2.1-lp153.202.1                          | x86_64 
v  | KDE:Extra  | kcm_tablet                           | 3.2.0-lp153.28.3                           | x86_64 
v  | KDE:Extra  | kcm_tablet-lang                      | 3.2.0-lp153.28.3                           | noarch 
i+ | KDE:Extra  | knemo                                | 0.7.7git.20191016T164055~e5a3984-lp153.4.5 | x86_64 
i+ | KDE:Extra  | knemo-lang                           | 0.7.7git.20191016T164055~e5a3984-lp153.4.5 | noarch 
v  | KDE:Extra  | kpeoplevcard                         | 0.1-lp153.6.4                              | x86_64 
v  | KDE:Extra  | krename                              | 5.0.1-lp153.42.4                           | x86_64 
v  | KDE:Extra  | kuserfeedback-imports                | 1.2.0-lp153.6.1                            | x86_64 
v  | KDE:Extra  | kuserfeedback-lang                   | 1.2.0-lp153.6.1                            | noarch 
v  | KDE:Extra  | libepub0                             | 0.2.2-lp153.15.5                           | x86_64 
v  | KDE:Extra  | libkasten-lang                       | 0.26.9-lp153.11.1                          | noarch 
v  | KDE:Extra  | libKasten4                           | 0.26.9-lp153.11.1                          | x86_64 
v  | KDE:Extra  | libKF5MediaWiki5                     | 5.37.0-lp153.11.3                          | x86_64 
v  | KDE:Extra  | libKF5PulseAudioQt2                  | 1.2-lp153.11.2                             | x86_64 
v  | KDE:Extra  | libKUserFeedbackCore1                | 1.2.0-lp153.6.1                            | x86_64 
v  | KDE:Extra  | libKUserFeedbackWidgets1             | 1.2.0-lp153.6.1                            | x86_64 
v  | KDE:Extra  | libokteta-lang                       | 0.26.9-lp153.11.1                          | noarch 
v  | KDE:Extra  | libOkteta3                           | 0.26.9-lp153.11.1                          | x86_64 
v  | KDE:Extra  | okteta                               | 0.26.9-lp153.11.1                          | x86_64 
v  | KDE:Extra  | okteta-data                          | 0.26.9-lp153.11.1                          | noarch 
v  | KDE:Extra  | okteta-lang                          | 0.26.9-lp153.11.1                          | noarch 
i+ | KDE:Extra  | tellico                              | 3.4.4-lp153.85.2                           | x86_64 
i+ | KDE:Extra  | tellico-lang                         | 3.4.4-lp153.85.2                           | noarch 
**#** LANG=C zypper search -ir 2 
Loading repository data... 
Reading installed packages... 

S  | Name         | Summary                          | Type 
---+--------------+----------------------------------+-------- 
i+ | knemo        | The KDE Network Monitor          | package 
i+ | knemo-lang   | Translations for package knemo   | package 
i+ | tellico      | A Collection Manager             | package 
i+ | tellico-lang | Translations for package tellico | package 
**#**
[/FONT][/FONT]

[FONT=monospace]

[/FONT][FONT=monospace]So, for instance, okteta was installed form the main update repo, hence the v flag. knemo and tellico were explicitly installed by me, hence the i+ flag.

[/FONT]

zypper search --installed-only -s -t package -t pattern

When I try that with | wc -l appended, I get 2098 (only 6 of which are patterns). rpm -qa | wc -l only produces 1988. Minus the 5 “overhead” lines in zypper output, that’s 105 packages more found by zypper. Can anyone suggest why such a big difference? :\

No. If you post these lists, someone may look at them and explain the difference.

On my system (openSUSE Tumbleweed 20220626) there is no difference (except the “zypper overhead”):

# zypper search --installed-only -s -t package -t pattern |wc -l
2845
# rpm -qa | wc -l
2840
#

I guess without knowing your lists it is impossible to tell where the difference comes from.

Regards

susejunky

On my system the above commands give:

(base) tom@mydesktop:~> sudo zypper search --installed-only -s -t package -t pattern 
|wc -l
[sudo] password for root:  
7225
(base) tom@mydesktop:~> rpm -qa | wc -l
6538
(base) tom@mydesktop:~>

The difference is about 700 files. That’s a lot more than overhead.

tom kosvic

Well, counting the lines in the results of the two commands is the first (not very meaningful) step to compare the two results.

If there is any difference the next step definitely must be to compare the two outputs line by line what by the way is actually the only really meaningful compare.

However without looking at the two actual outputs it is impossible to analyze that any further.

Regards

susejunky

I did the following on my system:


rpm -qa --qf "%{NAME}
" | tr -s -d ' ' '
' | sort > rpm.out

sudo zypper se --installed-only -s -t package -t pattern | grep '^i' | cut -d '|' -f 2 | tr -s -d ' ' '
' | sort > zypper.out

diff --suppress-common-lines -y rpm.out zypper.out
                                  >    apparmor
                                  >    base
                                  >    basic_desktop
                                  >    documentation
                                  >    enhanced_base
                                  >    fonts
                                  >    games
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
                                  >    imaging
                                  >    laptop
                                  >    mate
                                  >    minimal_base
                                  >    multimedia
                                  >    office
                                  >    sw_management
                                  >    x11
                                  >    x11_yast
                                  >    yast2_basis
                                  >    yast2_desktop

sudo zypper se --installed-only -s -t package | grep '^i' | cut -d '|' -f 2 | tr -s -d ' ' '
' | sort > zypper.out  # Don't list installed patterns, only packages.

diff --suppress-common-lines -y rpm.out zypper.out
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <
gpg-pubkey                              <

It turned out that zypper didn’t return the gpg-pubkeys, but rpm did. And rpm didn’t return the patterns, but zypper did if you asked for them.

Gene_S

Hmmm, I just tried

# rpm -qa | grep ^patterns
patterns-base-minimal_base-20190612-15.1.x86_64
patterns-kde-kde-20181130-3.2.noarch
patterns-base-x11-20190612-15.1.x86_64
patterns-yast-x11_yast-20190411-1.4.x86_64
patterns-yast-yast2_basis-20190411-1.4.x86_64
patterns-base-enhanced_base-20190612-15.1.x86_64
patterns-base-base-20190612-15.1.x86_64
patterns-kde-kde_plasma-20181130-3.2.noarch
#

Regards

susejunky

While by convention packages that define patters are named with patterns- prefix, this is not mandatory. Patterns (including pattern names themselves) are defined by specific package properties, not by package names. So it is entirely possible to have patterns not following these conventions. Also I am not sure that pattern dependencies map one-to-one into RPM dependencies, so it is still better to install patterns as patterns, not their “container” packages.

And in the past patterns were defined in separate repository metadata, not using packages. Such patterns will not be listed by rpm. It is still possible to have repository with this “old style” information.

Ahhh,… again something i did not know. Thank you for this information.

So it is (more or less) “pure luck” that on my system

# zypper se -i -t pattern
Loading repository data...
Reading installed packages...

S  | Name          | Summary                               | Type
---+---------------+---------------------------------------+--------
i+ | base          | Base System                           | pattern
i+ | enhanced_base | Enhanced Base System                  | pattern
i+ | kde           | KDE Applications and Plasma 5 Desktop | pattern
i  | kde_plasma    | KDE Plasma 5 Desktop Base             | pattern
i  | minimal_base  | Minimal Appliance Base                | pattern
i+ | x11           | X Window System                       | pattern
i+ | x11_yast      | YaST User Interfaces                  | pattern
i+ | yast2_basis   | YaST Base Utilities                   | pattern
#

renders the same result as

# rpm -qa | grep ^pattern
patterns-base-minimal_base-20190612-15.1.x86_64
patterns-kde-kde-20181130-3.2.noarch
patterns-base-x11-20190612-15.1.x86_64
patterns-yast-x11_yast-20190411-1.4.x86_64
patterns-yast-yast2_basis-20190411-1.4.x86_64
patterns-base-enhanced_base-20190612-15.1.x86_64
patterns-base-base-20190612-15.1.x86_64
patterns-kde-kde_plasma-20181130-3.2.noarch
#

Good to know!

Thank you.

Regards

susejunky