Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add support for displaying info about shared libs provided by packages as well as those required by packages.
Matthew Seaman committed 13 years ago
commit cc23cbe61fdf213e9ea3745aed05ae93e18f3ca4
parent e65f729
6 files changed +103 -65
modified pkg/info.c
@@ -50,8 +50,8 @@ usage_info(void)
{
	fprintf(stderr, "usage: pkg info <pkg-name>\n");
	fprintf(stderr, "       pkg info -a\n");
-
	fprintf(stderr, "       pkg info [-BDdefgiIklOqRrsx] <pkg-name>\n");
-
	fprintf(stderr, "       pkg info [-BDdfIlqRrs] -F <pkg-file>\n\n");
+
	fprintf(stderr, "       pkg info [-bBDdefgiIklOqRrsx] <pkg-name>\n");
+
	fprintf(stderr, "       pkg info [-bBDdfIlqRrs] -F <pkg-file>\n\n");
	fprintf(stderr, "For more information see 'pkg help info'.\n");
}

@@ -83,7 +83,7 @@ exec_info(int argc, char **argv)
	bool origin_search = false;

	/* TODO: exclusive opts ? */
-
	while ((ch = getopt(argc, argv, "aDegixEIdrklBsqopOfF:R")) != -1) {
+
	while ((ch = getopt(argc, argv, "aDegixEIdrklbBsqopOfF:R")) != -1) {
		switch (ch) {
		case 'a':
			match = MATCH_ALL;
@@ -122,8 +122,11 @@ exec_info(int argc, char **argv)
		case 'l':
			opt |= INFO_FILES;
			break;
+
		case 'b':
+
			opt |= INFO_SHLIBS_PROVIDED;
+
			break;
		case 'B':
-
			opt |= INFO_SHLIBS;
+
			opt |= INFO_SHLIBS_REQUIRED;
			break;
		case 's':
			opt |= INFO_FLATSIZE;
modified pkg/pkg-info.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 25, 2013
+
.Dd March 3, 2013
.Dt PKG-INFO 8
.Os
.Sh NAME
@@ -27,10 +27,10 @@
.Nm
.Fl a
.Nm
-
.Op Fl BDdefgiIklOqRrsx
+
.Op Fl bBDdefgiIklOqRrsx
.Ar <pkg-name>
.Nm
-
.Op Fl BDdfIlqRrs
+
.Op Fl bBDdfIlqRrs
.Fl F Ar <pkg-file>
.Sh DESCRIPTION
.Nm
@@ -91,6 +91,9 @@ is queried.
.It Fl l
Display all files installed by
.Ar <pkg-name> .
+
.It Fl b
+
Display all shared libraries provided by
+
.Ar <pkg-name> .
.It Fl B
Display all shared libraries used by
.Ar <pkg-name> .
modified pkg/pkg-search.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 25, 2013
+
.Dd March 3, 2013
.Dt PKG-SEARCH 8
.Os
.Sh NAME
@@ -282,7 +282,8 @@ Show a standard set of fields, equivalent to a combination of the
.Sy www ,
.Sy comment ,
.Sy options ,
-
.Sy shared-libs ,
+
.Sy shared-libs-required ,
+
.Sy shared-libs-provided ,
.Sy size ,
.Sy pkg-size
and
@@ -336,7 +337,8 @@ one per line.
If the no other packages require the named package, nothing will be
output for this field, including suppressing the tag name when
multiple output fields are requested.
-
.It Sy shared-libs
+

+
.It Sy shared-libs-required
If the package contains dynamically linked FreeBSD ELF binaries,
display a list of all of the shared libraries other than those from
the base system required for those binaries to run.
@@ -345,6 +347,12 @@ under emulation will not be displayed.
If the package does not require any shared libraries, nothing will be
output for this field including suppressing the tag name when multiple
fields are requested.
+
.It Sy shared-libs-provided
+
If the package contains any shared libraries, display a list of
+
the library names, including the ABI version number, if any.
+
A shared library, of either the same or differing ABI versions, may
+
legitimately be provided by more than installed package, 
+
but this generally indicates a problem.
.It Sy size
Display the total amount of filesystem space the package files will
take up once unpacked and installed.
@@ -374,7 +382,14 @@ and
to distinguish
.Cm size
from
-
.Cm shared-libs .
+
.Cm shared-libs-required
+
or
+
.Cm shared-libs-provided ,
+
and you'll need at least
+
.FL "Q shared-libs-p"
+
 to select the
+
.Cm shared-libs-provided
+
unambiguously.
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm .
modified pkg/pkgcli.h
@@ -165,33 +165,34 @@ void usage_convert(void);
/* utils */

/* These are the fields of the Full output, in order */
-
#define INFO_NAME	(1<<0)
-
#define INFO_VERSION	(1<<1)
-
#define INFO_ORIGIN	(1<<2)
-
#define INFO_PREFIX	(1<<3)
-
#define INFO_REPOSITORY	(1<<4)
-
#define INFO_CATEGORIES	(1<<5)
-
#define INFO_LICENSES	(1<<6)
-
#define INFO_MAINTAINER	(1<<7)
-
#define INFO_WWW	(1<<8)
-
#define INFO_COMMENT	(1<<9)
-
#define INFO_OPTIONS	(1<<10)
-
#define INFO_SHLIBS	(1<<11)
-
#define INFO_FLATSIZE	(1<<12)
-
#define INFO_PKGSIZE	(1<<13)
-
#define INFO_DESCR	(1<<14)
+
#define INFO_NAME		(1<<0)
+
#define INFO_VERSION		(1<<1)
+
#define INFO_ORIGIN		(1<<2)
+
#define INFO_PREFIX		(1<<3)
+
#define INFO_REPOSITORY		(1<<4)
+
#define INFO_CATEGORIES		(1<<5)
+
#define INFO_LICENSES		(1<<6)
+
#define INFO_MAINTAINER		(1<<7)
+
#define INFO_WWW		(1<<8)
+
#define INFO_COMMENT		(1<<9)
+
#define INFO_OPTIONS		(1<<10)
+
#define INFO_SHLIBS_REQUIRED	(1<<11)
+
#define INFO_SHLIBS_PROVIDED	(1<<12)
+
#define INFO_FLATSIZE		(1<<13)
+
#define INFO_PKGSIZE		(1<<14)
+
#define INFO_DESCR		(1<<15)

/* Other fields not part of the Full output */
-
#define INFO_MESSAGE	(1<<15)
-
#define INFO_DEPS	(1<<16)
-
#define INFO_RDEPS	(1<<17)
-
#define INFO_FILES	(1<<18)
-
#define INFO_DIRS	(1<<19)
-
#define INFO_USERS	(1<<20)
-
#define INFO_GROUPS	(1<<21)
-
#define INFO_ARCH	(1<<22)
-
#define INFO_REPOURL	(1<<23)
-
#define INFO_LOCKED	(1<<24)
+
#define INFO_MESSAGE		(1<<16)
+
#define INFO_DEPS		(1<<17)
+
#define INFO_RDEPS		(1<<18)
+
#define INFO_FILES		(1<<19)
+
#define INFO_DIRS		(1<<20)
+
#define INFO_USERS		(1<<21)
+
#define INFO_GROUPS		(1<<22)
+
#define INFO_ARCH		(1<<23)
+
#define INFO_REPOURL		(1<<24)
+
#define INFO_LOCKED		(1<<25)

#define INFO_LASTFIELD	INFO_LOCKED
#define INFO_ALL	(((INFO_LASTFIELD) << 1) - 1)
@@ -206,13 +207,15 @@ void usage_convert(void);

/* Everything in the 'full' package output */
#define INFO_FULL	(INFO_NAME|INFO_VERSION|INFO_ORIGIN|INFO_PREFIX| \
-
			 INFO_REPOSITORY|INFO_CATEGORIES|INFO_LICENSES|  \
-
			 INFO_MAINTAINER|INFO_WWW|INFO_COMMENT|          \
-
			 INFO_OPTIONS|INFO_SHLIBS|INFO_FLATSIZE|         \
+
			 INFO_REPOSITORY|INFO_CATEGORIES|INFO_LICENSES|	 \
+
			 INFO_MAINTAINER|INFO_WWW|INFO_COMMENT|		 \
+
			 INFO_OPTIONS|INFO_SHLIBS_REQUIRED|		 \
+
			 INFO_SHLIBS_PROVIDED|INFO_FLATSIZE|		 \
			 INFO_PKGSIZE|INFO_DESCR)

/* Everything that can take more than one line to print */
-
#define INFO_MULTILINE	(INFO_OPTIONS|INFO_SHLIBS|INFO_DESCR|INFO_MESSAGE| \
+
#define INFO_MULTILINE	(INFO_OPTIONS|INFO_SHLIBS_REQUIRED|	       \
+
			 INFO_SHLIBS_PROVIDED|INFO_DESCR|INFO_MESSAGE| \
			 INFO_DEPS|INFO_RDEPS|INFO_FILES|INFO_DIRS)

bool query_yesno(const char *msg, ...);
modified pkg/search.c
@@ -52,25 +52,26 @@ static const cliopt search_label[] = {
};

static const cliopt modifiers[] = {
-
	{ "arch",         'a'  },
-
	{ "categories",   'C'  },
-
	{ "comment",      'c'  },
-
	{ "depends-on",   'd'  },
-
	{ "description",  'D'  },
-
	{ "full",         'f'  },
-
	{ "licenses",     'l'  },
-
	{ "maintainer",   'm'  },
-
	{ "name",         'n'  },
-
	{ "options",      'o'  },
-
	{ "pkg-size",	  'P'  },
-
	{ "prefix",       'p'  },
-
	{ "repository",   'R'  },
-
	{ "required-by",  'r'  },
-
	{ "shared-libs",  'S'  },
-
	{ "size",         's'  },
-
	{ "url",          'u'  },
-
	{ "www",          'w'  },
-
	{ NULL,           '\0' },
+
	{ "arch",                 'a'  },
+
	{ "categories",           'C'  },
+
	{ "comment",              'c'  },
+
	{ "depends-on",           'd'  },
+
	{ "description",          'D'  },
+
	{ "full",                 'f'  },
+
	{ "licenses",             'l'  },
+
	{ "maintainer",           'm'  },
+
	{ "name",                 'n'  },
+
	{ "options",              'o'  },
+
	{ "pkg-size",	          'P'  },
+
	{ "prefix",               'p'  },
+
	{ "repository",           'R'  },
+
	{ "required-by",          'r'  },
+
	{ "shared-libs-required", 'B'  },
+
	{ "shared-libs-provided", 'b'  },
+
	{ "size",                 's'  },
+
	{ "url",                  'u'  },
+
	{ "www",                  'w'  },
+
	{ NULL,                   '\0' },
};	

static char
@@ -178,8 +179,11 @@ modifier_opt(const char *optionarg)
	case 'r':
		opt = INFO_RDEPS;
		break;
-
	case 'S':
-
		opt = INFO_SHLIBS;
+
	case 'B':
+
		opt = INFO_SHLIBS_REQUIRED;
+
		break;
+
	case 'b':
+
		opt = INFO_SHLIBS_PROVIDED;
		break;
	case 's':
		opt = INFO_FLATSIZE;
@@ -207,7 +211,7 @@ usage_search(void)
	int i, n;

	fprintf(stderr, "usage: pkg search [-egix] [-r repo] [-S search] "
-
	    "[-L label] [-M mod]... <pkg-name>\n");
+
	    "[-L label] [-Q mod]... <pkg-name>\n");
	fprintf(stderr, "       pkg search [-cDdefgiopqx] [-r repo] "
	    "<pattern>\n\n");
	n = fprintf(stderr, "       Search and Label options:");
modified pkg/utils.c
@@ -143,8 +143,10 @@ info_flags(unsigned int opt)
		flags |= PKG_LOAD_LICENSES;
	if (opt & INFO_OPTIONS)
		flags |= PKG_LOAD_OPTIONS;
-
	if (opt & INFO_SHLIBS)
+
	if (opt & INFO_SHLIBS_REQUIRED)
		flags |= PKG_LOAD_SHLIBS_REQUIRED;
+
	if (opt & INFO_SHLIBS_PROVIDED)
+
		flags |= PKG_LOAD_SHLIBS_PROVIDED;
	if (opt & INFO_DEPS)
		flags |= PKG_LOAD_DEPS;
	if (opt & INFO_RDEPS)
@@ -382,14 +384,22 @@ print_info(struct pkg * const pkg, unsigned int options)
					       pkg_option_value(option));
			}
			break;
-
		case INFO_SHLIBS:
+
		case INFO_SHLIBS_REQUIRED:
			if (pkg_list_count(pkg, PKG_SHLIBS_REQUIRED) > 0) {
				if (print_tag)
-
					printf("%-15s:\n", "Shared Libs");
+
					printf("%-15s:\n", "Shared Libs required");
				while (pkg_shlibs_required(pkg, &shlib) == EPKG_OK)
					printf("%s%s\n", tab, pkg_shlib_name(shlib));
			}
			break;
+
		case INFO_SHLIBS_PROVIDED:
+
			if (pkg_list_count(pkg, PKG_SHLIBS_PROVIDED) > 0) {
+
				if (print_tag)
+
					printf("%-15s:\n", "Shared Libs provided");
+
				while (pkg_shlibs_provided(pkg, &shlib) == EPKG_OK)
+
					printf("%s%s\n", tab, pkg_shlib_name(shlib));
+
			}
+
			break;
		case INFO_FLATSIZE:
			if (pkg_type(pkg) == PKG_INSTALLED ||
			    pkg_type(pkg) == PKG_FILE)