Beispiel #1
0
static void
rdcontents(void)
{
	VFP_T		*vfp;
	struct cfstat	*dp;
	struct pinfo	*pinfo;
	int		n;

	if (vfpOpen(&vfp, contents, "r", VFP_NEEDNOW) != 0) {
		progerr(gettext("unable to open \"%s\" for reading"), contents);
		exit(1);
	}

	/* check the contents file to look for referenced packages */
	while ((n = srchcfile(&entry, "*", vfp, (VFP_T *)NULL)) > 0) {
		for (pinfo = entry.pinfo; pinfo; pinfo = pinfo->next) {
			/* see if entry is used by indicated packaged */
			if (pkgcnt && (selectp(pinfo->pkg) < 0))
				continue;

			dp = fpkg(pinfo->pkg);
			pkgusage(dp, &entry);

			if (entry.npkgs > 1)
				dp->shared++;

			/*
			 * Only objects specifically tagged with '!' event
			 * character are considered "partial", everything
			 * else is considered "installed" (even server
			 * objects).
			 */
			switch (pinfo->status) {
			case '!' :
				dp->partial++;
				break;
			default :
				dp->installed++;
				break;
			}
		}
	}
	if (n < 0) {
		char	*errstr = getErrstr();
		progerr(gettext("bad entry read in contents file"));
		logerr(gettext("pathname: %s"),
		    (entry.path && *entry.path) ? entry.path : "Unknown");
		logerr(gettext("problem: %s"),
		    (errstr && *errstr) ? errstr : "Unknown");
		exit(1);
	}

	(void) vfpClose(&vfp);
}
Beispiel #2
0
static void
rdcontents(void)
{
	struct cfstat	*dp;
	struct pinfo	*pinfo;
	int		n;
	PKGserver	server;

	if (!socfile(&server, B_TRUE) ||
	    pkgopenfilter(server, pkgcnt == 1 ? pkg[0] :  NULL) != 0)
		exit(1);

	/* check the contents file to look for referenced packages */
	while ((n = srchcfile(&entry, "*", server)) > 0) {
		for (pinfo = entry.pinfo; pinfo; pinfo = pinfo->next) {
			/* see if entry is used by indicated packaged */
			if (pkgcnt && (selectp(pinfo->pkg) < 0))
				continue;

			dp = fpkg(pinfo->pkg);
			pkgusage(dp, &entry);

			if (entry.npkgs > 1)
				dp->shared++;

			/*
			 * Only objects specifically tagged with '!' event
			 * character are considered "partial", everything
			 * else is considered "installed" (even server
			 * objects).
			 */
			switch (pinfo->status) {
			case '!' :
				dp->partial++;
				break;
			default :
				dp->installed++;
				break;
			}
		}
	}
	if (n < 0) {
		char	*errstr = getErrstr();
		progerr(gettext("bad entry read in contents file"));
		logerr(gettext("pathname: %s"),
		    (entry.path && *entry.path) ? entry.path : "Unknown");
		logerr(gettext("problem: %s"),
		    (errstr && *errstr) ? errstr : "Unknown");
		exit(1);
	}
	pkgcloseserver(server);
}
Beispiel #3
0
static void
look_for_installed(void)
{
	struct dirent *drp;
	DIR	*dirfp;
	char	path[PATH_MAX];

	if ((dirfp = opendir(pkgdir)) == NULL)
		return;

	while (drp = readdir(dirfp)) {
		if (drp->d_name[0] == '.')
			continue;

		if (pkgcnt && (selectp(drp->d_name) < 0))
			continue;

		if (!pkginfofind(path, pkgdir, drp->d_name))
			continue; /* doesn't appear to be a package */

		(void) fpkg(drp->d_name);
	}
	(void) closedir(dirfp);
}
			uint64_t next1(uint64_t i) const 
			{
				uint64_t r = rankm1(i);
				assert(r < m_ones);
				return selectp(r+1);
			}                                    
			uint64_t prev1(uint64_t i) const 
			{
				uint64_t r = rankm1(i+1);
				assert(r>0);
				return selectp(r);
			}
			uint64_t select1(uint64_t i) const
			{
				return selectp(i+1);
			}
			bool operator[](uint64_t const idx) const
			{
				uint64_t const r = rankm1(idx+1);
				return r && (selectp(r) == idx);
			}
Beispiel #8
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 */
}