aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/create/perform.c
diff options
context:
space:
mode:
authorKirill Ponomarev <krion@FreeBSD.org>2005-11-08 20:48:26 +0000
committerKirill Ponomarev <krion@FreeBSD.org>2005-11-08 20:48:26 +0000
commit1d03b1a1aeaf2baba4e67d46344790e8a9a4d312 (patch)
treef420ee9bc1cc2825cecfd40fef5d5db844ca9d38 /usr.sbin/pkg_install/create/perform.c
parent4e7e0183e1884e2ea9beb2720b22610c0a9e83ba (diff)
Notes
Diffstat (limited to 'usr.sbin/pkg_install/create/perform.c')
-rw-r--r--usr.sbin/pkg_install/create/perform.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 3f7ab47984f0..51a3cfa4d740 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -81,9 +81,40 @@ pkg_perform(char **pkgs)
suf = "tar";
if (InstalledPkg != NULL) {
- if (!Recursive)
- return (create_from_installed(InstalledPkg, pkg, suf));
- return (create_from_installed_recursive(pkg, suf));
+ char *pkgglob[] = { InstalledPkg, NULL };
+ char **matched, **pkgs;
+ int i, error;
+
+ pkgs = pkgglob;
+ if (MatchType != MATCH_EXACT) {
+ matched = matchinstalled(MatchType, pkgs, &error);
+ if (!error && matched != NULL)
+ pkgs = matched;
+ else if (MatchType != MATCH_GLOB)
+ errx(1, "no packages match pattern");
+ }
+ /*
+ * Is there is only one installed package matching the pattern,
+ * we need to respect the optional pkg-filename parameter. If,
+ * however, the pattern matches several packages, this parameter
+ * makes no sense and is ignored.
+ */
+ if (pkgs[1] == NULL) {
+ if (pkg == InstalledPkg)
+ pkg = *pkgs;
+ InstalledPkg = *pkgs;
+ if (!Recursive)
+ return (create_from_installed(InstalledPkg, pkg, suf));
+ return (create_from_installed_recursive(pkg, suf));
+ }
+ for (i = 0; pkgs[i] != NULL; i++) {
+ InstalledPkg = pkg = pkgs[i];
+ if (!Recursive)
+ create_from_installed(pkg, pkg, suf);
+ else
+ create_from_installed_recursive(pkg, suf);
+ }
+ return TRUE;
}
get_dash_string(&Comment);