示例#1
0
pkgCache::VerIterator AptCacheFile::findVer(const pkgCache::PkgIterator &pkg)
{
    // if the package is installed return the current version
    if (!pkg.CurrentVer().end()) {
        return pkg.CurrentVer();
    }

    // Else get the candidate version iterator
    const pkgCache::VerIterator &candidateVer = findCandidateVer(pkg);
    if (!candidateVer.end()) {
        return candidateVer;
    }

    // return the version list as a last resource
    return pkg.VersionList();
}
示例#2
0
文件: disposal.cpp 项目: wh0/disposal
static void fancy_reverse_deps(const pkgCache::PkgIterator pkg, const pkgCache::VerIterator ver, callback_t callback) {
	for (pkgCache::DepIterator dep = pkg.RevDependsList(); !dep.end(); ++dep) {
		if (dep.IsSatisfied(ver)) callback(dep);
	}
	for (pkgCache::PrvIterator prv = ver.ProvidesList(); !prv.end(); ++prv) {
		for (pkgCache::DepIterator dep = prv.ParentPkg().RevDependsList(); !dep.end(); ++dep) {
			if (dep.IsSatisfied(prv)) callback(dep);
		}
	}
}
示例#3
0
文件: disposal.cpp 项目: wh0/disposal
bool notable_remove(pkgCacheFile &Cache, const std::vector<scan_info> &info, const pkgCache::PkgIterator pkg) {
	// removing as requested
	if (info[pkg->ID].in_no) return true;
	bool notable = true;
	fancy_reverse_deps(pkg, pkg.CurrentVer(), [&](const pkgCache::DepIterator dep) {
		if (dep.IsNegative()) return;
		if (!Cache->IsImportantDep(dep)) return;
		if (!Cache[dep.ParentPkg()].Delete()) return;
		if (dep.ParentVer() != dep.ParentPkg().CurrentVer()) return;
		// something else being removed depends on it
		notable = false;
	});
	return notable;
}