diff options
author | joerg <joerg> | 2009-03-02 17:13:49 +0000 |
---|---|---|
committer | joerg <joerg> | 2009-03-02 17:13:49 +0000 |
commit | b333f21216c294dae0da13cdf5678c2afe7a710a (patch) | |
tree | 82890a514370bff1dc520fadf9359dd8fceeda4d /pkgtools | |
parent | d109f7e7a2b2877b9e359c303ef39b876dc8d040 (diff) | |
download | pkgsrc-b333f21216c294dae0da13cdf5678c2afe7a710a.tar.gz |
pkg_install-20090302:
Add new option -r to pkg_info, which works like -R, but expands it
recursively.
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 | 12 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/perform.c | 54 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/pkg_info.1 | 9 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/pkg_info.cat1 | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/show.c | 22 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
7 files changed, 95 insertions, 17 deletions
diff --git a/pkgtools/pkg_install/files/info/info.h b/pkgtools/pkg_install/files/info/info.h index 233ade1f6fe..8615c5cb974 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.17 2008/02/02 16:21:45 joerg Exp $ */ +/* $NetBSD: info.h,v 1.18 2009/03/02 17:13:49 joerg Exp $ */ /* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */ @@ -70,6 +70,7 @@ struct pkg_meta { char *meta_preserve; char *meta_views; char *meta_installed_info; + int is_installed; }; #ifndef MAXINDEXSIZE @@ -99,6 +100,7 @@ struct pkg_meta { #define SHOW_BLD_DEPENDS 0x20000 #define SHOW_BI_VAR 0x40000 #define SHOW_SUMMARY 0x80000 +#define SHOW_FULL_REQBY 0x100000 enum which { WHICH_ALL, @@ -128,6 +130,7 @@ void show_depends(const char *, package_t *); void show_bld_depends(const char *, package_t *); void show_index(const char *, const char *); void show_summary(struct pkg_meta *, package_t *, const char *); +void show_list(lpkg_head_t *, const char *); int pkg_perform(lpkg_head_t *); diff --git a/pkgtools/pkg_install/files/info/main.c b/pkgtools/pkg_install/files/info/main.c index 6736f2e8754..b75ad227af2 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.24 2009/02/28 16:03:56 joerg Exp $ */ +/* $NetBSD: main.c,v 1.25 2009/03/02 17:13:49 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.24 2009/02/28 16:03:56 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.25 2009/03/02 17:13:49 joerg Exp $"); /* * @@ -44,7 +44,7 @@ __RCSID("$NetBSD: main.c,v 1.24 2009/02/28 16:03:56 joerg Exp $"); #include "lib.h" #include "info.h" -static const char Options[] = ".aBbcDde:E:fFhIiK:kLl:mNnpQ:qRsSuvVX"; +static const char Options[] = ".aBbcDde:E:fFhIiK:kLl:mNnpQ:qrRsSuvVX"; int Flags = 0; enum which Which = WHICH_LIST; @@ -61,7 +61,7 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: pkg_info [-BbcDdFfhIikLmNnpqRSsVvX] [-e package] [-E package]", + "usage: pkg_info [-BbcDdFfhIikLmNnpqrRSsVvX] [-e package] [-E package]", " [-K pkg_dbdir] [-l prefix] pkg-name ...", " pkg_info [-a | -u] [flags]", " pkg_info [-Q variable] pkg-name ..."); @@ -172,6 +172,10 @@ main(int argc, char **argv) Quiet = TRUE; break; + case 'r': + Flags |= SHOW_FULL_REQBY; + break; + case 'R': Flags |= SHOW_REQBY; break; diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index 812fc2aa438..5f605dd2ed3 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.52 2009/02/25 20:52:10 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.53 2009/03/02 17:13:49 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -13,7 +13,7 @@ #if HAVE_SYS_WAIT_H #include <sys/wait.h> #endif -__RCSID("$NetBSD: perform.c,v 1.52 2009/02/25 20:52:10 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.53 2009/03/02 17:13:49 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -234,6 +234,7 @@ has_entry: } archive_read_finish(archive); + meta->is_installed = 0; return meta; } @@ -279,9 +280,50 @@ read_meta_data_from_pkgdb(const char *pkg) close(fd); } + meta->is_installed = 1; + return meta; } +static void +build_full_reqby(lpkg_head_t *reqby, struct pkg_meta *meta) +{ + char *iter, *eol, *next; + lpkg_t *lpp; + struct pkg_meta *meta_dep; + + if (meta->is_installed == 0 || meta->meta_required_by == NULL) + return; + + for (iter = meta->meta_required_by; *iter != '\0'; iter = next) { + eol = iter + strcspn(iter, "\n"); + if (*eol == '\n') + next = eol + 1; + else + next = eol; + if (iter == eol) + continue; + TAILQ_FOREACH(lpp, reqby, lp_link) { + if (strlen(lpp->lp_name) != eol - iter) + continue; + if (memcmp(lpp->lp_name, iter, eol - iter) == 0) + break; + } + if (lpp != NULL) + continue; + *eol = '\0'; + lpp = alloc_lpkg(iter); + if (next != eol) + *eol = '\n'; + TAILQ_INSERT_TAIL(reqby, lpp, lp_link); + meta_dep = read_meta_data_from_pkgdb(lpp->lp_name); + if (meta_dep == NULL) + continue; + build_full_reqby(reqby, meta_dep); + free_pkg_meta(meta_dep); + } +} + static lfile_head_t files; static int @@ -396,6 +438,12 @@ pkg_do(const char *pkg) if ((Flags & SHOW_REQBY) && meta->meta_required_by) { show_file(meta->meta_required_by, "Required by:\n", TRUE); } + if ((Flags & SHOW_FULL_REQBY) && meta->is_installed) { + lpkg_head_t reqby; + TAILQ_INIT(&reqby); + build_full_reqby(&reqby, meta); + show_list(&reqby, "Full required by list:\n"); + } if (Flags & SHOW_DESC) { show_file(meta->meta_desc, "Description:\n", TRUE); } @@ -587,7 +635,7 @@ pkg_perform(lpkg_head_t *pkghead) desired_meta_data |= LOAD_SIZE_ALL; if (Flags & (SHOW_SUMMARY | SHOW_DESC)) desired_meta_data |= LOAD_DESC; - if (Flags & SHOW_REQBY) + if (Flags & (SHOW_REQBY | SHOW_FULL_REQBY)) desired_meta_data |= LOAD_REQUIRED_BY; if (Flags & SHOW_DISPLAY) desired_meta_data |= LOAD_DISPLAY; diff --git a/pkgtools/pkg_install/files/info/pkg_info.1 b/pkgtools/pkg_install/files/info/pkg_info.1 index 89676dc8ad2..df22fbf626a 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.23 2009/02/28 16:03:56 joerg Exp $ +.\" $NetBSD: pkg_info.1,v 1.24 2009/03/02 17:13:49 joerg Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -17,7 +17,7 @@ .\" .\" @(#)pkg_info.1 .\" -.Dd February 27, 2009 +.Dd March 2, 2009 .Dt PKG_INFO 1 .Os .Sh NAME @@ -25,7 +25,7 @@ .Nd a utility for displaying information on software packages .Sh SYNOPSIS .Nm -.Op Fl BbcDdFfhIikLmNnpqRSsVvX +.Op Fl BbcDdFfhIikLmNnpqrRSsVvX .Op Fl e Ar package .Op Fl E Ar package .Op Fl K Ar pkg_dbdir @@ -176,6 +176,9 @@ in emitting report headers and such, just dump the raw info (basically, assume a non-human reading). .It Fl R For each package, show the packages that require it. +.It Fl r +For each package, show the packages that require it. +Continue recursively to show all dependents. .It Fl S Show the size of this package and all the packages it requires, in bytes. diff --git a/pkgtools/pkg_install/files/info/pkg_info.cat1 b/pkgtools/pkg_install/files/info/pkg_info.cat1 index 1e6a42b93d8..ecfd7b20c4c 100644 --- a/pkgtools/pkg_install/files/info/pkg_info.cat1 +++ b/pkgtools/pkg_install/files/info/pkg_info.cat1 @@ -4,7 +4,7 @@ NNAAMMEE ppkkgg__iinnffoo -- a utility for displaying information on software packages SSYYNNOOPPSSIISS - ppkkgg__iinnffoo [--BBbbccDDddFFffhhIIiikkLLmmNNnnppqqRRSSssVVvvXX] [--ee _p_a_c_k_a_g_e] [--EE _p_a_c_k_a_g_e] + ppkkgg__iinnffoo [--BBbbccDDddFFffhhIIiikkLLmmNNnnppqqrrRRSSssVVvvXX] [--ee _p_a_c_k_a_g_e] [--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 | --uu] [flags] ppkkgg__iinnffoo [--QQ _v_a_r_i_a_b_l_e] _p_k_g_-_n_a_m_e _._._. @@ -107,6 +107,8 @@ DDEESSCCRRIIPPTTIIOONN --RR For each package, show the packages that require it. + --rr For each package, recursively show the packages that require it. + --SS Show the size of this package and all the packages it requires, in bytes. @@ -184,4 +186,4 @@ AAUUTTHHOORRSS NetBSD wildcard dependency processing, pkgdb, depends displaying, pkg size display etc. -NetBSD 5.0 February 27, 2009 NetBSD 5.0 +NetBSD 5.0 March 2, 2009 NetBSD 5.0 diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c index c3d6f6f873c..b6371065866 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.24 2009/02/11 23:51:30 joerg Exp $ */ +/* $NetBSD: show.c,v 1.25 2009/03/02 17:13:49 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: show.c,v 1.24 2009/02/11 23:51:30 joerg Exp $"); +__RCSID("$NetBSD: show.c,v 1.25 2009/03/02 17:13:49 joerg Exp $"); /* * FreeBSD install - a package for the installation and maintainance @@ -405,3 +405,21 @@ print_string_as_var(const char *var, const char *str) return 0; } + +void +show_list(lpkg_head_t *pkghead, const char *title) +{ + lpkg_t *lpp; + + if (!Quiet) + printf("%s%s", InfoPrefix, title); + + while ((lpp = TAILQ_FIRST(pkghead)) != NULL) { + TAILQ_REMOVE(pkghead, lpp, lp_link); + puts(lpp->lp_name); + free_lpkg(lpp); + } + + if (!Quiet) + printf("\n"); +} diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 56b682760fb..d8962aa240c 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.116 2009/03/02 14:59:14 joerg Exp $ */ +/* $NetBSD: version.h,v 1.117 2009/03/02 17:13:49 joerg Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION "20090301" +#define PKGTOOLS_VERSION "20090302" #endif /* _INST_LIB_VERSION_H_ */ |