diff options
author | jlam <jlam> | 2004-05-07 16:40:41 +0000 |
---|---|---|
committer | jlam <jlam> | 2004-05-07 16:40:41 +0000 |
commit | 470054360428449e807440332bad42752f3dd395 (patch) | |
tree | 776c390a73331bc5541eeecbd78784a522f00ab3 /pkgtools | |
parent | 2c496f32955821fd09b47eec2f92cdd1db2356ec (diff) | |
download | pkgsrc-470054360428449e807440332bad42752f3dd395.tar.gz |
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 (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/info/info.h | 5 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/main.c | 15 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/perform.c | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/pkg_info.1 | 13 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/pkg_info.cat1 | 47 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/show.c | 46 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
7 files changed, 101 insertions, 35 deletions
diff --git a/pkgtools/pkg_install/files/info/info.h b/pkgtools/pkg_install/files/info/info.h index aa04f5f3545..5c62757f5b9 100644 --- a/pkgtools/pkg_install/files/info/info.h +++ b/pkgtools/pkg_install/files/info/info.h @@ -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 size_t termwidth; 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 --git a/pkgtools/pkg_install/files/info/main.c b/pkgtools/pkg_install/files/info/main.c index e4b77ad7be0..ef617388a25 100644 --- a/pkgtools/pkg_install/files/info/main.c +++ b/pkgtools/pkg_install/files/info/main.c @@ -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 @@ __RCSID("$NetBSD: main.c,v 1.8 2004/03/22 11:44:24 wiz Exp $"); #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 @@ usage(void) 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 @@ main(int argc, char **argv) Flags |= SHOW_PREFIX; break; + case 'Q': + Flags |= SHOW_BI_VAR; + BuildInfoVariable = optarg; + break; + case 'q': Quiet = TRUE; break; diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index d298871bf09..66c0e1f8158 100644 --- a/pkgtools/pkg_install/files/info/perform.c +++ b/pkgtools/pkg_install/files/info/perform.c @@ -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 @@ pkg_do(char *pkg) (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 --git a/pkgtools/pkg_install/files/info/pkg_info.1 b/pkgtools/pkg_install/files/info/pkg_info.1 index c2486d69c5c..3c0c084473f 100644 --- a/pkgtools/pkg_install/files/info/pkg_info.1 +++ b/pkgtools/pkg_install/files/info/pkg_info.1 @@ -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 was built with (exact dependencies), if any. 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 --git a/pkgtools/pkg_install/files/info/pkg_info.cat1 b/pkgtools/pkg_install/files/info/pkg_info.cat1 index d4116848e6e..589e49a4ee0 100644 --- a/pkgtools/pkg_install/files/info/pkg_info.cat1 +++ b/pkgtools/pkg_install/files/info/pkg_info.cat1 @@ -7,6 +7,7 @@ SSYYNNOOPPSSIISS 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 @@ DDEESSCCRRIIPPTTIIOONN --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 @@ DDEESSCCRRIIPPTTIIOONN --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 @@ DDEESSCCRRIIPPTTIIOONN 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 @@ DDEESSCCRRIIPPTTIIOONN 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 @@ PPAACCKKAAGGEE WWIILLDDCCAARRDDSS 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 @@ EENNVVIIRROONNMMEENNTT 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 --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c index f1f1d2cc2f1..d6d5ce0e466 100644 --- a/pkgtools/pkg_install/files/info/show.c +++ b/pkgtools/pkg_install/files/info/show.c @@ -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 @@ show_file(char *title, char *fname) } 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 --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 184ee90730b..f851dc330fb 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.28 2004/04/28 15:38:17 tv Exp $ */ +/* $NetBSD: version.h,v 1.29 2004/05/07 16:40:41 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_ */ |