pkginfo.c revision 9ab815e1e50104cb1004a5ccca7a6da582994b57
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#define __EXTENTIONS__
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>
#include <strings.h>
#include <string.h>
#include <dirent.h>
#include <pkginfo.h>
#include <fcntl.h>
#include <pkgstrct.h>
#include <pkglocs.h>
#include <errno.h>
#include <ctype.h>
#include <pkglib.h>
#include <instzones_api.h>
#include <libadm.h>
#include <libinst.h>
extern char *pkgdir;
#define ERR_USAGE "usage:\n" \
"%s [-q] [-pi] [-x|l] [options] [pkg ...]\n" \
"%s -d device [-q] [-x|l] [options] [pkg ...]\n" \
"where\n" \
" -q #quiet mode\n" \
" -p #select partially installed packages\n" \
" -i #select completely installed packages\n" \
" -x #extracted listing\n" \
" -l #long listing\n" \
" -r #relocation base \n" \
"and options may include:\n" \
" -c category, [category...]\n" \
" -a architecture\n" \
" -v version\n"
#define ERR_INCOMP0 "-L and -l/-x/-r flags are incompatible"
#define ERR_INCOMP1 "-l and -x/-r flags are not compatible"
#define ERR_INCOMP2 "-x and -l/-r flags are not compatible"
#define ERR_INCOMP3 "-r and -x/-x flags are not compatible"
#define ERR_NOINFO "ERROR: information for \"%s\" was not found"
#define ERR_NOPINFO "ERROR: No partial information for \"%s\" was found"
#define ERR_BADINFO "pkginfo file is corrupt or missing"
#define ERR_ROOT_SET "Could not set install root from the environment."
#define ERR_ROOT_CMD "Command line install root contends with environment."
/* Format for dumping package attributes in dumpinfo() */
#define FMT "%10s: %s\n"
#define SFMT "%-11.11s %-*.*s %s\n"
#define CFMT "%*.*s "
#define XFMT "%-*.*s %s\n"
#define MAXCATG 64
static char *parmlst[] = {
"DESC", "PSTAMP", "INSTDATE", "VSTOCK", "SERIALNUM", "HOTLINE",
"EMAIL", NULL
};
static int errflg = 0;
static int qflag = 0;
static int iflag = -1;
static int pflag = -1;
static int lflag = 0;
static int Lflag = 0;
static int Nflag = 0;
static int xflag = 0;
static int rflag = 0; /* bug # 1081606 */
static int pkgcnt = 0;
static int ncatg = 0;
static struct cfstat {
char pkginst[32];
short exec;
short dirs;
short link;
short partial;
long spooled;
long installed;
short info;
short shared;
short setuid;
long tblks;
} *data;
static int selectp(char *p);
static void usage(void), look_for_installed(void),
report(void), rdcontents(void);
int
{
int c;
/* initialize locale mechanism */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
/* determine program name */
(void) set_prog_name(argv[0]);
/* tell spmi zones interface how to access package output functions */
/* establish installation root directory */
exit(1);
}
switch (c) {
case 'v':
break;
case 'a':
break;
case 'd':
/* -d could specify stream or mountable device */
break;
case 'q':
qflag++;
break;
case 'i':
iflag = 1;
if (pflag > 0)
usage();
pflag = 0;
break;
case 'p':
pflag = 1;
if (iflag > 0)
usage();
iflag = 0;
break;
case 'N':
Nflag++;
break;
case 'L':
usage();
}
Lflag++;
break;
case 'l':
usage();
}
lflag++;
break;
case 'x':
/* bug # 1081606 */
usage();
}
xflag++;
break;
case 'r':
usage();
}
rflag++;
break;
case 'c':
ncatg++;
break;
/* added for newroot functions */
case 'R':
if (!set_inst_root(optarg)) {
exit(1);
}
break;
default:
usage();
}
}
/*
* implement the newroot option
*/
/*
* Open the install DB, if one exists.
*/
pkgcnt = 0;
}
/* convert device appropriately */
exit(1);
/*
* If we are to inspect a spooled package we are only interested in
* the pkginfo file in the spooled pkg. We have a spooled pkg if
* device is not NULL.
*/
/* look at contents file */
rdcontents();
}
/*
* If we are to inspect a spooled package we are only interested in
* the pkginfo file in the spooled pkg so we skip any Reg 4 DB
* lookups and use the old algorithm. We have a spooled pkg if
* device is not NULL.
*/
report();
return (errflg ? 1 : 0);
}
static void
report(void)
{
int i;
int pkgLgth = 0;
int longestPkg = 0;
for (;;) {
if (pkgLgth > longestPkg)
}
/* get information about this package */
continue; /* already used */
break;
} else if (!choice ||
}
if (!choice)
break; /* no more packages */
continue;
}
/*
* Confirm that the pkginfo file contains the
* required information.
*/
errflg++;
return;
}
/* is it in an appropriate catgory? */
continue;
}
if (!pflag &&
/* don't include partially installed packages */
continue;
}
/* don't include completely installed packages */
continue;
}
if (pkgcnt) {
if (i >= 0)
else {
if (qflag) {
errflg++;
return;
}
}
}
}
/* If no package matched and no output produced set error flag */
if (!output)
errflg++;
/* verify that each package listed on command line was output */
for (i = 0; i < pkgcnt; ++i) {
if (pkg[i]) {
errflg++;
if (!qflag) {
if (pflag == 1)
else
} else
return;
}
}
}
static void
{
register int i;
char *pt;
char category[128];
if (qflag) {
return; /* print nothing */
}
if (rflag) {
return;
}
if (Lflag) {
return;
} else if (xflag) {
(void) printf("\n");
}
return;
} else if (!lflag) {
} else {
}
return;
}
for (i = 0; parmlst[i]; ++i) {
}
gettext("partially installed"));
gettext("completely installed"));
else
if (!lflag) {
(void) putchar('\n');
return;
}
(void) putchar('\n');
}
static struct cfstat *
{
while (dp) {
return (dp);
}
if (!dp) {
exit(1);
}
if (!last)
else
return (dp);
}
#define SEPAR ','
static int
{
register int i;
register char *pt;
int match;
if (!ckcatg[0])
return (0); /* no specification implies all packages */
if (!list)
return (1); /* no category specified in pkginfo is a bug */
match = 0;
do {
*pt = '\0';
for (i = 0; ckcatg[i]; /* void */) {
/* bug id 1081607 */
match++;
break;
}
}
if (pt)
*pt++ = ',';
if (match)
return (0);
} while (pt);
return (1);
}
static void
look_for_installed(void)
{
return;
continue;
continue;
continue; /* doesn't appear to be a package */
}
}
static int
selectp(char *p)
{
register int i;
for (i = 0; i < pkgcnt; ++i) {
return (i);
}
return (-1);
}
static void
rdcontents(void)
{
int n;
exit(1);
/* check the contents file to look for referenced packages */
/* see if entry is used by indicated packaged */
continue;
/*
* Only objects specifically tagged with '!' event
* character are considered "partial", everything
* else is considered "installed" (even server
* objects).
*/
case '!' :
break;
default :
break;
}
}
}
if (n < 0) {
exit(1);
}
}
static void
{
int n;
char pkgmap[MAXPATHLEN];
exit(1);
}
}
if (n < 0) {
exit(1);
}
}
static void
{
return;
} else {
/* Only collect mode stats if they would be meaningful. */
}
}
}
static void
usage(void)
{
char *prog = get_prog_name();
/* bug # 1081606 */
exit(1);
}
void
{
}