Beispiel #1
0
static char *
nextinst(void)
{
	struct pkginfo info;
	int	n;

	n = 2; /* requirements say start at 2 */

	info.pkginst = NULL;
	(void) strcpy(newinst, pkgabrv);
	while (pkginfo(&info, newinst, NULL, NULL) == 0) {
		(void) snprintf(newinst, sizeof (newinst),
				"%s.%d", pkgabrv, n++);
	}
	return (newinst);
}
Beispiel #2
0
static void
report(void)
{
	struct cfstat *dp, *choice;
	int	i;
	int	pkgLgth = 0;
	int	longestPkg = 0;
	boolean_t output = B_FALSE;

	for (;;) {
		choice = (struct cfstat *)0;
		for (dp = data; dp; dp = dp->next) {
			pkgLgth = strlen(dp->pkginst);
			if (pkgLgth > longestPkg)
				longestPkg = pkgLgth;
		}
		for (dp = data; dp; dp = dp->next) {
			/* get information about this package */
			if (dp->installed < 0)
				continue; /* already used */
			if (Lflag && pkgcnt) {
				choice = dp;
				break;
			} else if (!choice ||
			    (strcmp(choice->pkginst, dp->pkginst) > 0))
				choice = dp;
		}
		if (!choice)
			break; /* no more packages */

		if (pkginfo(&info, choice->pkginst, ckarch, ckvers)) {
			choice->installed = (-1);
			continue;
		}

		/*
		 * Confirm that the pkginfo file contains the
		 * required information.
		 */
		if (info.name == NULL || *(info.name) == 0 ||
		    info.arch == NULL || *(info.arch) == 0 ||
		    info.version == NULL || *(info.version) == 0 ||
		    info.catg == NULL || *(info.catg) == 0) {
			progerr(gettext(ERR_BADINFO));
			errflg++;
			return;
		}

		/* is it in an appropriate catgory? */
		if (iscatg(info.catg)) {
			choice->installed = (-1);
			continue;
		}

		if (!pflag &&
			/* don't include partially installed packages */
			(choice->partial || (info.status == PI_PARTIAL) ||
				(info.status == PI_UNKNOWN))) {
			choice->installed = (-1);
			continue;
		}

		if (Nflag && (info.status == PI_PRESVR4)) {
			/* don't include preSVR4 packages */
			choice->installed = (-1);
			continue;
		}

		if (!iflag && (info.status == PI_INSTALLED)) {
			/* don't include completely installed packages */
			choice->installed = (-1);
			continue;
		}

		output = B_TRUE;
		dumpinfo(choice, longestPkg);
		choice->installed = (-1);
		if (pkgcnt) {
			i = selectp(choice->pkginst);
			if (i >= 0)
				pkg[i] = NULL;
			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)
					logerr(gettext(ERR_NOPINFO), pkg[i]);
				else
					logerr(gettext(ERR_NOINFO), pkg[i]);
			} else
				return;
		}
	}
	(void) pkginfo(&info, NULL); /* free up all memory and open fds */
}