diff --git a/packaging/os/apt.py b/packaging/os/apt.py index c086cdc3326..a160c13c311 100644 --- a/packaging/os/apt.py +++ b/packaging/os/apt.py @@ -29,7 +29,7 @@ version_added: "0.0.2" options: name: description: - - A package name, like C(foo), or package specifier with version, like C(foo=1.0). Name wildcards (fnmatch) like C(apt*) and version wildcards like C(foo=1.0*) are also supported. + - A package name, like C(foo), or package specifier with version, like C(foo=1.0). Name wildcards (fnmatch) like C(apt*) and version wildcards like C(foo=1.0*) are also supported. Note that the apt-get commandline supports implicit regex matches here but we do not because it can let typos through easier (If you typo C(foo) as C(fo) apt-get would install packages that have "fo" in their name with a warning and a prompt for the user. Since we don't have warnings and prompts before installing we disallow this. Use an explicit fnmatch pattern if you want wildcarding) required: false default: null state: @@ -271,6 +271,14 @@ def expand_dpkg_options(dpkg_options_compressed): return dpkg_options.strip() def expand_pkgspec_from_fnmatches(m, pkgspec, cache): + # Note: apt-get does implicit regex matching when an exact package name + # match is not found. Something like this: + # matches = [pkg.name for pkg in cache if re.match(pkgspec, pkg.name)] + # (Should also deal with the ':' for multiarch like the fnmatch code below) + # + # We have decided not to do similar implicit regex matching but might take + # a PR to add some sort of explicit regex matching: + # https://github.com/ansible/ansible-modules-core/issues/1258 new_pkgspec = [] for pkgspec_pattern in pkgspec: pkgname_pattern, version = package_split(pkgspec_pattern)