meta_package_manager.managers.zypper module

class meta_package_manager.managers.zypper.Zypper[source]

Bases: PackageManager

openSUSE’s package manager.

mpm drives zypper in XML mode (--xmlout) and parses the result with xmltodict: the most stable machine-readable output zypper offers. Every call is pinned with --no-color and --no-abbrev (untruncated columns), --non-interactive for unattended runs, and --no-cd --no-refresh so it never touches removable media or auto-refreshes metadata (mpm refreshes explicitly through sync).

Note

Both installed and search run search --details --type package: --details is the only mode exposing versions, but it returns one row per source package, architecture and past release. mpm drops other-version rows and keeps the highest edition per package name to collapse those duplicates.

Documentation:

Initialize cli_errors list.

name: str = 'openSUSE Zypper'

Return package manager’s common name.

Default value is based on class name.

homepage_url: str | None = 'https://en.opensuse.org/Portal:Zypper'

Home page of the project, only used in documentation for reference.

Slug of the brand mark standing for this manager in the documentation.

Names an SVG vendored under docs/assets/managers/, whose provenance and license are recorded in docs/assets/managers/logos.yaml. Inlined at the top of the manager’s page by meta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.

Several managers legitimately share one slug, either because they wrap the same upstream (brew and cask) or because the tool has no mark of its own and its ecosystem’s stands in (apt under Debian’s swirl, cargo under Rust’s gear). Documentation-only, like homepage_url: no CLI output reads it.

platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='aix', name='IBM AIX'), Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='cygwin', name='Cygwin'), Platform(id='debian', name='Debian'), Platform(id='dragonfly_bsd', name='DragonFly BSD'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='freebsd', name='FreeBSD'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='haiku', name='Haiku'), Platform(id='hurd', name='GNU/Hurd'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='illumos', name='illumos'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='midnightbsd', name='MidnightBSD'), Platform(id='netbsd', name='NetBSD'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='openbsd', name='OpenBSD'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='os400', name='IBM i'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='solaris', name='Solaris'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='sunos', name='SunOS'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})

List of platforms supported by the manager.

Allows for a mishmash of platforms and groups of platforms. Will be normalized into a frozenset of Platform instances at instantiation.

default_sudo: bool = True

Built-in escalation default, used when sudo is None.

False on the base: most managers install into user-writable trees and never need root. The system package managers whose privileged operations require root (apt, dnf, pacman, zypper, …) set this to True so their build_cli(..., sudo=True) operations escalate out of the box, while staying switchable off through sudo (--no-sudo or config) for rootless setups.

requirement: str | None = '>=1.14.0'

Version requirement specifier.

Supports a comma-separated range of constraints (e.g. ">=1.20.0,<2.0.0"). A bare version string like "1.20.0" is treated as >=1.20.0.

Parsed by meta_package_manager.version.VersionRange.

Defaults to None, which deactivates version check entirely.

pre_args: tuple[str, ...] = ('--no-color', '--no-abbrev', '--non-interactive', '--no-cd', '--no-refresh')
version_regexes: tuple[str, ...] = ('zypper\\s+(?P<version>\\S+)',)
$ zypper --version
zypper 1.14.11
property installed: Iterator[Package]

Fetch installed packages.

$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout search --details --type package --installed-only
property outdated: Iterator[Package]

Fetch outdated packages.

$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout list-updates
<?xml version='1.0'?>
<stream>
    <message type="info">Loading repository data...</message>
    <message type="info">Reading installed packages...</message>
    <update-status version="0.6">
        <update-list>
            <update name="git" kind="package" edition="2.34.1-10.9.1"
                    edition-old="2.26.2-3.34.1" arch="x86_64">
                <summary>Fast, scalable revision control system</summary>
                <description>
                    Git is a fast, scalable, distributed revision
                    control system.
                </description>
                <license/>
                <source
                    url="http://download.opensuse.org/updata/leap/15.3/sle"
                    alias="repo-sle-update"/>
            </update>
            <update name="vim" kind="package" edition="9.0.1234-1.1"
                    edition-old="8.2.4956-1.1" arch="x86_64">
                <summary>Vi IMproved text editor</summary>
                <description>
                    Highly configurable text editor.
                </description>
                <license/>
                <source
                    url="http://download.opensuse.org/update/leap/15.3/sle"
                    alias="repo-sle-update"/>
            </update>
        </update-list>
    </update-status>
</stream>
property orphans: Iterator[Package]

Fetch packages installed as dependencies that nothing requires anymore.

$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             packages --unneeded
Loading repository data...
Reading installed packages...
S  | Repository | Name    | Version   | Arch
---+------------+---------+-----------+-------
i  | @System    | libfoo  | 1.2.3-1.1 | x86_64
i+ | openSUSE   | libbar  | 0.9-2.4   | noarch
search(query, extended, exact)[source]

Fetch matching packages.

$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout search --details --type package kopete
$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout search --details --type package --search-description kopete
$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout search --details --type package --match-exact kopete
$ zypper --no-color --no-abbrev --non-interactive --no-cd --no-refresh             --xmlout search --details --type package --search-description             --match-exact kopete
Return type:

Iterator[Package]

install(package_id, version=None)[source]

Install one package.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh install kopete
Return type:

str

upgrade_all_cli()[source]

Generates the CLI to upgrade all outdated packages.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh update
Return type:

tuple[str, ...]

upgrade_one_cli(package_id, version=None)[source]

Generates the CLI to upgrade the provided package.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh update kopete
Return type:

tuple[str, ...]

remove(package_id)[source]

Remove one package.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh remove kopete
Return type:

str

remove_orphan(package_id)[source]

Remove one package, dropping dependencies it alone pulled in.

--clean-deps additionally removes the dependencies that were installed with the package and are no longer needed.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh remove --clean-deps kopete
Return type:

str

cli_names: tuple[str, ...] = ('zypper',)

List of CLI names the package manager is known as.

This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.

..hint::

This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named python or python3.

By default, this property’s value is derived from the manager’s ID (see the MetaPackageManager.__init__ method above).

id: str = 'zypper'

Package manager’s ID.

Derived by defaults from the lower-cased class name in which underscores _ are replaced by dashes -.

This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.

sync()[source]

Sync package metadata.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh refresh
Return type:

None

virtual: bool = False

Should we expose the package manager to the user?

Virtual package manager are just skeleton classes used to factorize code among managers of the same family.

cleanup_cache()[source]

Removes things we don’t need anymore.

$ sudo zypper --no-color --no-abbrev --non-interactive --no-cd             --no-refresh clean
Return type:

None