Apt, expresiones regulares y apt-pattern

Brevísima entrada para comentar un cambio importante en el funcionamiento de apt a partir de la versión 1.9.6:

apt (1.9.6) experimental; urgency=medium

apt(8) no longer treats package names passed as regular expressions or fnmatch expressions, requiring the use of patterns (apt-patterns(5)) to perform complex searches. For ease of use, regular expressions starting with ^ or ending with $ continue to work.

This fixes the problem where e.g. g++ could mean either «the package g++» or, if there is no g++ package, «all packages containing g». This change will propagate to apt-* after the release of Debian bullseye.

— Julian Andres Klode [email protected] Wed, 15 Jan 2020 21:45:18 +0100

Que viene a querer decir que cuando hagáis una búsqueda con apt, la cadena de texto ya no se va a interpretar como una expresión regular, salvo que comience por ^ o termine por $. Para realizar búsquedas en los directorios de paquetes utilizando expresiones regulares debemos ceñirnos a las directrices establecidas en apt-patterns:

LOGIC PATTERNS
These patterns provide the basic means to combine other patterns into more complex expressions, as well as ?true and
?false patterns.
?and(PATTERN, PATTERN, …), PATTERN PATTERN …
Selects objects where all specified patterns match.
?false, ~F
Selects nothing.
?not(PATTERN), !PATTERN
Selects objects where PATTERN does not match.
?or(PATTERN, PATTERN, …), PATTERN | PATTERN | …
Selects objects where at least one of the specified patterns match.
?true, ~T
Selects all objects.
(PATTERN)
Selects the same as PATTERN, can be used to work around precedence, for example, (~ramd64|~ri386)~nfoo

NARROWING PATTERNS
?all-versions(PATTERN)
Selects packages where all versions match PATTERN. When matching versions instead, same as PATTERN.
?any-version(PATTERN)
Selects any version where the pattern matches on the version.
For example, while ?and(?version(1),?version(2)) matches a package which has one version containing 1 and one
version containing 2, ?any-version(?and(?version(1),?version(2))) restricts the ?and to act on the same version.
?narrow(PATTERN…)
Selects any version matching all PATTERNs, short for?any-version(?and(PATTERN…)).

PACKAGE PATTERNS
These patterns select specific packages.
?architecture(WILDCARD), ~rWILDCARD
Selects packages matching the specified architecture, which may contain wildcards using any.
?automatic, ~M
Selects packages that were installed automatically.
?broken, ~b
Selects packages that have broken dependencies.
?config-files, ~c
Selects packages that are not fully installed, but have solely residual configuration files left.
?essential, ~E
Selects packages that have Essential: yes set in their control file.
?exact-name(NAME)
Selects packages with the exact specified name.
?garbage, ~g
Selects packages that can be removed automatically.
?installed, ~i
Selects packages that are currently installed.
?name(REGEX), ~nREGEX
Selects packages where the name matches the given regular expression.
?obsolete, ~o
Selects packages that no longer exist in repositories.
?upgradable, ~U
Selects packages that can be upgraded (have a newer candidate).
?virtual, ~v
Selects all virtual packages; that is packages without a version. These exist when they are referenced somewhere
in the archive, for example because something depends on that name.

VERSION PATTERNS
These patterns select specific versions of a package.
?archive(REGEX), ~AREGEX
Selects versions that come from the archive that matches the specified regular expression. Archive, here, means
the values after a= in apt-cache policy.
?origin(REGEX), ~OREGEX
Selects versions that come from the origin that matches the specified regular expression. Origin, here, means the
values after o= in apt-cache policy.
?section(REGEX), ~sREGEX
Selects versions where the section matches the specified regular expression.
?source-package(REGEX), ~eREGEX
Selects versions where the source package name matches the specified regular expression.
?source-version(REGEX)
Selects versions where the source package version matches the specified regular expression.
?version(REGEX), ~VREGEX
Selects versions where the version string matching the specified regular expression.

EXAMPLES
apt remove ?garbage
Remove all packages that are automatically installed and no longer needed – same as apt autoremove
apt purge ?config-files
Purge all packages that only have configuration files left
apt list ‘~i !~M (~slibs|~sperl|~spython)’
List all manually-installed packages in sections matching libs, perl, or python.

Happy apt hacking!

Sentimos molestarte con lo de las Cookies, pero es por imperativo legal. Puedes ver aquí la Política de Cookies, si continúas navegando te informo que la estás aceptando ;)    Ver
Privacidad