Cleanup of distribution upgrades

Running “zypper packages --unneeded” on Tumbleweed 20220802-0 revealed no unneeded packages. Upgrading to Tumbleweed 20220804-0 resulted in:

[FONT=monospace]**6700K:~ #** zypper packages --unneeded  
Loading repository data... 
Reading installed packages... 
S | Repository             | Name                          | Version    | Arch 
--+------------------------+-------------------------------+------------+------- 
i | Haupt-Repository (OSS) | policycoreutils-lang          | 3.4-4.1    | noarch 
i | Haupt-Repository (OSS) | python310-aiosmtpd            | 1.4.2-4.3  | noarch 
i | Haupt-Repository (OSS) | python310-alembic             | 1.8.1-1.1  | noarch 
i | Haupt-Repository (OSS) | python310-authheaders         | 0.14.1-1.3 | noarch 
i | Haupt-Repository (OSS) | python310-falcon              | 3.0.1-3.5  | noarch 
i | Haupt-Repository (OSS) | python310-flufl.bounce        | 4.0-2.1    | noarch 
i | Haupt-Repository (OSS) | python310-flufl.i18n          | 4.0-2.1    | noarch 
i | Haupt-Repository (OSS) | python310-flufl.lock          | 7.0-1.6    | noarch 
i | Haupt-Repository (OSS) | python310-gunicorn            | 20.1.0-2.7 | noarch 
i | Haupt-Repository (OSS) | python310-importlib-resources | 5.4.0-1.5  | noarch 
i | Haupt-Repository (OSS) | python310-lazr.config         | 2.2.3-1.5  | noarch 
i | Haupt-Repository (OSS) | python310-passlib             | 1.7.4-4.6  | noarch 
i | Haupt-Repository (OSS) | python310-zope.component      | 5.0.1-1.7  | x86_64 
i | Haupt-Repository (OSS) | python310-zope.configuration  | 4.4.0-1.12 | noarch 
**6700K:~ #**[/FONT]

Removing the above and their dependencies resulted in a clean upgrade:

**6700K:~ #** zypper packages --unneeded | grep ^i|cut -d '|' -f3|xargs zypper rm --clean-deps --no-confirm 
Reading installed packages... 
Resolving package dependencies... 

The following 40 packages are going to be REMOVED:
  libhiredis1_0_0 libmemcached11 memcached policycoreutils-lang python310-Beaker python310-Deprecated python310-Mako python310-PyNaCl python310-SQLAlchemy 
  python310-aiosmtpd python310-alembic python310-atpublic python310-authheaders python310-authres python310-bcrypt python310-dkimpy python310-falcon 
  python310-flufl.bounce python310-flufl.i18n python310-flufl.lock python310-gunicorn python310-hiredis python310-importlib-resources 
  python310-lazr.config python310-lazr.delegates python310-passlib python310-publicsuffix2 python310-pycryptodome python310-pylibmc python310-pymongo 
  python310-python-memcached python310-redis python310-scrypt python310-wrapt python310-zope.component python310-zope.configuration 
  python310-zope.hookable python310-zope.i18nmessageid python310-zope.schema redis 

40 packages to remove. 
After the operation, 52.2 MiB will be freed. 
**Continue? [y/n/v/...? shows all options] (y): **y 
( 1/40) Removing policycoreutils-lang-3.4-4.1.noarch ...............................................................................................[done] 
( 2/40) Removing python310-Beaker-1.11.0-7.3.noarch ................................................................................................[done] 
( 3/40) Removing python310-aiosmtpd-1.4.2-4.3.noarch ...............................................................................................[done] 
( 4/40) Removing python310-alembic-1.8.1-1.1.noarch ................................................................................................[done] 
( 5/40) Removing python310-authheaders-0.14.1-1.3.noarch ...........................................................................................[done] 
( 6/40) Removing python310-bcrypt-3.2.2-1.4.x86_64 .................................................................................................[done] 
( 7/40) Removing python310-falcon-3.0.1-3.5.noarch .................................................................................................[done] 
( 8/40) Removing python310-flufl.bounce-4.0-2.1.noarch .............................................................................................[done] 
( 9/40) Removing python310-flufl.i18n-4.0-2.1.noarch ...............................................................................................[done] 
(10/40) Removing python310-flufl.lock-7.0-1.6.noarch ...............................................................................................[done] 
(11/40) Removing python310-gunicorn-20.1.0-2.7.noarch ..............................................................................................[done] 
(12/40) Removing python310-hiredis-2.0.0-1.3.x86_64 ................................................................................................[done] 
(13/40) Removing python310-importlib-resources-5.4.0-1.5.noarch ....................................................................................[done] 
(14/40) Removing python310-lazr.config-2.2.3-1.5.noarch ............................................................................................[done] 
(15/40) Removing python310-passlib-1.7.4-4.6.noarch ................................................................................................[done] 
(16/40) Removing python310-pycryptodome-3.15.0-1.1.x86_64 ..........................................................................................[done] 
(17/40) Removing python310-pymongo-4.1.1-1.1.x86_64 ................................................................................................[done] 
(18/40) Removing python310-python-memcached-1.59-5.2.noarch ........................................................................................[done] 
(19/40) Removing python310-redis-4.3.3-1.1.noarch ..................................................................................................[done] 
(20/40) Removing python310-scrypt-0.8.20-1.2.x86_64 ................................................................................................[done] 
(21/40) Removing python310-zope.component-5.0.1-1.7.x86_64 .........................................................................................[done] 
(22/40) Removing python310-zope.configuration-4.4.0-1.12.noarch ....................................................................................[done] 
(23/40) Removing python310-pylibmc-1.6.1-3.5.x86_64 ................................................................................................[done] 
(24/40) Removing python310-SQLAlchemy-1.4.39-1.1.x86_64 ............................................................................................[done] 
(25/40) Removing python310-Mako-1.2.1-1.1.noarch ...................................................................................................[done] 
(26/40) Removing python310-publicsuffix2-2.20191221-1.11.noarch ....................................................................................[done] 
(27/40) Removing python310-dkimpy-1.0.5-1.10.noarch ................................................................................................[done] 
(28/40) Removing python310-atpublic-2.3-2.3.noarch .................................................................................................[done] 
(29/40) Removing libhiredis1_0_0-1.0.2-1.5.x86_64 ..................................................................................................[done] 
(30/40) Removing python310-lazr.delegates-2.0.4-1.11.noarch ........................................................................................[done] 
(31/40) Removing memcached-1.6.15-1.2.x86_64 .......................................................................................................[done] 
Failed to stop redis@.service: Unit name redis@.service is missing the instance name.
See system logs and 'systemctl status redis@.service' for details.
Failed to stop redis-sentinel@.service: Unit name redis-sentinel@.service is missing the instance name.
See system logs and 'systemctl status redis-sentinel@.service' for details.
(32/40) Removing redis-7.0.4-1.1.x86_64 ............................................................................................................[done] 
(33/40) Removing python310-Deprecated-1.2.13-1.5.noarch ............................................................................................[done] 
(34/40) Removing python310-zope.hookable-5.1.0-1.6.x86_64 ..........................................................................................[done] 
(35/40) Removing python310-zope.schema-6.1.0-1.6.noarch ............................................................................................[done] 
(36/40) Removing python310-zope.i18nmessageid-5.0.1-3.6.x86_64 .....................................................................................[done] 
(37/40) Removing libmemcached11-1.0.18-9.5.x86_64 ..................................................................................................[done] 
(38/40) Removing python310-authres-1.2.0-1.11.noarch ...............................................................................................[done] 
(39/40) Removing python310-PyNaCl-1.5.0-1.3.x86_64 .................................................................................................[done] 
(40/40) Removing python310-wrapt-1.13.3-1.5.x86_64 .................................................................................................[done] 
  
**6700K:~ #** 

Removing unneeded packages results in more hassle-free maintenance. Host 6700K has some 3700 packages installed and runs “zypper dup” on a daily schedule. No problems were encountered during 3 months of operation.

That is interesting and leads to the question: Why does an upgrade pull in un-needed packages? Are those packages just “recommends”?

I gave it a try on one of my openSUSE Tumbleweed installations which was installed with “no-recommends” right from the start. First I removed all “un-needed” packages and then upgraded to the current snapshot.

After the upgrade there was a new “un-needed” package again!

So why was this package pulled in if it is not needed and should not be installed even if it is “recommended”?

Regards

susejunky

I have no idea what is going on. But it’s inconsistent behavior.

Solver configuration:

**erlangen:~ #** grep ^solver /etc/zypp/zypp.conf  
**solver**.onlyRequires = true 
**solver**.dupAllowDowngrade = true 
**solver**.dupAllowVendorChange = true 
**erlangen:~ #**
**erlangen:~ #** zypper install-new-recommends --dry-run  
Loading repository data... 
Reading installed packages... 
Resolving package dependencies... 
Nothing to do. 
**erlangen:~ #** zypper install-new-recommends --dry-run --recommends  
Loading repository data... 
Reading installed packages... 
Resolving package dependencies... 

The following 141 NEW packages are going to be installed:
  Mesa-demo-egl NetworkManager-bluetooth NetworkManager-tui NetworkManager-wwan PackageKit PackageKit-backend-zypp PackageKit-branding-openSUSE PackageKit-gtk3-module PackageKit-lang WebKit2GTK-4.0-lang aha alsa alsa-oss alsa-plugins alsa-plugins-speexrate alsa-plugins-upmix alsa-ucm-conf alsa-utils bluez-cups discover-backend-packagekit dvdauthor dvgrab fwupd-bash-completion gdk-pixbuf-loader-libheif gimp-plugin-aa gimp-plugins-python gnome-online-accounts gnome-online-accounts-lang gnome-themes-accessibility gnome-themes-accessibility-gtk2 google-noto-coloremoji-fonts gstreamer-libnice gstreamer-plugins-bad gstreamer-plugins-bad-lang gtk2-engine-hcengine gtk4-branding-openSUSE gtk4-metatheme-greybird-geeko hwloc-devel icewm icewm-config-upstream icewm-default icewm-lang kguiaddons libSoundTouch1 libWPEBackend-fdo-1_0-1 libatopology2 libavtp0 libcdt5 libcgraph6 libdbus-glib-1-2-32bit libevent-devel libgdk_pixbuf_xlib-2_0-0 libgoa-backend-1_0-1 libgssdp-1_2-0 libgstadaptivedemux-1_0-0 libgstbadaudio-1_0-0 libgstbasecamerabinsrc-1_0-0 libgstcodecparsers-1_0-0 libgstcodecs-1_0-0 libgstisoff-1_0-0 libgstmpegts-1_0-0 libgstsctp-1_0-0 libgsturidownloader-1_0-0 libgstva-1_0-0 libgstvulkan-1_0-0 libgstwayland-1_0-0 libgstwebrtc-1_0-0 libgupnp-1_2-1 libgupnp-igd-1_0-4 libgvc6 libhiredis1_0_0 libiec61883-0 liblrdf2 libmanette-0_2-0 libnewt0_52 libnice10 libpathplan4 libproxy1-pacrunner-duktape libpython2_7-1_0 libqt5-qtspeech-plugin-speechd librest-0_7-0 libspandsp3 libsrtp2-1 libwebkit2gtk-4_0-37 libwoff2common1_0_2 libwoff2dec1_0_2 libwpe-1_0-1 libyui-qt-graph16 libzbar0 memcached nss-mdns-32bit ntfs-3g nvme-cli-bash-completion openssh-askpass-gnome perl-File-FcntlLock perl-RPM2 phonon4qt5-backend-gstreamer phonon4qt5-backend-gstreamer-lang pipewire-alsa plasma5-pk-updates plasma5-pk-updates-lang pmix-devel pmix-headers power-profiles-daemon python python-base python-gobject2 python-gtk python-xml python2-pycairo python310-Babel python310-Genshi python310-PySocks python310-colorama python310-dbm python310-h2 python310-hpack python310-hyperframe python310-pip python310-pytz python38-Brotli python38-Deprecated python38-hiredis python38-python-memcached python38-redis python38-wrapt qt6-imageformats qt6-platformtheme-gtk3 qt6-printsupport-cups qt6-translations rclone-bash-completion redis sqlite3-devel udiskie-lang webkit2gtk-4_0-injected-bundles xclock xdg-menu xscreensaver xscreensaver-data xscreensaver-lang yast2-sound 

141 new packages to install. 
Overall download size: 52.8 MiB. Already cached: 11.4 MiB. After the operation, additional 212.5 MiB will be used. 
**Continue? [y/n/v/...? shows all options] (y): **

Checking for file conflicts: (113 skipped) .............................................................................................................................................................................................[done] 
Warning: 113 packages had to be excluded from file conflicts check because they are not yet downloaded. 

    Note: Checking for file conflicts requires not installed packages to be downloaded in advance in 
    order to access their file lists. See option '--download-in-advance / --dry-run --download-only' 
    in the zypper manual page for details. 

**erlangen:~ #** 

I’ve not looked at this, but my initial guess would be perhaps it’s related to the setting of (zypp.conf) “solver.focus”

On my system “solver.focus” is not set

> cat /etc/zypp/zypp.conf | grep "solver.focus"
# solver.focus =
>

according to the comments provided

this should be equivalent to “solver.focus = Job”.

However I can’t see why any of these focus-options should cause a package to be installed (by zypper dup) although

  • it is “not needed” and
  • “solver.onlyRequires = true” is set, so that even a (newly) recommended package should not be installed.

What am I missing here? Probably my understanding of “not needed” is not correct?

Regards

susejunky

As I said, it was just an initial guess, I really don’t understand the inner workings of zypper…

However, I also would expect “solver.onlyRequires = true” to take precedence.

A second guess would be the (unneeded) packages are being pulled in by one of the installed “Patterns”

If a genuine bug is suspected then it’s probably best to raise a bug report against zypper.

Ran “zypper remove --clean-deps python38* python39*”. “zypper se -is python|grep ^i+” found several packages I never want to use. Removed them and their dependencies too.

Nor do I !

Ahhh !!! I had not thought of that one.

Although I locked patterns after the installation there are still 8 patterns-* packages installed on my system.

I will have to look into this.

Thank you very much for that hint!

Regards

susejunky

“unneeded” presumably means package is not needed by any user installed package and isn’t a user installed package itself. Found several packages surprisingly flagged as “user installed” but which I don’t need and removed them too.

As you say … “presumably” !

It would be nice to know the exact definition used by zypper.

Regards

susejunky

What is the definition of unneeded packages?

“zypper pa --unneeded (and similar category in YaST) is all packages that are not Required:, Recommended:, or Suggested: by any user-installed packages (those not in /var/lib/zypp/AutoInstalled, also patterns and products) directly or indirectly. If you remove them all dependencies of remaining packages will still be satisfied.”

https://www.reddit.com/r/openSUSE/comments/aeqx6i/what_is_the_definition_of_unneeded_packages/

“The source is at libsolv/src/cleandeps.c at master · openSUSE/libsolv · GitHub if you would like to decipher the detailed logic.”

From libsolv/src/cleandeps.c at master · openSUSE/libsolv · GitHub at line 623 is the following comment:

/*
 * Find all installed packages that are no longer
 * needed regarding the current solver job.
 *
 * The algorithm is:
 * - remove pass: remove all packages that could have
 *   been dragged in by the obsoleted packages.
 *   i.e. if package A is obsolete and contains "Requires: B",
 *   also remove B, as installing A will have pulled in B.
 *   after this pass, we have a set of still installed packages
 *   with broken dependencies.
 * - add back pass:
 *   now add back all packages that the still installed packages
 *   require.
 *
 * The cleandeps packages are the packages removed in the first
 * pass and not added back in the second pass.
 *
 * If we search for unneeded packages (unneeded is true), we
 * simply remove all packages except the userinstalled ones in
 * the first pass.
 */

I’m not sure that clarifies anything, at least with the state of my addled brain at the moment :slight_smile:

Don’t worry, be happy.

Yes, I know! The sources are the only way to find out the real truth.

Regards

susejunky

I don’t, I am :slight_smile:

Haven’t checked on my TW installs, but this Leap 15.3 currently has 42 (arrgh! is that significant?) “unneeded” packages, they’re doing no harm and I just leave them.

I never have fully understood the definition of “unneeded”. I think it’s rather flexible though, dependent upon what action the software is taking, or what the user “expects”.

Based on the issues listed below I presume detection of unneeded packages works correctly. “zypper remove --clean-deps” uses it. “zypper dist-upgrade” has no such option. It performs cleanup of dependencies for each package to be removed, but it performs no global cleanup, thus causing the emergence of unneeded packages after completing the upgrade.

See also: Add UI to manage the auto install flag on packages by bzeller · Pull Request #165 · openSUSE/zypper · GitHub

If you refer to the recent polkit/pkexec split, pkexec was brought in as a split provides. Because pkexec isn’t usually required, it is now unneeded and can be removed in solver view.

A quick check to man zypper clears any confusion:

Called as zypper inr --no-recommends, it restricts the command to just look for packages supporting available hardware, languages or filesystems. Usefull after having added e.g. new hardware or driver repos. This is also the default behavior if you have set [zypp.conf:solver.onlyRequires].

Source: SDB:Zypper manual - openSUSE Wiki

True, but in this case documentation makes for a good stand-in and covers this scenario.

The package in question was python310-importlib-metadata.

Regards

susejunky

I commented here: Command to clean out all unneeded autoinstalled dependencies · Issue #116 · openSUSE/zypper · GitHub

Hmmm …probably I missed something but in all of those places I found no definition of “unneeded”.

Regards

susejunky