pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files Import pkg_install-20040507...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f9fb312a2a6b
branches:  trunk
changeset: 474933:f9fb312a2a6b
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri May 07 16:40:41 2004 +0000

description:
Import pkg_install-20040507 from src/usr.sbin/pkg_install:

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

diffstat:

 pkgtools/pkg_install/files/info/info.h        |   5 ++-
 pkgtools/pkg_install/files/info/main.c        |  15 ++++++--
 pkgtools/pkg_install/files/info/perform.c     |   6 ++-
 pkgtools/pkg_install/files/info/pkg_info.1    |  13 ++++++-
 pkgtools/pkg_install/files/info/pkg_info.cat1 |  47 +++++++++++++-------------
 pkgtools/pkg_install/files/info/show.c        |  46 +++++++++++++++++++++++++-
 pkgtools/pkg_install/files/lib/version.h      |   4 +-
 7 files changed, 101 insertions(+), 35 deletions(-)

diffs (truncated from 344 to 300 lines):

diff -r 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/info.h
--- a/pkgtools/pkg_install/files/info/info.h    Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/info.h    Fri May 07 16:40:41 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: info.h,v 1.3 2003/09/23 07:13:51 grant Exp $ */
+/* $NetBSD: info.h,v 1.4 2004/05/07 16:40:41 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 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/main.c
--- a/pkgtools/pkg_install/files/info/main.c    Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/main.c    Fri May 07 16:40:41 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.8 2004/03/22 11:44:24 wiz Exp $     */
+/*     $NetBSD: main.c,v 1.9 2004/05/07 16:40:41 jlam Exp $    */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #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.8 2004/03/22 11:44:24 wiz Exp $");
+__RCSID("$NetBSD: main.c,v 1.9 2004/05/07 16:40:41 jlam Exp $");
 #endif
 #endif
 
@@ -50,13 +50,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;
@@ -69,7 +70,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);
 }
 
@@ -159,6 +161,11 @@
                        Flags |= SHOW_PREFIX;
                        break;
 
+               case 'Q':
+                       Flags |= SHOW_BI_VAR;
+                       BuildInfoVariable = optarg;
+                       break;
+
                case 'q':
                        Quiet = TRUE;
                        break;
diff -r 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Fri May 07 16:40:41 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.14 2003/12/20 04:23:05 grant Exp $       */
+/*     $NetBSD: perform.c,v 1.15 2004/05/07 16:40:41 jlam Exp $        */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #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.14 2003/12/20 04:23:05 grant Exp $");
+__RCSID("$NetBSD: perform.c,v 1.15 2004/05/07 16:40:41 jlam Exp $");
 #endif
 #endif
 
@@ -171,6 +171,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 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/pkg_info.1
--- a/pkgtools/pkg_install/files/info/pkg_info.1        Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/pkg_info.1        Fri May 07 16:40:41 2004 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_info.1,v 1.8 2004/02/07 10:37:53 grant Exp $
+.\" $NetBSD: pkg_info.1,v 1.9 2004/05/07 16:40:41 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 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/pkg_info.cat1
--- a/pkgtools/pkg_install/files/info/pkg_info.cat1     Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/pkg_info.cat1     Fri May 07 16:40:41 2004 +0000
@@ -7,6 +7,7 @@
      ppkkgg__iinnffoo [--BBbbccDDddFFffhhIIiikkLLmmNNnnppqqRRrrSSssVVvv] [--ee _p_a_c_k_a_g_e] [--KK _p_k_g___d_b_d_i_r]
               [--ll _p_r_e_f_i_x] _p_k_g_-_n_a_m_e _._._.
      ppkkgg__iinnffoo [--aa _f_l_a_g_s]
+     ppkkgg__iinnffoo [--QQ _v_a_r_i_a_b_l_e] _p_k_g_-_n_a_m_e _._._.
 
 DDEESSCCRRIIPPTTIIOONN
      The ppkkgg__iinnffoo command is used to dump out information for packages, which
@@ -23,8 +24,8 @@
 
      --aa      Show information for all currently installed packages.
 
-     --BB      Show some of the important definitions used when building the
-             binary package (the "Build information") for each package.
+     --BB      Show some of the important definitions used when building the bi-
+             nary package (the "Build information") for each package.
 
      --bb      Show the NetBSD RCS Id strings from the files used in the con-
              struction of the binary package (the "Build version") for each
@@ -39,8 +40,8 @@
 
      --ee _p_k_g_-_n_a_m_e
              This option allows you to test for the existence of a given pack-
-             age.  If the package identified by _p_k_g_-_n_a_m_e is currently
-             installed, return code is 0, otherwise 1.  The names of any pack-
+             age.  If the package identified by _p_k_g_-_n_a_m_e is currently in-
+             stalled, return code is 0, otherwise 1.  The names of any pack-
              age(s) found installed are printed to stdout unless turned off
              using the --qq option.  _p_k_g_-_n_a_m_e can contain wildcards, see the
              _P_A_C_K_A_G_E _W_I_L_D_C_A_R_D_S section below.
@@ -69,11 +70,11 @@
              generated.
 
      --ll _s_t_r  Prefix each information category header (see --qq) shown with _s_t_r.
-             This is primarily of use to front-end programs that want to
-             request a lot of different information fields at once for a pack-
+             This is primarily of use to front-end programs that want to re-
+             quest a lot of different information fields at once for a pack-
              age, but don't necessary want the output intermingled in such a
-             way that they can't organize it.  This lets you add a special
-             token to the start of each field.
+             way that they can't organize it.  This lets you add a special to-
+             ken to the start of each field.
 
      --mm      Show the mtree file (if any) for each package.
 
@@ -103,14 +104,14 @@
 
 TTEECCHHNNIICCAALL DDEETTAAIILLSS
      Package info is either extracted from package files named on the command
-     line, or from already installed package information in
-     _/_v_a_r_/_d_b_/_p_k_g_/_<_p_k_g_-_n_a_m_e_>.
+     line, or from already installed package information in _/_v_a_r_/_d_b_/_p_k_g_/_<_p_k_g_-
+     _n_a_m_e_>.
 
      A filename can be given instead of a (installed) package name to query
      information on the package this file belongs to.  This filename is then
      resolved to a package name using the Package Database.  For this transla-
-     tion to take place, the --FF flag must be given.  The filename must be
-     absolute, compare the output of pkg_info --aaFF.
+     tion to take place, the --FF flag must be given.  The filename must be ab-
+     solute, compare the output of pkg_info --aaFF.
 
 PPAACCKKAAGGEE WWIILLDDCCAARRDDSS
      In the places where a package name/version is expected, e.g. for the --ee
@@ -123,9 +124,9 @@
      matched in a relational manner using the _>_=, _<_=, _>, and _< operators.  For
      example, _p_k_g___i_n_f_o _-_e _'_n_a_m_e_>_=_1_._3_' will match versions 1.3 and later of the
      _n_a_m_e package.  The collating sequence of the various package version num-
-     bers is unusual, but strives to be consistent.  The magic string
-     ``alpha'' equates to _a_l_p_h_a _v_e_r_s_i_o_n and sorts before a beta version.  The
-     magic string ``beta'' equates to _b_e_t_a _v_e_r_s_i_o_n and sorts before a release
+     bers is unusual, but strives to be consistent.  The magic string ``al-
+     pha'' equates to _a_l_p_h_a _v_e_r_s_i_o_n and sorts before a beta version.  The mag-
+     ic string ``beta'' equates to _b_e_t_a _v_e_r_s_i_o_n and sorts before a release
      candidate.  The magic string ``rc'' equates to _r_e_l_e_a_s_e _c_a_n_d_i_d_a_t_e and
      sorts before a release.  For example, _n_a_m_e_-_1_._3_r_c_3 will sort before
      _n_a_m_e_-_1_._3 and after _n_a_m_e_-_1_._2_._9 Similarly _n_a_m_e_-_1_._3_a_l_p_h_a_2 will sort before
@@ -142,21 +143,21 @@
 
      PKG_PATH   This can be used to specify a semicolon-separated list of
                 paths and URLs to search for package files.  If PKG_PATH is
-                used, the suffix _._t_g_z is automatically appended to the
-                _p_k_g_-_n_a_m_e, whereas searching in the current directory uses
-                _p_k_g_-_n_a_m_e literally.
+                used, the suffix _._t_g_z is automatically appended to the _p_k_g_-
+                _n_a_m_e, whereas searching in the current directory uses _p_k_g_-_n_a_m_e
+                literally.
 
      PKG_TMPDIR, TMPDIR
                 These are tried in turn (if set) as candidate directories in
                 which to create a ``staging area'' for any files extracted by
                 ppkkgg__iinnffoo from package files.  If neither PKG_TMPDIR nor TMPDIR
                 yields a suitable scratch directory, _/_v_a_r_/_t_m_p, _/_t_m_p, and
-                _/_u_s_r_/_t_m_p are tried in turn.  Note that _/_u_s_r_/_t_m_p may be cre-
-                ated, if it doesn't already exist.
+                _/_u_s_r_/_t_m_p are tried in turn.  Note that _/_u_s_r_/_t_m_p may be creat-
+                ed, if it doesn't already exist.
 
-                Since ppkkgg__iinnffoo requires very little information to be
-                extracted from any package files examined, it is unlikely that
-                these environment variables would ever need to be used to work
+                Since ppkkgg__iinnffoo requires very little information to be extract-
+                ed from any package files examined, it is unlikely that these
+                environment variables would ever need to be used to work
                 around limited available space in the default locations.
 
 SSEEEE AALLSSOO
diff -r 547386eb90a7 -r f9fb312a2a6b pkgtools/pkg_install/files/info/show.c
--- a/pkgtools/pkg_install/files/info/show.c    Fri May 07 16:38:53 2004 +0000
+++ b/pkgtools/pkg_install/files/info/show.c    Fri May 07 16:40:41 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: show.c,v 1.5 2004/04/09 18:38:12 tv Exp $      */
+/*     $NetBSD: show.c,v 1.6 2004/05/07 16:40:41 jlam Exp $    */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #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.5 2004/04/09 18:38:12 tv Exp $");
+__RCSID("$NetBSD: show.c,v 1.6 2004/05/07 16:40:41 jlam Exp $");
 #endif
 #endif
 
@@ -132,6 +132,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



Home | Main Index | Thread Index | Old Index