summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorkrion <krion@FreeBSD.org>2005-11-08 20:48:26 +0000
committerkrion <krion@FreeBSD.org>2005-11-08 20:48:26 +0000
commit5fd5a0c4b28e58f85df18e5dc0879f8173d87b7b (patch)
treef420ee9bc1cc2825cecfd40fef5d5db844ca9d38 /usr.sbin/pkg_install
parent48c0bcb5c218c021c1da0e53702d2e83708a471a (diff)
downloadFreeBSD-src-5fd5a0c4b28e58f85df18e5dc0879f8173d87b7b.zip
FreeBSD-src-5fd5a0c4b28e58f85df18e5dc0879f8173d87b7b.tar.gz
Introduce 3 new options for pkg_create(1), -x for using basic
regular expressions for pkg-name, -E for extended regexps and -G for exact matching. Submitted by: mux MFC after: 3 days
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/create/create.h1
-rw-r--r--usr.sbin/pkg_install/create/main.c17
-rw-r--r--usr.sbin/pkg_install/create/perform.c37
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.113
4 files changed, 61 insertions, 7 deletions
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h
index 33c3db7..9450170 100644
--- a/usr.sbin/pkg_install/create/create.h
+++ b/usr.sbin/pkg_install/create/create.h
@@ -23,6 +23,7 @@
#ifndef _INST_CREATE_H_INCLUDE
#define _INST_CREATE_H_INCLUDE
+extern match_t MatchType;
extern char *Prefix;
extern char *Comment;
extern char *Desc;
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 4869bfd5..1c3af29 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -16,8 +16,9 @@ __FBSDID("$FreeBSD$");
#include "lib.h"
#include "create.h"
-static char Options[] = "YNORhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
+static char Options[] = "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
+match_t MatchType = MATCH_GLOB;
char *Prefix = NULL;
char *Comment = NULL;
char *Desc = NULL;
@@ -57,6 +58,18 @@ main(int argc, char **argv)
Verbose = TRUE;
break;
+ case 'x':
+ MatchType = MATCH_REGEX;
+ break;
+
+ case 'E':
+ MatchType = MATCH_EREGEX;
+ break;
+
+ case 'G':
+ MatchType = MATCH_EXACT;
+ break;
+
case 'N':
AutoAnswer = NO;
break;
@@ -216,6 +229,6 @@ usage()
" [-D displayfile] [-m mtreefile] [-o origin] ",
" [-s srcdir] [-S basedir] ",
" -c comment -d description -f packlist pkg-filename",
-" pkg_create [-YNhvyzR] -b pkg-name [pkg-filename]");
+" pkg_create [-EGYNhvxyzR] -b pkg-name [pkg-filename]");
exit(1);
}
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 3f7ab47..51a3cfa 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);
diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1
index 62599ea..e7666cd 100644
--- a/usr.sbin/pkg_install/create/pkg_create.1
+++ b/usr.sbin/pkg_install/create/pkg_create.1
@@ -23,7 +23,7 @@
.\" [jkh] Took John's changes back and made some additional extensions for
.\" better integration with FreeBSD's new ports collection.
.\"
-.Dd June 14, 2005
+.Dd November 8, 2005
.Dt PKG_CREATE 1
.Os
.Sh NAME
@@ -52,7 +52,7 @@
.Fl f Ar packlist
.Ar pkg-filename
.Nm
-.Op Fl YNRhvy
+.Op Fl EGYNRhvxy
.Fl b Ar pkg-name
.Op Ar pkg-filename
.Sh DESCRIPTION
@@ -341,6 +341,15 @@ also create package files for all packages required by
Resulting archive(s) will be created in the current directory
and named using name of the respective package with appropriate
extraction suffix applied.
+.It Fl x
+Use basic regular expressions for
+.Ar pkg-name .
+.It Fl E
+Use extended (modern) regular expressions for
+.Ar pkg-name .
+.It Fl G
+Use exact matching for
+.Ar pkg-name .
.El
.Sh PACKING LIST DETAILS
The
OpenPOWER on IntegriCloud