2003-09-02 11:34:47 +04:00
|
|
|
/* $NetBSD: show.c,v 1.27 2003/09/02 07:34:59 jlam Exp $ */
|
1997-06-05 16:59:18 +04:00
|
|
|
|
1997-10-17 18:53:18 +04:00
|
|
|
#include <sys/cdefs.h>
|
1997-06-05 12:54:23 +04:00
|
|
|
#ifndef lint
|
1997-06-05 16:59:18 +04:00
|
|
|
#if 0
|
1997-10-16 04:31:32 +04:00
|
|
|
static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
|
1997-06-05 16:59:18 +04:00
|
|
|
#else
|
2003-09-02 11:34:47 +04:00
|
|
|
__RCSID("$NetBSD: show.c,v 1.27 2003/09/02 07:34:59 jlam Exp $");
|
1997-06-05 16:59:18 +04:00
|
|
|
#endif
|
1997-06-05 12:54:23 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 23 Aug 1993
|
|
|
|
*
|
|
|
|
* Various display routines for the info module.
|
|
|
|
*
|
|
|
|
*/
|
1999-03-04 03:35:05 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Hubert Feyrer. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
2000-02-22 04:24:26 +03:00
|
|
|
* This product includes software developed by Hubert Feyrer for
|
|
|
|
* the NetBSD Project.
|
1999-03-04 03:35:05 +03:00
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1997-10-17 18:53:18 +04:00
|
|
|
#include <err.h>
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
#include "lib.h"
|
|
|
|
#include "info.h"
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/* Structure to define entries for the "show table" */
|
1998-10-09 15:05:58 +04:00
|
|
|
typedef struct show_t {
|
1999-08-24 04:48:37 +04:00
|
|
|
pl_ent_t sh_type; /* type of entry */
|
|
|
|
char *sh_quiet; /* message when quiet */
|
|
|
|
char *sh_verbose; /* message when verbose */
|
|
|
|
} show_t;
|
1998-10-09 15:05:58 +04:00
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/*
|
|
|
|
* The entries in this table must be ordered the same as
|
|
|
|
* pl_ent_t constants
|
|
|
|
*/
|
2002-06-09 18:14:49 +04:00
|
|
|
static const show_t showv[] = {
|
1999-12-01 17:51:50 +03:00
|
|
|
{PLIST_FILE, "%s", "\tFile: %s"},
|
1999-08-24 04:48:37 +04:00
|
|
|
{PLIST_CWD, "@cwd %s", "\tCWD to: %s"},
|
|
|
|
{PLIST_CMD, "@exec %s", "\tEXEC '%s'"},
|
|
|
|
{PLIST_CHMOD, "@chmod %s", "\tCHMOD to %s"},
|
|
|
|
{PLIST_CHOWN, "@chown %s", "\tCHOWN to %s"},
|
|
|
|
{PLIST_CHGRP, "@chgrp %s", "\tCHGRP to %s"},
|
|
|
|
{PLIST_COMMENT, "@comment %s", "\tComment: %s"},
|
1999-12-01 17:51:50 +03:00
|
|
|
{PLIST_IGNORE, "@ignore", "Ignore next file:"},
|
1999-08-24 04:48:37 +04:00
|
|
|
{PLIST_NAME, "@name %s", "\tPackage name: %s"},
|
|
|
|
{PLIST_UNEXEC, "@unexec %s", "\tUNEXEC '%s'"},
|
1999-11-29 23:09:54 +03:00
|
|
|
{PLIST_SRC, "@src: %s", "\tSRC to: %s"},
|
1999-08-24 04:48:37 +04:00
|
|
|
{PLIST_DISPLAY, "@display %s", "\tInstall message file: %s"},
|
|
|
|
{PLIST_PKGDEP, "@pkgdep %s", "\tPackage depends on: %s"},
|
|
|
|
{PLIST_MTREE, "@mtree %s", "\tPackage mtree file: %s"},
|
|
|
|
{PLIST_DIR_RM, "@dirrm %s", "\tDeinstall directory remove: %s"},
|
|
|
|
{PLIST_IGNORE_INST, "@ignore_inst ??? doesn't belong here",
|
|
|
|
"\tIgnore next file installation directive (doesn't belong)"},
|
|
|
|
{PLIST_OPTION, "@option %s", "\tPackage has option: %s"},
|
|
|
|
{PLIST_PKGCFL, "@pkgcfl %s", "\tPackage conflicts with: %s"},
|
2002-03-05 17:18:07 +03:00
|
|
|
{PLIST_BLDDEP, "@blddep %s", "\tPackage depends exactly on: %s"},
|
1999-08-24 04:48:37 +04:00
|
|
|
{-1, NULL, NULL}
|
1998-10-09 15:05:58 +04:00
|
|
|
};
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
void
|
|
|
|
show_file(char *title, char *fname)
|
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
FILE *fp;
|
|
|
|
char line[1024];
|
|
|
|
int n;
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1998-10-09 15:05:58 +04:00
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
|
|
|
}
|
|
|
|
if ((fp = fopen(fname, "r")) == (FILE *) NULL) {
|
|
|
|
printf("ERROR: show_file: Can't open '%s' for reading!\n", fname);
|
|
|
|
} else {
|
2002-07-20 08:59:47 +04:00
|
|
|
int append_nl = 0;
|
2002-06-09 07:32:45 +04:00
|
|
|
while ((n = fread(line, 1, sizeof(line), fp)) != 0) {
|
1998-10-09 15:05:58 +04:00
|
|
|
fwrite(line, 1, n, stdout);
|
2002-07-20 08:59:47 +04:00
|
|
|
append_nl = (line[n - 1] != '\n');
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
|
|
|
(void) fclose(fp);
|
2002-07-20 08:59:47 +04:00
|
|
|
if (append_nl)
|
|
|
|
printf("\n");
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
printf("\n"); /* just in case */
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
show_index(char *title, char *fname)
|
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
FILE *fp;
|
|
|
|
char *line;
|
|
|
|
size_t linelen;
|
|
|
|
size_t maxline = termwidth;
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1998-10-09 15:05:58 +04:00
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
1998-12-31 03:04:07 +03:00
|
|
|
maxline -= MAXNAMESIZE;
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
|
|
|
if ((fp = fopen(fname, "r")) == (FILE *) NULL) {
|
|
|
|
warnx("show_file: can't open '%s' for reading", fname);
|
|
|
|
return;
|
|
|
|
}
|
1998-12-31 03:04:07 +03:00
|
|
|
if ((line = fgetln(fp, &linelen))) {
|
1999-08-24 04:48:37 +04:00
|
|
|
line[linelen - 1] = '\0'; /* tromp newline & terminate string */
|
1998-12-31 03:04:07 +03:00
|
|
|
if (termwidth && (linelen > maxline)) {
|
|
|
|
/* XXX -1 if term does NOT have xn (or xenl) quirk */
|
|
|
|
line[maxline] = '\0';
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
1998-12-31 03:04:07 +03:00
|
|
|
(void) printf("%s\n", line);
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
|
|
|
(void) fclose(fp);
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/*
|
|
|
|
* Show a packing list item type. If type is PLIST_SHOW_ALL, show all
|
|
|
|
*/
|
1997-06-05 12:54:23 +04:00
|
|
|
void
|
1998-10-09 22:27:31 +04:00
|
|
|
show_plist(char *title, package_t *plist, pl_ent_t type)
|
1997-06-05 12:54:23 +04:00
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
plist_t *p;
|
|
|
|
Boolean ign;
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
|
|
|
}
|
|
|
|
for (ign = FALSE, p = plist->head; p; p = p->next) {
|
|
|
|
if (p->type == type || type == PLIST_SHOW_ALL) {
|
|
|
|
switch (p->type) {
|
|
|
|
case PLIST_FILE:
|
|
|
|
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, p->name);
|
|
|
|
if (ign) {
|
|
|
|
if (!Quiet) {
|
|
|
|
printf(" (ignored)");
|
|
|
|
}
|
|
|
|
ign = FALSE;
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
break;
|
|
|
|
case PLIST_CHMOD:
|
|
|
|
case PLIST_CHOWN:
|
|
|
|
case PLIST_CHGRP:
|
|
|
|
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose,
|
|
|
|
p->name ? p->name : "(clear default)");
|
|
|
|
break;
|
|
|
|
case PLIST_IGNORE:
|
1999-12-01 17:51:50 +03:00
|
|
|
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose);
|
1999-08-24 04:48:37 +04:00
|
|
|
ign = TRUE;
|
|
|
|
break;
|
|
|
|
case PLIST_IGNORE_INST:
|
|
|
|
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, p->name);
|
|
|
|
ign = TRUE;
|
|
|
|
break;
|
|
|
|
case PLIST_CWD:
|
|
|
|
case PLIST_CMD:
|
1999-11-29 23:09:54 +03:00
|
|
|
case PLIST_SRC:
|
1999-08-24 04:48:37 +04:00
|
|
|
case PLIST_UNEXEC:
|
|
|
|
case PLIST_COMMENT:
|
|
|
|
case PLIST_NAME:
|
|
|
|
case PLIST_DISPLAY:
|
|
|
|
case PLIST_PKGDEP:
|
|
|
|
case PLIST_MTREE:
|
|
|
|
case PLIST_DIR_RM:
|
|
|
|
case PLIST_OPTION:
|
|
|
|
case PLIST_PKGCFL:
|
2002-03-05 17:18:07 +03:00
|
|
|
case PLIST_BLDDEP:
|
1999-08-24 04:48:37 +04:00
|
|
|
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, p->name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warnx("unknown command type %d (%s)", p->type, p->name);
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
(void) fputc('\n', stdout);
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/*
|
|
|
|
* Show all files in the packing list (except ignored ones)
|
|
|
|
*/
|
1997-06-05 12:54:23 +04:00
|
|
|
void
|
1998-10-09 22:27:31 +04:00
|
|
|
show_files(char *title, package_t *plist)
|
1997-06-05 12:54:23 +04:00
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
plist_t *p;
|
|
|
|
Boolean ign;
|
|
|
|
char *dir = ".";
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1998-10-09 15:05:58 +04:00
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
for (ign = FALSE, p = plist->head; p; p = p->next) {
|
|
|
|
switch (p->type) {
|
1998-10-09 15:05:58 +04:00
|
|
|
case PLIST_FILE:
|
|
|
|
if (!ign) {
|
2003-06-05 21:58:05 +04:00
|
|
|
printf("%s%s%s\n", dir,
|
|
|
|
(strcmp(dir, "/") == 0) ? "" : "/", p->name);
|
1998-10-09 15:05:58 +04:00
|
|
|
}
|
|
|
|
ign = FALSE;
|
|
|
|
break;
|
|
|
|
case PLIST_CWD:
|
|
|
|
dir = p->name;
|
|
|
|
break;
|
|
|
|
case PLIST_IGNORE:
|
|
|
|
ign = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
}
|
1999-03-04 03:35:05 +03:00
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/*
|
|
|
|
* Show dependencies (packages this pkg requires)
|
|
|
|
*/
|
1999-03-04 03:35:05 +03:00
|
|
|
void
|
|
|
|
show_depends(char *title, package_t *plist)
|
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
plist_t *p;
|
|
|
|
int nodepends;
|
1999-03-04 03:35:05 +03:00
|
|
|
|
|
|
|
nodepends = 1;
|
|
|
|
for (p = plist->head; p && nodepends; p = p->next) {
|
1999-08-24 04:48:37 +04:00
|
|
|
switch (p->type) {
|
1999-03-04 03:35:05 +03:00
|
|
|
case PLIST_PKGDEP:
|
|
|
|
nodepends = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nodepends)
|
1999-08-24 04:48:37 +04:00
|
|
|
return;
|
|
|
|
|
1999-03-04 04:45:22 +03:00
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
for (p = plist->head; p; p = p->next) {
|
|
|
|
switch (p->type) {
|
1999-03-04 03:35:05 +03:00
|
|
|
case PLIST_PKGDEP:
|
1999-08-24 04:48:37 +04:00
|
|
|
printf("%s\n", p->name);
|
1999-03-04 03:35:05 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-08-24 04:48:37 +04:00
|
|
|
|
1999-03-04 03:35:05 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
2003-09-02 11:34:47 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Show exact dependencies (packages this pkg was built with)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
show_bld_depends(char *title, package_t *plist)
|
|
|
|
{
|
|
|
|
plist_t *p;
|
|
|
|
int nodepends;
|
|
|
|
|
|
|
|
nodepends = 1;
|
|
|
|
for (p = plist->head; p && nodepends; p = p->next) {
|
|
|
|
switch (p->type) {
|
|
|
|
case PLIST_BLDDEP:
|
|
|
|
nodepends = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nodepends)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Quiet) {
|
|
|
|
printf("%s%s", InfoPrefix, title);
|
|
|
|
}
|
|
|
|
for (p = plist->head; p; p = p->next) {
|
|
|
|
switch (p->type) {
|
|
|
|
case PLIST_BLDDEP:
|
|
|
|
printf("%s\n", p->name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|