meta_package_manager.managers.apt module¶
- class meta_package_manager.managers.apt.APT[source]¶
Bases:
PackageManagerBase class for Debian’s
aptfront-end and its variants.Documentation: apt(8) man page.
Command equivalences with other managers are listed in Pacman/Rosetta.
mpm drives the high-level
aptbinary, notapt-getorapt-cache, over system-wide packages. Mutations escalate throughsudoand force--yesto stay non-interactive.APT_Mintretargets Linux Mint’s same-named but differently-behavedapt.Note
apt’s listing and search commands emit
Listing...,Sorting...andFull Text Search...preambles plus progress indicators.--quietdrops the progress bars, and each parser anchors on thename/suite version archrow shape, so the preamble lines fall through.Note
searchmatches names only by default. An exact query is wrapped as the^query$regex apt supports natively; an extended query switches to--fullto pull descriptions into the output for mpm to post-filter.Initialize
cli_errorslist.- name: str = 'Debian apt'¶
Return package manager’s common name.
Default value is based on class name.
- homepage_url: str | None = 'https://wiki.debian.org/AptCLI'¶
Home page of the project, only used in documentation for reference.
- logo: str | None = 'debian'¶
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 indocs/assets/managers/logos.yaml. Inlined at the top of the manager’s page bymeta_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 (
brewandcask) or because the tool has no mark of its own and its ecosystem’s stands in (aptunder Debian’s swirl,cargounder Rust’s gear). Documentation-only, likehomepage_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
frozensetofPlatforminstances at instantiation.
- default_sudo: bool = True¶
Built-in escalation default, used when
sudoisNone.Falseon 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 toTrueso theirbuild_cli(..., sudo=True)operations escalate out of the box, while staying switchable off throughsudo(--no-sudoor config) for rootless setups.
- requirement: str | None = '>=1.0.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.
- property installed: Iterator[Package]¶
Fetch installed packages.
$ apt --quiet list --installed Listing... adduser/xenial,now 3.113+nmu3ubuntu4 all [installed] bc/xenial,now 1.06.95-9build1 amd64 [installed] bsdmainutils/xenial,now 9.0.6ubuntu3 amd64 [installed,automatic] ca-certificates/xenial,now 20160104ubuntu1 all [installed] cron/xenial,now 3.0pl1-128ubuntu2 amd64 [installed] debconf/xenial,now 1.5.58ubuntu1 all [installed] debianutils/xenial,now 4.7 amd64 [installed] diffutils/xenial,now 1:3.3-3 amd64 [installed] e2fsprogs/xenial,now 1.42.13-1ubuntu1 amd64 [installed] ethstatus/xenial,now 0.4.3ubuntu2 amd64 [installed] file/xenial,now 1:5.25-2ubuntu1 amd64 [installed] findutils/xenial,now 4.6.0+git+20160126-2 amd64 [installed] libidn2-0/jammy,now 2.3.2-2build1 amd64 [installed,automatic] libidn2-0/jammy,now 2.3.2-2build1 i386 [installed,automatic]
- property outdated: Iterator[Package]¶
Fetch outdated packages.
$ apt --quiet list --upgradable Listing... apt/xenial-updates 1.2.19 amd64 [upgradable from: 1.2.15ubuntu0.2] nano/xenial-updates 2.5.3-2ubuntu2 amd64 [upgradable from: 2.5.3-2]
- property orphans: Iterator[Package]¶
Fetch packages installed as dependencies that nothing requires anymore.
--simulateturnsautoremoveinto a read-only report of the would-be-removed packages, printed asRemv <name> [<version>]lines. It needs no root: apt only prints a notice that the run is a simulation.$ apt --quiet autoremove --simulate NOTE: This is only a simulation! apt needs root privileges for real execution. Keep also in mind that locking is deactivated, so don't depend on the relevance to the real current situation! Reading package lists... Building dependency tree... Reading state information... The following packages will be REMOVED: libx11-dev libxcb1-dev 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. Remv libx11-dev [2:1.8.7-1] Remv libxcb1-dev [1.15-1]
- search(query, extended, exact)[source]¶
Fetch matching packages.
$ apt --quiet search abc --names-only Sorting... Full Text Search... abcde/xenial 2.7.1-1 all A Better CD Encoder abcmidi/xenial 20160103-1 amd64 converter from ABC to MIDI format and back berkeley-abc/xenial 1.01+20150706hgc3698e0+dfsg-2 amd64 ABC - A System for Sequential Synthesis and Verification fuse-overlayfs/jammy,now 1.7.1-1 amd64 [installed] implementation of overlay+shiftfs in FUSE for rootless containers grabcd-rip/xenial 0009-1 all rip and encode audio CDs - ripper libakonadi-kabc4/xenial 4:4.14.10-1ubuntu2 amd64 Akonadi address book access library
$ apt --quiet search ^sed$ --names-only Sorting... Full Text Search... sed/xenial 2.1.9-3 all Blah blah blah
$ apt --quiet search abc --full Sorting... Full Text Search... abcde/xenial 2.7.1-1 all This package contains the essential basic system utilities. . Specifically, this package includes: basename cat chgrp chmod chown chroot cksum comm cp csplit cut dircolors dirname du echo env expand expr factor false fmt hostid id install join link ln logname ls md5sum mkdir mkfifo nohup od paste pathchk pinky pr printenv printf ptx pwd sha1sum seq shred sleep sort split stat stty sum sync tac tail tr true tsort tty uname unexpand uniq unlink users vdir wc who (...) midi/xenial 20160103-1 amd64 converter from ABC to MIDI format and back
- install(package_id, version=None)[source]¶
Install one package.
$ sudo apt --quiet --yes install git
- Return type:
- upgrade_all_cli()[source]¶
Generates the CLI to upgrade all outdated packages.
$ sudo apt --quiet --yes upgrade
- upgrade_one_cli(package_id, version=None)[source]¶
Generates the CLI to upgrade the provided package.
$ sudo apt --quiet --yes install --only-upgrade git
- remove_orphan(package_id)[source]¶
Remove one package, then drop dependencies it alone pulled in.
--auto-removeclears the packages that were installed as dependencies and are no longer needed after the removal.$ sudo apt --quiet --yes remove --auto-remove git
- Return type:
- sync()[source]¶
Sync package metadata.
$ sudo apt --quiet --yes update Hit:1 http://archive.ubuntu.com xenial InRelease Get:2 http://archive.ubuntu.com xenial-updates InRelease [102 kB] Get:3 http://archive.ubuntu.com xenial-security InRelease [102 kB] Get:4 http://archive.ubuntu.com xenial/main Translation-en [568 kB] Fetched 6,868 kB in 2s (2,680 kB/s) Reading package lists... Building dependency tree... Reading state information...
- Return type:
- cleanup_orphan()[source]¶
Remove every package installed as a dependency and no longer required.
$ sudo apt --quiet --yes autoremove
- Return type:
- cleanup_cache()[source]¶
Clear out the local repository of retrieved package files.
$ sudo apt --quiet --yes clean
- Return type:
- doctor_cli()[source]¶
Generates the CLI running the native self-diagnosis.
aptitself has no stable check verb, so the diagnosis goes through theapt-getsibling:checkverifies the package cache and dependency integrity, prints the broken state and exits non-zero on problems. Runs unprivileged.$ apt-get --quiet check
- cli_names: tuple[str, ...] = ('apt',)¶
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
pythonorpython3.
By default, this property’s value is derived from the manager’s ID (see the
MetaPackageManager.__init__method above).
- class meta_package_manager.managers.apt.APT_Mint[source]¶
Bases:
APTLinux Mint’s
apt, a wrapper script that shadows Debian’sapt.Mint ships its own
aptcommand reusing the name but not the behavior ofAPT, so only version probing and search parsing are overridden here; every other operation is inherited.Note
Mint’s
apt --versionprints noapt <version>line, so the version is read fromapt version apt: the version of the apt package itself.Caution
Search rows are
<status> <name> - <description>with no version column and no--fullmode, so extended matching is unsupported and results carry no version.Initialize
cli_errorslist.- name: str = 'Linux Mint apt'¶
Return package manager’s common name.
Default value is based on class name.
- homepage_url: str | None = 'https://github.com/kdeldycke/meta-package-manager/issues/52'¶
Home page of the project, only used in documentation for reference.
- logo: str | None = 'linuxmint'¶
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 indocs/assets/managers/logos.yaml. Inlined at the top of the manager’s page bymeta_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 (
brewandcask) or because the tool has no mark of its own and its ecosystem’s stands in (aptunder Debian’s swirl,cargounder Rust’s gear). Documentation-only, likehomepage_url: no CLI output reads it.
- cli_names: tuple[str, ...] = ('apt',)¶
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
pythonorpython3.
By default, this property’s value is derived from the manager’s ID (see the
MetaPackageManager.__init__method above).
- id: str = 'apt-mint'¶
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.
- 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.
- search(query, extended, exact)[source]¶
Fetch matching packages.
Caution
Search does not supports extended matching.
$ /usr/local/bin/apt --quiet search sed v librust-slog-2.5+erased-serde-dev - p python3-blessed - Practical wrapper i sed - GNU stream editor p sed:i386 - GNU stream editor
$ /usr/local/bin/apt --quiet search ^sed$ i sed - GNU stream editor p sed:i386 - GNU stream editor