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 Add a new flag -Q (for "query") to pkg_...



details:   https://anonhg.NetBSD.org/src/rev/79a460616b23
branches:  trunk
changeset: 566389:79a460616b23
user:      jlam <jlam%NetBSD.org@localhost>
date:      Fri May 07 16:40:30 2004 +0000

description:
Add a new flag -Q (for "query") to pkg_info(1) to query the build
information for the definitions of specific variables that were saved
from build time, e.g.

        $ pkg_info -Q PKGPATH glib
        devel/glib
        $ pkg_info -Q PROVIDES glib
        /usr/pkg/lib/libglib.so.13
        /usr/pkg/lib/libgmodule.so.13
        /usr/pkg/lib/libgthread.so.13

Bump the version number of pkg_install(1) to 20040507.

diffstat:

 usr.sbin/pkg_install/info/info.h     |   5 +++-
 usr.sbin/pkg_install/info/main.c     |  15 ++++++++---
 usr.sbin/pkg_install/info/perform.c  |   6 +++-
 usr.sbin/pkg_install/info/pkg_info.1 |  13 +++++++++-
 usr.sbin/pkg_install/info/show.c     |  46 ++++++++++++++++++++++++++++++++++-
 usr.sbin/pkg_install/lib/version.h   |   4 +-
 6 files changed, 77 insertions(+), 12 deletions(-)

diffs (230 lines):

diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/info/info.h
--- a/usr.sbin/pkg_install/info/info.h  Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/info/info.h  Fri May 07 16:40:30 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: info.h,v 1.14 2003/09/02 07:34:57 jlam Exp $ */
+/* $NetBSD: info.h,v 1.15 2004/05/07 16:40:30 jlam Exp $ */
 
 /* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */
 
@@ -51,12 +51,14 @@
 #define SHOW_PKG_SIZE          0x08000
 #define SHOW_ALL_SIZE          0x10000
 #define SHOW_BLD_DEPENDS       0x20000
+#define SHOW_BI_VAR            0x20000
 
 extern int Flags;
 extern Boolean AllInstalled;
 extern Boolean File2Pkg;
 extern Boolean Quiet;
 extern char *InfoPrefix;
+extern char *BuildInfoVariable;
 extern char PlayPen[];
 extern size_t PlayPenSize;
 extern char *CheckPkg;
@@ -64,6 +66,7 @@
 extern lpkg_head_t pkgs;
 
 extern void show_file(char *, char *);
+extern void show_build_info_var(const char *);
 extern void show_plist(char *, package_t *, pl_ent_t);
 extern void show_files(char *, package_t *);
 extern void show_depends(char *, package_t *);
diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/info/main.c
--- a/usr.sbin/pkg_install/info/main.c  Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/info/main.c  Fri May 07 16:40:30 2004 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.39 2004/03/22 11:42:51 wiz Exp $    */
+/*     $NetBSD: main.c,v 1.40 2004/05/07 16:40:30 jlam Exp $   */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.39 2004/03/22 11:42:51 wiz Exp $");
+__RCSID("$NetBSD: main.c,v 1.40 2004/05/07 16:40:30 jlam Exp $");
 #endif
 #endif
 
@@ -38,13 +38,14 @@
 #include "lib.h"
 #include "info.h"
 
-static const char Options[] = "aBbcDde:fFhIiK:kLl:mNnpqRrsSvV";
+static const char Options[] = "aBbcDde:fFhIiK:kLl:mNnpQ:qRrsSvV";
 
 int     Flags = 0;
 Boolean AllInstalled = FALSE;
 Boolean File2Pkg = FALSE;
 Boolean Quiet = FALSE;
 char   *InfoPrefix = "";
+char   *BuildInfoVariable = "";
 char    PlayPen[FILENAME_MAX];
 size_t  PlayPenSize = sizeof(PlayPen);
 char   *CheckPkg = NULL;
@@ -57,7 +58,8 @@
        fprintf(stderr, "%s\n%s\n%s\n",
            "usage: pkg_info [-BbcDdFfIikLmNnpqRrSsVvh] [-e package] [-l prefix]",
            "                pkg-name [pkg-name ...]",
-           "       pkg_info -a [flags]");
+           "       pkg_info -a [flags]",
+           "       pkg_info -Q variable pkg-name [pkg-name ...]");
        exit(1);
 }
 
@@ -147,6 +149,11 @@
                        Flags |= SHOW_PREFIX;
                        break;
 
+               case 'Q':
+                       Flags |= SHOW_BI_VAR;
+                       BuildInfoVariable = optarg;
+                       break;
+
                case 'q':
                        Quiet = TRUE;
                        break;
diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/info/perform.c
--- a/usr.sbin/pkg_install/info/perform.c       Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/info/perform.c       Fri May 07 16:40:30 2004 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.51 2003/12/20 03:31:56 grant Exp $       */
+/*     $NetBSD: perform.c,v 1.52 2004/05/07 16:40:30 jlam Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.51 2003/12/20 03:31:56 grant Exp $");
+__RCSID("$NetBSD: perform.c,v 1.52 2004/05/07 16:40:30 jlam Exp $");
 #endif
 #endif
 
@@ -153,6 +153,8 @@
 
                (void) snprintf(tmp, sizeof(tmp), "%-19s ", pkg);
                show_index(tmp, COMMENT_FNAME);
+       } else if (Flags & SHOW_BI_VAR) {
+               show_var(BUILD_INFO_FNAME, BuildInfoVariable);
        } else {
                FILE   *fp;
                package_t plist;
diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/info/pkg_info.1
--- a/usr.sbin/pkg_install/info/pkg_info.1      Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/info/pkg_info.1      Fri May 07 16:40:30 2004 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_info.1,v 1.38 2004/04/19 18:43:26 itojun Exp $
+.\" $NetBSD: pkg_info.1,v 1.39 2004/05/07 16:40:30 jlam Exp $
 .\"
 .\" FreeBSD install - a package for the installation and maintenance
 .\" of non-core utilities.
@@ -40,6 +40,11 @@
 .Bk -words
 .Op Fl a Ar flags
 .Ek
+.Nm
+.Bk -words
+.Op Fl Q Ar variable
+.Ek
+.Ar pkg-name ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -140,6 +145,12 @@
 Show which packages each package needs (depends upon), if any.
 .It Fl p
 Show the installation prefix for each package.
+.It Fl Q
+Show the definition of
+.Ar variable
+from the build information for each package.
+An empty string is returned if no such variable definition is found for
+the package(s).
 .It Fl q
 Be ``quiet'' in emitting report headers and such, just dump the
 raw info (basically, assume a non-human reading).
diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/info/show.c
--- a/usr.sbin/pkg_install/info/show.c  Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/info/show.c  Fri May 07 16:40:30 2004 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: show.c,v 1.28 2004/04/01 02:37:24 reed Exp $   */
+/*     $NetBSD: show.c,v 1.29 2004/05/07 16:40:31 jlam Exp $   */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
 #else
-__RCSID("$NetBSD: show.c,v 1.28 2004/04/01 02:37:24 reed Exp $");
+__RCSID("$NetBSD: show.c,v 1.29 2004/05/07 16:40:31 jlam Exp $");
 #endif
 #endif
 
@@ -124,6 +124,48 @@
 }
 
 void
+show_var(const char *fname, const char *variable)
+{
+       FILE   *fp;
+       char   *line;
+       size_t  len;
+       size_t  varlen;
+
+       fp = fopen(fname, "r");
+       if (!fp) {
+               warnx("show_var: can't open '%s' for reading", fname);
+               return;
+       }
+
+       varlen = strlen(variable);
+       if (varlen > 0) {
+               while ((line = fgetln(fp, &len)) != (char *) NULL) {
+                       /*
+                        * We expect lines to look like one of the following
+                        * forms:
+                        *      VAR=value
+                        *      VAR= value
+                        * We print out the value of VAR, or nothing if it
+                        * doesn't exist.
+                        */
+                       if (line[len - 1] == '\n')
+                               line[len - 1] = '\0';
+                       if (strncmp(variable, line, varlen) == 0) {
+                               line += varlen;
+                               if (*line != '=')
+                                       continue;
+                               ++line;
+                               if (*line == ' ')
+                                       ++line;
+                               (void) printf("%s\n", line);
+                       }
+               }
+       }
+       (void) fclose(fp);
+       return;
+}
+
+void
 show_index(char *title, char *fname)
 {
        FILE   *fp;
diff -r ed138a655182 -r 79a460616b23 usr.sbin/pkg_install/lib/version.h
--- a/usr.sbin/pkg_install/lib/version.h        Fri May 07 16:09:46 2004 +0000
+++ b/usr.sbin/pkg_install/lib/version.h        Fri May 07 16:40:30 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.50 2004/04/28 15:37:29 tv Exp $  */
+/*     $NetBSD: version.h,v 1.51 2004/05/07 16:40:31 jlam Exp $        */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -33,6 +33,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION "20040428"
+#define PKGTOOLS_VERSION "20040507"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index