From 6feb4e3837e166a4c2c07e9e53693c86f3963f6b Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 12 Aug 2013 11:26:31 -0500 Subject: [PATCH] Fail apt package install when nothing is matched by the fnmatch pattern Related to PR #3823 --- library/packaging/apt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/packaging/apt b/library/packaging/apt index acc61b6c67b..94d2ad8f55c 100644 --- a/library/packaging/apt +++ b/library/packaging/apt @@ -185,7 +185,11 @@ def expand_pkgspec_from_fnmatches(m, pkgspec, cache): else: matches = fnmatch.filter( [pkg.name for pkg in cache], pkgname_or_fnmatch_pattern) - new_pkgspec.extend(matches) + + if len(matches) == 0: + m.fail_json(msg="No package(s) matching '%s' available" % str(pkgname_or_fnmatch_pattern)) + else: + new_pkgspec.extend(matches) else: new_pkgspec.append(pkgname_or_fnmatch_pattern) return new_pkgspec