meta_package_manager.managers.nala module¶

class meta_package_manager.managers.nala.Nala[source]¶

Bases: PackageManager

Front-end to Debian’s apt, driving libapt-pkg directly.

Nala reaches the same archives apt does, adding a parallel downloader, a mirror-scoring fetcher and a transaction history it can roll back. It is wrapped on the same grounds as the AUR helpers that sit over pacman: 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.

Important

Every invocation forces LC_ALL=C, and it is doing two jobs at once. Nala translates its own output at runtime, so a French host reports est installé``where the parsers expect``is installed; and it picks its tree glyphs from the encoding of its output stream. The same flag that pins the language to the untranslated strings also selects the ASCII glyphs, giving one stable shape to parse instead of a matrix of locale and encoding.

Caution

A listing is a record of three lines, not a line per package: a header naming the package and its version, a branch giving its status, and another carrying its description. That is why this is a class rather than a declarative definition, and why outdated correlates two lines to pair an installed version with the candidate it can move to.

Note

Nala’s own upgrade takes no package arguments at all, accepting only exclusions, so naming a package cannot restrict it. Upgrading one package therefore goes through install, which moves an already-installed package to its candidate version, exactly as apt does.

Documentation: nala.

Initialize cli_errors list.

name: str = 'Nala'¶

Return package manager’s common name.

Default value is based on class name.

homepage_url: str | None = 'https://gitlab.com/volian/nala'¶

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='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='debian', name='Debian'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), 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='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), 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='sourcemage', name='Source Mage GNU/Linux'), 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¶

Nala checks for root and exits with a message rather than escalating on its own, so mpm supplies the privilege for the operations that mutate.

requirement: str | None = '>=0.12.2'¶

The oldest release still shipped by a supported distribution, and the floor from which the listing format is unchanged: its emitting code is byte-identical from there through the newest release.

extra_env: ClassVar = {'LC_ALL': 'C'}¶

Additional environment variables to add to the current context.

Automatically applied on each meta_package_manager.execution.CLIExecutor.run_cli() calls.

version_regexes: tuple[str, ...] = ('nala\\s+(?P<version>\\S+)',)¶

Search the version right after the nala string.

$ nala --version
nala 0.16.0
property installed: Iterator[Package]¶

Fetch installed packages.

$ nala list --installed
vim 2:8.2.3995-1+b2 [Debian/sid main]
+-- is installed
`-- Vi IMproved - enhanced vi editor
property outdated: Iterator[Package]¶

Fetch outdated packages.

The two versions sit on different lines: the header carries the installed one, and the status branch names the candidate.

$ nala list --upgradable
vim 2:8.2.3995-1+b2 [Debian/sid main]
+-- is installed and upgradable to 2:8.2.4659-1
`-- Vi IMproved - enhanced vi editor
search(query, extended, exact)[source]¶

Fetch matching packages.

The query is a regular expression as far as nala is concerned, so mpm’s own refiltering narrows whatever comes back.

Caution

Search does not support extended or exact matching.

$ nala search vim
Return type:

Iterator[Package]

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

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 = 'nala'¶

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 nala install --assume-yes firefox
Return type:

str

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 packages.

$ sudo nala upgrade --assume-yes
Return type:

tuple[str, ...]

upgrade_one_cli(package_id, version=None)[source]¶

Generates the CLI to upgrade the package provided as parameter.

Routed through install, since nala’s own upgrade accepts no package arguments and would upgrade everything. Installing a package already present moves it to its candidate version.

$ sudo nala install --assume-yes firefox
Return type:

tuple[str, ...]

remove(package_id)[source]¶

Removes a package.

$ sudo nala remove --assume-yes firefox
Return type:

str

sync()[source]¶

Sync package metadata.

$ sudo nala update
Return type:

None

cleanup_orphan()[source]¶

Removes packages nothing depends on anymore.

$ sudo nala autoremove --assume-yes
Return type:

None

cleanup_cache()[source]¶

Removes things we don’t need anymore.

$ sudo nala clean
Return type:

None