Jörg Mechnich 2 weeks ago committed by GitHub
commit f71c77c951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
minor_changes:
- apt - add support for apt-patterns (https://github.com/ansible/ansible/pull/83070)

@ -634,8 +634,11 @@ def expand_pkgspec_from_fnmatches(m, pkgspec, cache):
pkgname_pattern, version_cmp, version = package_split(pkgspec_pattern)
if pkgname_pattern.startswith(('?', '~', '(?', '(~')):
# this is an apt-pattern (https://manpages.debian.org/bookworm/apt/apt-patterns.7.en.html)
new_pkgspec.append(pkgspec_pattern)
# note that none of these chars is allowed in a (debian) pkgname
if frozenset('*?[]!').intersection(pkgname_pattern):
elif frozenset('*?[]!').intersection(pkgname_pattern):
# handle multiarch pkgnames, the idea is that "apt*" should
# only select native packages. But "apt*:i386" should still work
if ":" not in pkgname_pattern:
@ -952,7 +955,7 @@ def remove(m, pkgspec, cache, purge=False, force=False,
for package in pkgspec:
name, version_cmp, version = package_split(package)
installed, installed_version, upgradable, has_files = package_status(m, name, version_cmp, version, None, cache, state='remove')
if installed_version or (has_files and purge):
if installed_version or (has_files and purge) or package.startswith(('?', '~', '(?', '(~')):
pkg_list.append("'%s'" % package)
packages = ' '.join(pkg_list)

@ -38,6 +38,11 @@ fake_cache = [
["apt", "apt-utils"],
id="pkgname-expands",
),
pytest.param(
["?config-files"],
["?config-files"],
id="apt-pattern",
),
],
)
def test_expand_pkgspec_from_fnmatches(test_input, expected):

Loading…
Cancel
Save