zypper: Which packages were installed, and why.

(Please note that this is not a question about libreoffice and ibus, those packages are just examples. I want to understand how zypper works.)

$ zypper install libreoffice
yields
Loading repository data…
…]
The following 41 NEW packages are going to be installed:
firebird ibus ibus-gtk …]

After the installation, how can I see that ibus was installed because of that?
(I hoped that $ zypper info --requires libreoffice would then list ibus, but it doesn’t (at least not verbatim).)

Also, after
$ zypper remove ibus
everything still seems to be fine:
$ zypper verify
…] Dependencies of all installed packages are satisfied.
$ zypper install libreoffice
…] Nothing to do.

If libreoffice doesn’t need ibus, why was it installed during the initial installation?
Also, If I want to reinstall all packackes that came with the initial installation and were removed in the meantime, how can I do that?
(I tried $ zypper info --suggests libreoffice and $ zypper info --recommends libreoffice but there is no hint towards ibus that i can see.)

You need to check all 41 new packages for suggested and recommended packages. “zypper verify” checks for hard dependencies only.

If the initial installation of libreoffice was long ago, how can I see what the 41 new packages are?

Try

zypper info --supplements ibus
$ zypper remove ibuseverything still seems to be fine:
$ zypper verify
...] Dependencies of all installed packages are satisfied.
$ zypper install libreoffice
...] Nothing to do.

Try

zypper inr

Also, If I want to reinstall all packackes that came with the initial installation and were removed in the meantime, how can I do that?

If “initial installation” means “the first installation of some package” - “zypper inr package” should do it.

EDIT
Sorry, I always forget that install-new-recommends does not really take any package name. It is global. So no, there is no easy way to reinstall non-required packages for one package only - it is all or nothing,

You may try:

erlangen:~ # zypper rm --dry-run --clean-deps libreoffice
Reading installed packages...
Resolving package dependencies...

The following 80 packages are going to be REMOVED:
  apache-commons-logging firebird flute google-carlito-fonts java-15-openjdk-headless javapackages-filesystem javapackages-tools libabw-0_1-1 libbase libboost_locale1_71_0
  libcdr-0_1-1 libclucene-contribs-lib1 libclucene-core1 libclucene-shared1 libcmis-0_5-5 libe-book-0_1-1 libeot0 libepubgen-0_1-1 libetonyek-0_1-1 libexttextcat
  libexttextcat-2_0-0 libfbclient2 libfonts libformula libfreehand-0_1-1 libib_util libixion-0_15-0 liblangtag1 liblayout libloader liblpsolve55-0 libmspub-0_1-1 libmwaw-0_3-3
  libmythes-1_2-0 libnumbertext-1_0-0 libnumbertext-data libodfgen-0_1-1 liborcus-0_15-0 libpagemaker-0_0-0 libqrcodegencpp1 libqxp-0_0-0 librasqal3 librdf0 libreoffice
  libreoffice-base libreoffice-base-drivers-firebird libreoffice-branding-openSUSE libreoffice-calc libreoffice-draw libreoffice-filters-optional libreoffice-impress
  libreoffice-l10n-de libreoffice-l10n-en libreoffice-mailmerge libreoffice-math libreoffice-pyuno libreoffice-qt5 libreoffice-writer librepository librevenge-0_0-0
  librevenge-stream-0_0-0 libserializer libstaroffice-0_0-0 libvisio-0_1-1 libwpd-0_10-10 libwpg-0_3-3 libwps-0_4-4 libxmlsec1-nss1 libzmf-0_0-0 myspell-de myspell-de_DE
  myspell-dictionaries myspell-en myspell-en_US myspell-lightproof-en pentaho-libxml pentaho-reporting-flow-engine sac timezone-java xml-commons-apis

80 packages to remove.
After the operation, 662.8 MiB will be freed.
Continue? [y/n/v/...? shows all options] (y): 
erlangen:~ # 

In a very strict interpretation of these questions, you’ll find answers in /var/log/zypp/history, because the state of package repository was likely to be different than the state of today. Package’s dependencies change all the time. That said, you’ll find that a package will be installed because:

  1. it was explicitly requested;
  2. provides a required dependency of (1)
  3. provides a recommended dependency of (1)
  4. supplements a dependency of (1)
  5. it’s in turn a direct dependency of either (2)(3)(4)
  6. and so on and so forth…
  7. as long as the package doesn’t pose a conflict for the solver

(I don’t claim this is an extensive description, but should be close enough)

It might not be possible to replicate the initial installation today, because of (7), nor automatically, because dependencies are added/removed over time.

Understanding Zypp and Zypper involves realising that, they’re a front end for the Red Hat Package Manager – RPM.
[ul]
[li]Not all the RPM options are visible in Zypper … [/li][li]RPM has a Package Dependencies feature which , is heavily used by most RPM based distributions, including openSUSE … [/li][li]To understand a packages dependencies, you have to delve into the following RPM select options:[/li][LIST]
[li]–whatprovides [/li][li]–whatrequires [/li][li]–whatrecommends [/li][li]–whatsuggests [/li][li]–whatsupplements [/li][li]–whatenhances [/li][/ul]

[li]There are also the following RPM query dependencies:[/li][ul]
[li]–conflicts [/li][li]–enhances [/li][li]–obsoletes [/li][li]–provides [/li][li]–recommends [/li][li]–requires [/li][li]–suggests [/li][li]–supplements [/li][/ul]

[/LIST]

Do you mean the original package versions or, some packages which were “accidentality” removed or, those packages which have been removed due to the security repair patches and updates made during the life of of the distribution version?
[HR][/HR]Despite your question, my answer is, look into the YaST Software Manager: <https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/part-reference-software.html&gt;
[ul]
[li]Section: “Installing or Removing Software”. [/li][li]Subsection: “Using the YaST Software Manager” – “Views for Searching Packages or Patterns”: <https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/cha-yast-software.html#sec-yast-software-search&gt;. [/li][/ul]
What you need is, the view “Patterns” – for each group of packages, you’ll find there are special packages with “patterns” in the name – forcibly re-install the “Patterns” packages and then, all the dependent packages, each with their dependencies, within each Pattern will be reinstalled – either using the newest versions available in the Update Repositories or, using the “original” version if there weren’t any patches or updates since the distribution’s beginning (of life) …

Thank you for the explanation.
Also thanks to arvidjaar, karlmistelberger and awerlang for the hints to zypper info --supplements ibus, zypper inr , zypper rm --dry-run --clean-deps libreoffice and /var/log/zypp/history.
With the combination of all this I can achieve what I wanted.

This.
(I want to keep my system clean and be able to remove unused packages but I don’t want any packages that I actually or eventually use to be non-optimal. I guess, zypper inr is perfect for that.)

Thanks for the feedback. Getting fluent with zypper pays off, minimizing your procedures too, e.g. https://forums.opensuse.org/showthread.php/540544-Open-Broadcaster-Software-(OBS)-format-not-support?p=2938892#post2938892