1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

Added two new options, one of which is fairly far reaching:

-q	turns on "quiet" mode, where informational headers and such are not
	dumped, just the information.

-L	Shows full pathnames of files comprising a package.  With -q,
	this can be useful for doing fileset operations, such as
	"du -s `pkg_info -q -L foo_bin`" to see how much space package
	"foo_bin" is taking up.
This commit is contained in:
Jordan K. Hubbard 1993-09-08 01:46:59 +00:00
parent 97eb5f5403
commit d23866636a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=411
5 changed files with 81 additions and 15 deletions

View File

@ -31,14 +31,17 @@
#define SHOW_REQUIRE 0x20
#define SHOW_PREFIX 0x40
#define SHOW_INDEX 0x80
#define SHOW_FILES 0x100
extern int Flags;
extern Boolean AllInstalled;
extern Boolean Quiet;
extern char *InfoPrefix;
extern char *PlayPen;
extern char *CheckPkg;
extern void show_file(char *, char *);
extern void show_plist(char *, Package *, plist_t);
extern void show_files(char *, Package *);
#endif /* _INST_INFO_H_INCLUDE */

View File

@ -26,10 +26,11 @@ static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.5 1993/
#include "lib.h"
#include "info.h"
static char Options[] = "acde:fikrpIvhl:";
static char Options[] = "acde:fikrpLqIvhl:";
int Flags = 0;
Boolean AllInstalled = FALSE;
Boolean Quiet = FALSE;
char *InfoPrefix = "";
char *PlayPen = NULL;
char *CheckPkg = NULL;
@ -87,10 +88,18 @@ main(int argc, char **argv)
Flags |= SHOW_REQUIRE;
break;
case 'L':
Flags |= SHOW_FILES;
break;
case 'l':
InfoPrefix = optarg;
break;
case 'q':
Quiet = TRUE;
break;
case 't':
PlayPen = optarg;
break;

View File

@ -125,7 +125,8 @@ pkg_do(char *pkg)
}
else {
/* Start showing the package contents */
printf("%sInformation for %s:\n\n", InfoPrefix, pkg);
if (!Quiet)
printf("%sInformation for %s:\n\n", InfoPrefix, pkg);
if (Flags & SHOW_COMMENT)
show_file("Comment:\n", COMMENT_FNAME);
if (Flags & SHOW_DESC)
@ -138,7 +139,10 @@ pkg_do(char *pkg)
show_file("De-Install script:\n", DEINSTALL_FNAME);
if (Flags & SHOW_PREFIX)
show_plist("Prefix(s):\n", &plist, PLIST_CWD);
puts(InfoPrefix);
if (Flags & SHOW_FILES)
show_files("Files:\n", &plist);
if (!Quiet)
puts(InfoPrefix);
}
free_plist(&plist);
leave_playpen();

View File

@ -48,12 +48,19 @@ Turns on verbose output.
.B \-p
Show the installation prefix for each package.
.TP
.B \-q
Be "quiet" in emitting report headers and such, just dump the
raw info (basically, assume a non-human reading).
.TP
.B \-c
Show the comment (one liner) field for each package.
.TP
.B \-d
Show the long description field for each package.
.TP
.B \-f
Show the packing list instructions for each package.
.TP
.B \-i
Show the install script (if any) for each package.
.TP
@ -63,6 +70,11 @@ Show the de-install script (if any) for each package.
.B \-r
Show the requirements script (if any) for each package.
.TP
.B \-L
Show the files within each package. This is different from just
viewing the packing list, since full pathnames for everything
are generated.
.TP
.BI "\-e\ " pkg-name
If the package identified by
.I pkg-name
@ -71,13 +83,16 @@ allows you to easily test for the presence of another (perhaps
prerequisite) package from a script.
.TP
.BI "\-l\ " str
Prefix each catagory of information shown with
Prefix each information catagory header (see
.I \-q)
shown with
.I str.
This is primarily of use to front-end programs who want to request a
lot of different information fields at once for a package, 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.
.TP
.BI "\-t\ " template
Use
.I template

View File

@ -32,7 +32,8 @@ show_file(char *title, char *fname)
char line[1024];
int n;
printf("%s%s", InfoPrefix, title);
if (!Quiet)
printf("%s%s", InfoPrefix, title);
fp = fopen(fname, "r");
if (!fp) {
whinge("show_file: Can't open '%s' for reading.", fname);
@ -51,7 +52,8 @@ show_plist(char *title, Package *plist, plist_t type)
PackingList p;
Boolean ign = FALSE;
printf("%s%s", InfoPrefix, title);
if (!Quiet)
printf("%s%s", InfoPrefix, title);
p = plist->head;
while (p) {
if (p->type != type && type != -1) {
@ -61,35 +63,38 @@ show_plist(char *title, Package *plist, plist_t type)
switch(p->type) {
case PLIST_FILE:
if (ign) {
printf("File: %s (ignored)\n", p->name);
printf(Quiet ? "%s\n" : "File: %s (ignored)\n", p->name);
ign = FALSE;
}
else
printf("File: %s\n", p->name);
printf(Quiet ? "%s\n" : "File: %s\n", p->name);
break;
case PLIST_CWD:
printf("\tCWD to %s\n", p->name);
printf(Quiet ? "@cwd %s\n" : "\tCWD to %s\n", p->name);
break;
case PLIST_CMD:
printf("\tEXEC '%s'\n", p->name);
printf(Quiet ? "@exec %s\n" : "\tEXEC '%s'\n", p->name);
break;
case PLIST_CHMOD:
printf("\tCHMOD to %s\n", p->name ? p->name : "(no default)");
printf(Quiet ? "@chmod %s\n" : "\tCHMOD to %s\n",
p->name ? p->name : "(clear default)");
break;
case PLIST_CHOWN:
printf("\tCHOWN to %s\n", p->name ? p->name : "(no default)");
printf(Quiet ? "@chown %s\n" : "\tCHOWN to %s\n",
p->name ? p->name : "(clear default)");
break;
case PLIST_CHGRP:
printf("\tCHGRP to %s\n", p->name ? p->name : "(no default)");
printf(Quiet ? "@chgrp %s\n" : "\tCHGRP to %s\n",
p->name ? p->name : "(clear default)");
break;
case PLIST_COMMENT:
printf("\tComment: %s\n", p->name);
printf(Quiet ? "@comment %s\n" : "\tComment: %s\n", p->name);
break;
case PLIST_IGNORE:
@ -97,7 +102,7 @@ show_plist(char *title, Package *plist, plist_t type)
break;
case PLIST_NAME:
printf("\tPackage name: %s\n", p->name);
printf(Quiet ? "@name %s\n" : "\tPackage name: %s\n", p->name);
break;
default:
@ -108,3 +113,33 @@ show_plist(char *title, Package *plist, plist_t type)
}
}
/* Show all files in the packing list (except ignored ones) */
void
show_files(char *title, Package *plist)
{
PackingList p;
Boolean ign = FALSE;
char *dir = ".";
if (!Quiet)
printf("%s%s", InfoPrefix, title);
p = plist->head;
while (p) {
switch(p->type) {
case PLIST_FILE:
if (!ign)
printf("%s/%s\n", dir, p->name);
ign = FALSE;
break;
case PLIST_CWD:
dir = p->name;
break;
case PLIST_IGNORE:
ign = TRUE;
break;
}
p = p->next;
}
}