Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pkg_install/admin Add 'pmatch' keyword: pkg_admin p...



details:   https://anonhg.NetBSD.org/src/rev/37d242b2fa35
branches:  trunk
changeset: 534861:37d242b2fa35
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Sun Aug 04 20:50:55 2002 +0000

description:
Add 'pmatch' keyword: pkg_admin pmatch pattern pkg

Will return true if 'pkg' matches 'pattern', false else.
Provides a command line interface to the pmatch() C function
to be used from shell scripts etc.

diffstat:

 usr.sbin/pkg_install/admin/main.c      |  27 ++++++++++++++++++++++++---
 usr.sbin/pkg_install/admin/pkg_admin.1 |   8 +++++---
 2 files changed, 29 insertions(+), 6 deletions(-)

diffs (81 lines):

diff -r a1a0b9a683e3 -r 37d242b2fa35 usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Sun Aug 04 20:29:44 2002 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Sun Aug 04 20:50:55 2002 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: main.c,v 1.28 2002/07/20 08:40:19 grant Exp $  */
+/*     $NetBSD: main.c,v 1.29 2002/08/04 20:50:55 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.28 2002/07/20 08:40:19 grant Exp $");
+__RCSID("$NetBSD: main.c,v 1.29 2002/08/04 20:50:55 hubertf Exp $");
 #endif
 
 /*
@@ -345,6 +345,26 @@
                show_version();
                /* NOTREACHED */
 
+       } else if (strcasecmp(argv[1], "pmatch") == 0) {
+
+               char *pattern, *pkg;
+               
+               argv++;         /* argv[0] */
+               argv++;         /* "pmatch" */
+
+               pattern = argv[0];
+               pkg = argv[1];
+
+               if (pattern == NULL || pkg == NULL) {
+                       usage();
+               }
+
+               if (pmatch(pattern, pkg)){
+                       return 0;
+               } else {
+                       return 1;
+               }
+         
        } else if (strcasecmp(argv[1], "rebuild") == 0) {
 
                rebuild();
@@ -567,7 +587,8 @@
 #endif
            " lsall /path/to/pkgpattern   - list all pkgs matching the pattern\n"
            " lsbest /path/to/pkgpattern  - list pkgs matching the pattern best\n"
-           " dump                        - dump database\n");
+           " dump                        - dump database\n"
+           " pmatch pattern pkg          - returns true if pkg matches pattern, false else\n");
        exit(1);
 }
 
diff -r a1a0b9a683e3 -r 37d242b2fa35 usr.sbin/pkg_install/admin/pkg_admin.1
--- a/usr.sbin/pkg_install/admin/pkg_admin.1    Sun Aug 04 20:29:44 2002 +0000
+++ b/usr.sbin/pkg_install/admin/pkg_admin.1    Sun Aug 04 20:50:55 2002 +0000
@@ -1,6 +1,6 @@
-.\"    $NetBSD: pkg_admin.1,v 1.16 2002/02/08 01:38:53 ross Exp $
+.\"    $NetBSD: pkg_admin.1,v 1.17 2002/08/04 20:50:55 hubertf Exp $
 .\"
-.\" Copyright (c) 1999 Hubert Feyrer.  All rights reserved.
+.\" Copyright (c) 1999-2002 Hubert Feyrer.  All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 4, 2000
+.Dd Aug 4, 2002
 .Dt PKG_ADMIN 1
 .Os
 .Sh NAME
@@ -93,6 +93,8 @@
 /usr/pkgsrc/packages/i386ELF/All/mit-pthreads-1.60b6.tgz
 /usr/pkgsrc/packages/i386ELF/All/unproven-pthreads-0.15.tgz
 .Ed
+.It Cm pmatch pattern pkg
+Returns true if pkg matches pattern, false else.
 .It Cm rebuild
 Rebuild the package database mapping from scratch, scanning
 subdirectories in



Home | Main Index | Thread Index | Old Index