meta_package_manager.managers.aptitude module¶
- meta_package_manager.managers.aptitude.NO_VERSION = '<none>'¶
Placeholder
%vand%Vrender for a version that does not exist.An uninstalled package has no current version, and a virtual one has no candidate. Both print this literal rather than an empty field, so it has to be mapped back to
Noneinstead of reaching a package record as a version string.
- meta_package_manager.managers.aptitude.escape_pattern(query)[source]¶
Render
queryas a regex matching itself and nothing else.Two layers read the string, and each needs a different treatment:
aptitude’s pattern parser splits a term at whitespace, so a two-word query becomes an implicit
ANDof two terms and matches nothing. A backslash cannot rescue it (the split happens first, leaving a trailing backslash the regex compiler rejects), so whitespace is rewritten as the[[:space:]]class, which carries no space to split on.the regex compiler underneath, whose metacharacters are backslashed.
Quoting the term instead (
~n"...") also survives whitespace, but the quote parser eats backslashes before the regex ever sees them, so the two mechanisms cannot be combined:~n"^s\.d$"still matchessed.- Return type:
- class meta_package_manager.managers.aptitude.Aptitude[source]¶
Bases:
PackageManagerFront-end to Debian’s
apt, with a resolver and a query language of its own.Aptitude reaches the same archives
aptdoes, over the same dpkg backend, and is wrapped on the same grounds asNala: a distinct tool with a vocabulary of its own, rather than a translation layer over another CLI. It shares dpkg’s lock with the rest of that family, so mpm runs it serially against them.Note
Every listing is a
searchover aptitude’s own pattern language (~ifor installed,~Ufor upgradable,~i~gfor installed garbage) rendered through an explicit--display-format. That projection is what makes the output a flatpackage,versiontable instead of the padded columns the interactive interface draws.Caution
A query reaches aptitude as a regular expression, not as a literal substring, so it is escaped by
escape_pattern()before being spliced into a~nor~dterm. Skipping that step is not a near-miss but a silent empty result:~n^libsigc++-2.0-0v5$compiles to a regex matching no package at all.Note
--disable-columnsis redundant on a pipe, aptitude having disabled columns on a redirection since0.7.5, and is passed anyway: that heuristic is a moving target (a later release narrowed it again for a caller setting a width explicitly), and the flag is what the manual’s own example uses to ask for unformatted output.Documentation: aptitude(8) man page.
Initialize
cli_errorslist.- homepage_url: str | None = 'https://salsa.debian.org/apt-team/aptitude'¶
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='crux', name='CRUX'), 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='nutyx', name='NuTyX'), 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='solus', name='Solus'), 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¶
Aptitude reports
are you root?and exits rather than escalating on its own, so mpm supplies the privilege for the operations that mutate.
- requirement: str | None = '>=0.4.11.4'¶
The release adding
--disable-columns, announced in aptitude’s ownNEWSas a newsearchoption. Every other option and pattern this class passes predates it, and every currently shipped distribution is far above it.
- pre_args: tuple[str, ...] = ('--quiet', '--disable-columns')¶
--quietdrops the incremental progress indicators aptitude draws on a terminal;--disable-columnsasks for unpadded, untruncated output.Source: aptitude(8) options.
- version_regexes: tuple[str, ...] = ('aptitude\\s+(?P<version>\\S+)',)¶
$ aptitude --version aptitude 0.8.13 Compiler: g++ 14.2.0 Compiled against: apt version 7.0.0 NCurses version 6.5 libsigc++ version: 2.12.1 Gtk+ support disabled. Qt support disabled. Current library versions: NCurses version: ncurses 6.5.20250216 cwidget version: 0.5.18 Apt version: 7.0.0
- property installed: Iterator[Package]¶
Fetch installed packages.
$ aptitude --quiet --disable-columns search ~i --display-format %p,%v adduser,3.152 apparmor,4.1.0-1 apt,3.0.3 apt-utils,3.0.3 aptitude,0.8.13-7 aptitude-common,0.8.13-7 base-files,13.8+deb13u6 base-passwd,3.6.7 bash,5.2.37-2+b9 bash-completion,1:2.16.0-7 bsdutils,1:2.41-5 busybox,1:1.37.0-6+b8 bzip2,1.0.8-6 ca-certificates,20250419
- property outdated: Iterator[Package]¶
Fetch outdated packages.
~Umatches an installed package having a newer candidate, so%vand%Vare both populated and always differ.$ aptitude --quiet --disable-columns search ~U --display-format %p,%v,%V bsdutils,1:2.41-5,1:2.41.5-0+deb13u1 eject,2.41-5,2.41.5-0+deb13u1 fdisk,2.41-5,2.41.5-0+deb13u1 libblkid1,2.41-5,2.41.5-0+deb13u1 libexpat1,2.7.1-2,2.8.3-1~deb13u1 libfdisk1,2.41-5,2.41.5-0+deb13u1 liblastlog2-2,2.41-5,2.41.5-0+deb13u1 libmount1,2.41-5,2.41.5-0+deb13u1 libpython3.13-minimal,3.13.5-2+deb13u3,3.13.5-2+deb13u4 libpython3.13-stdlib,3.13.5-2+deb13u3,3.13.5-2+deb13u4
- property orphans: Iterator[Package]¶
Fetch packages installed as dependencies that nothing requires anymore.
~gmatches aptitude’s garbage set, which also covers packages that are not installed at all, so it is intersected with~i. The result is the setapt autoremovewould remove.$ aptitude --quiet --disable-columns search ~i~g --display-format %p,%v nyancat,1.5.2-0.3+b1
- search(query, extended, exact)[source]¶
Fetch matching packages.
~nmatches the name and~dthe description, so an extended search is the union of the two and a plain one is the name term alone. An exact query anchors that term at both ends.A package with no candidate version renders
%Vas<none>: virtual packages match a name search and carry neither a version nor a description.$ aptitude --quiet --disable-columns search ~nabc --display-format %p,%V,%d abcde,2.9.3-1,A Better CD Encoder abcl,1.9.2-2,Common Lisp implementation in the Java Virtual Machine abcm2ps,8.14.17-2,Translates ABC music description files to PostScript abcmidi,20250216+ds-1,converter from ABC to MIDI format and back grabc,1.1+git20210125.b9e4316-2+b1,simple program to determine the color string in hex by clicking on a pixel libghc-directory-tree-dev-0.12.1-9dabc,<none>, libghc-directory-tree-prof-0.12.1-9dabc,<none>, node-lodash.kebabcase,<none>, node-types-lodash.kebabcase,<none>, python3-sabctools,8.2.3-2+b4,C implementations of functions for use within SABnzbd
$ aptitude --quiet --disable-columns search ~n^sed$ --display-format %p,%V,%d sed,4.9-2+deb13u1,GNU stream editor for filtering/transforming text
$ aptitude --quiet --disable-columns search ~nnyancat|~dnyancat --display-format %p,%V,%d nyancat,1.5.2-0.3+b1,Animated terminal Nyancat nyancat-server,1.5.2-0.3,Animated terminal Nyancat server configurations
$ aptitude --quiet --disable-columns search ~n^libsigc\+\+-2\.0-0v5$ --display-format %p,%V,%d libsigc++-2.0-0v5,2.12.1-3,type-safe Signal Framework for C++ - runtime
- cli_names: tuple[str, ...] = ('aptitude',)¶
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 = 'aptitude'¶
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.
- install(package_id, version=None)[source]¶
Install one package.
$ sudo aptitude --quiet --disable-columns --assume-yes install nyancat
$ sudo aptitude --quiet --disable-columns --assume-yes install nyancat=1.5.2-0.3+b1
- Return type:
- 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.
- upgrade_all_cli()[source]¶
Generates the CLI to upgrade all outdated packages.
safe-upgradenever removes an installed package to resolve an upgrade, which is the conservatismapt upgradehas andfull-upgradedrops.$ sudo aptitude --quiet --disable-columns --assume-yes safe-upgrade
- upgrade_one_cli(package_id, version=None)[source]¶
Generates the CLI to upgrade the provided package.
Routed through
install, which moves an already-installed package to the requested version, since naming a package onsafe-upgradestill drags in every other member of its dependency cluster.$ sudo aptitude --quiet --disable-columns --assume-yes install eject
- remove(package_id)[source]¶
Remove one package.
$ sudo aptitude --quiet --disable-columns --assume-yes remove nyancat
- Return type:
- sync()[source]¶
Sync package metadata.
$ sudo aptitude --quiet --disable-columns update
- Return type: