summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-14 02:17:55 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-14 02:17:55 -0300
commit9afd0c563fd36cf49eb94b6227a27ba86e85cc4f (patch)
tree274ea391d1b907d261ca52e38a27b27611fc33f0
parent0bf32e6231340eb9a72e1651262c4ad5f7e8e0ae (diff)
aptcc: Managed to get rid of pair container it should become faster but needs testing, seems that the packages emitted in simulate aren't ok
-rw-r--r--backends/aptcc/acqpkitstatus.cpp12
-rw-r--r--backends/aptcc/acqpkitstatus.h2
-rw-r--r--backends/aptcc/apt-intf.cpp223
-rw-r--r--backends/aptcc/apt-intf.h32
-rw-r--r--backends/aptcc/apt-utils.cpp4
-rw-r--r--backends/aptcc/apt-utils.h18
-rw-r--r--backends/aptcc/pk-backend-aptcc.cpp63
7 files changed, 173 insertions, 181 deletions
diff --git a/backends/aptcc/acqpkitstatus.cpp b/backends/aptcc/acqpkitstatus.cpp
index 262bc608..4a5fc662 100644
--- a/backends/aptcc/acqpkitstatus.cpp
+++ b/backends/aptcc/acqpkitstatus.cpp
@@ -232,9 +232,9 @@ bool AcqPackageKitStatus::MediaChange(string Media, string Drive)
}
-void AcqPackageKitStatus::addPackagePair(PkgPair packagePair)
+void AcqPackageKitStatus::addPackage(const pkgCache::VerIterator &ver)
{
- packages.push_back(packagePair);
+ packages.push_back(ver);
}
void AcqPackageKitStatus::emit_package(const string &name, bool finished)
@@ -247,10 +247,10 @@ void AcqPackageKitStatus::emit_package(const string &name, bool finished)
}
// try to see if any package matches
- if (name.compare(it->first.Name()) == 0) {
- m_apt->emit_package(*it,
- PK_INFO_ENUM_UNKNOWN,
- finished ? PK_INFO_ENUM_FINISHED : PK_INFO_ENUM_DOWNLOADING);
+ if (name.compare(it->ParentPkg().Name()) == 0) {
+ m_apt->emitPackage(*it,
+ PK_INFO_ENUM_UNKNOWN,
+ finished ? PK_INFO_ENUM_FINISHED : PK_INFO_ENUM_DOWNLOADING);
last_package_name = name;
// Find the downloading item
diff --git a/backends/aptcc/acqpkitstatus.h b/backends/aptcc/acqpkitstatus.h
index 4e018861..b3388090 100644
--- a/backends/aptcc/acqpkitstatus.h
+++ b/backends/aptcc/acqpkitstatus.h
@@ -41,7 +41,7 @@ public:
bool Pulse(pkgAcquire *Owner);
- void addPackagePair(PkgPair packagePair);
+ void addPackage(const pkgCache::VerIterator &ver);
private:
PkBackend *m_backend;
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 7b8bd527..77c20288 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -182,49 +182,46 @@ void AptIntf::cancel()
}
}
-PkgPair AptIntf::find_package_id(const gchar *package_id, bool &found)
+pkgCache::VerIterator AptIntf::findPackageId(const gchar *package_id, bool &found)
{
gchar **parts;
- pkgCache::VerIterator ver;
- PkgPair pkg_ver;
+ pkgCache::PkgIterator pkg;
found = true;
parts = pk_package_id_split (package_id);
gchar *pkgNameArch;
pkgNameArch = g_strdup_printf("%s:%s", parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_ARCH]);
- pkg_ver.first = packageCache->FindPkg(pkgNameArch);
+ pkg = packageCache->FindPkg(pkgNameArch);
g_free(pkgNameArch);
// Ignore packages that could not be found or that exist only due to dependencies.
- if (pkg_ver.first.end() == true ||
- (pkg_ver.first.VersionList().end() && pkg_ver.first.ProvidesList().end())) {
+ if (pkg.end() == true ||
+ (pkg.VersionList().end() && pkg.ProvidesList().end())) {
g_strfreev(parts);
- return pkg_ver;
+ return pkgCache::VerIterator();
}
- ver = find_ver(pkg_ver.first);
+ const pkgCache::VerIterator &ver = find_ver(pkg);
// check to see if the provided package isn't virtual too
if (ver.end() == false &&
strcmp(ver.VerStr(), parts[PK_PACKAGE_ID_VERSION]) == 0) {
g_strfreev(parts);
- pkg_ver.second = ver;
- return pkg_ver;
+ return ver;
}
- ver = find_candidate_ver(pkg_ver.first);
+ const pkgCache::VerIterator &candidateVer = find_candidate_ver(pkg);
// check to see if the provided package isn't virtual too
- if (ver.end() == false &&
- strcmp(ver.VerStr(), parts[PK_PACKAGE_ID_VERSION]) == 0) {
+ if (candidateVer.end() == false &&
+ strcmp(candidateVer.VerStr(), parts[PK_PACKAGE_ID_VERSION]) == 0) {
g_strfreev(parts);
- pkg_ver.second = ver;
- return pkg_ver;
+ return candidateVer;
}
found = false;
g_strfreev (parts);
- return pkg_ver;
+ return ver;
}
pkgCache::VerIterator AptIntf::find_candidate_ver(const pkgCache::PkgIterator &pkg)
@@ -236,25 +233,24 @@ pkgCache::VerIterator AptIntf::find_candidate_ver(const pkgCache::PkgIterator &p
pkgCache::VerIterator AptIntf::find_ver(const pkgCache::PkgIterator &pkg)
{
// if the package is installed return the current version
- if(!pkg.CurrentVer().end()) {
+ if (!pkg.CurrentVer().end()) {
return pkg.CurrentVer();
}
// Else get the candidate version iterator
- pkgCache::VerIterator candver = find_candidate_ver(pkg);
- if(!candver.end()) {
- return candver;
+ const pkgCache::VerIterator &candidateVer = find_candidate_ver(pkg);
+ if (!candidateVer.end()) {
+ return candidateVer;
}
// return the version list as a last resource
return pkg.VersionList();
}
-bool AptIntf::matchPackage(const PkgPair &pair, PkBitfield filters)
+bool AptIntf::matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters)
{
if (filters != 0) {
- const pkgCache::PkgIterator &pkg = pair.first;
- const pkgCache::VerIterator &ver = pair.second;
+ const pkgCache::PkgIterator &pkg = ver.ParentPkg();
bool installed = false;
// Check if the package is installed
@@ -363,12 +359,11 @@ PkgList AptIntf::filterPackages(PkgList &packages, PkBitfield filters)
}
// used to emit packages it collects all the needed info
-void AptIntf::emit_package(const PkgPair &pair,
- PkBitfield filters,
- PkInfoEnum state)
+void AptIntf::emitPackage(const pkgCache::VerIterator &ver,
+ PkBitfield filters,
+ PkInfoEnum state)
{
- const pkgCache::PkgIterator &pkg = pair.first;
- const pkgCache::VerIterator &ver = pair.second;
+ const pkgCache::PkgIterator &pkg = ver.ParentPkg();
// check the state enum to see if it was not set.
if (state == PK_INFO_ENUM_UNKNOWN) {
@@ -381,7 +376,7 @@ void AptIntf::emit_package(const PkgPair &pair,
}
// Check if the filters match the package
- if (!matchPackage(pair, filters)) {
+ if (!matchPackage(ver, filters)) {
return;
}
@@ -417,7 +412,7 @@ void AptIntf::emit_packages(PkgList &output,
break;
}
- emit_package(*i, filters, state);
+ emitPackage(*i, filters, state);
}
}
@@ -441,7 +436,7 @@ void AptIntf::emitUpdates(PkgList &output, PkBitfield filters)
state = PK_INFO_ENUM_NORMAL;
// let find what kind of upgrade this is
- pkgCache::VerFileIterator vf = i->second.FileList();
+ pkgCache::VerFileIterator vf = i->FileList();
std::string origin = vf.File().Origin() == NULL ? "" : vf.File().Origin();
std::string archive = vf.File().Archive() == NULL ? "" : vf.File().Archive();
std::string label = vf.File().Label() == NULL ? "" : vf.File().Label();
@@ -460,7 +455,7 @@ void AptIntf::emitUpdates(PkgList &output, PkBitfield filters)
state = PK_INFO_ENUM_ENHANCEMENT;
}
- emit_package(*i, filters, state);
+ emitPackage(*i, filters, state);
}
}
@@ -499,7 +494,7 @@ void AptIntf::providesCodec(PkgList &output, gchar **values)
rec.GetRec(start, stop);
string record(start, stop - start);
if (matcher->matches(record)) {
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
}
@@ -569,7 +564,7 @@ void AptIntf::providesLibrary(PkgList &output, gchar **values)
std::transform(libPkgName.begin(), libPkgName.end(), libPkgName.begin(), ::tolower);
if (g_strcmp0 (pkg.Name (), libPkgName.c_str ()) == 0) {
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
}
} else {
@@ -579,13 +574,11 @@ void AptIntf::providesLibrary(PkgList &output, gchar **values)
}
// used to emit packages it collects all the needed info
-void AptIntf::emitDetails(const pkgCache::PkgIterator &pkg, const pkgCache::VerIterator &version)
+void AptIntf::emitDetails(const pkgCache::VerIterator &ver)
{
- pkgCache::VerIterator ver;
- if (version.end() == false) {
- ver = version;
- } else {
- ver = find_ver(pkg);
+ const pkgCache::PkgIterator &pkg = ver.ParentPkg();
+ if (ver.end() == true) {
+ return;
}
std::string section = ver.Section() == NULL ? "" : ver.Section();
@@ -634,16 +627,17 @@ void AptIntf::emitDetails(PkgList &pkgs)
break;
}
- emitDetails(i->first, i->second);
+ emitDetails(*i);
}
}
// used to emit packages it collects all the needed info
-void AptIntf::emitUpdateDetails(const pkgCache::PkgIterator &pkg, const pkgCache::VerIterator &version)
+void AptIntf::emitUpdateDetails(const pkgCache::VerIterator &version)
{
+ const pkgCache::PkgIterator &pkg = version.ParentPkg();
// Get the version of the current package
- pkgCache::VerIterator currver = find_ver(pkg);
- pkgCache::VerFileIterator currvf = currver.FileList();
+ const pkgCache::VerIterator &currver = find_ver(pkg);
+ const pkgCache::VerFileIterator &currvf = currver.FileList();
// Build a package_id from the current version
gchar *current_package_id;
current_package_id = pk_package_id_build(pkg.Name(),
@@ -885,21 +879,21 @@ void AptIntf::emitUpdateDetails(PkgList &pkgs)
break;
}
- emitUpdateDetails(i->first, i->second);
+ emitUpdateDetails(*i);
}
}
-void AptIntf::get_depends(PkgList &output,
- pkgCache::PkgIterator pkg,
- bool recursive)
+void AptIntf::getDepends(PkgList &output,
+ const pkgCache::VerIterator &ver,
+ bool recursive)
{
- pkgCache::DepIterator dep = find_ver(pkg).DependsList();
+ pkgCache::DepIterator dep = ver.DependsList();
while (!dep.end()) {
if (_cancel) {
break;
}
- pkgCache::VerIterator ver = find_ver(dep.TargetPkg());
+ const pkgCache::VerIterator &ver = find_ver(dep.TargetPkg());
// Ignore packages that exist only due to dependencies.
if (ver.end()) {
dep++;
@@ -907,44 +901,51 @@ void AptIntf::get_depends(PkgList &output,
} else if (dep->Type == pkgCache::Dep::Depends) {
if (recursive) {
if (!contains(output, dep.TargetPkg())) {
- output.push_back(PkgPair(dep.TargetPkg(), ver));
- get_depends(output, dep.TargetPkg(), recursive);
+ // TODO is this still working
+// output.push_back(PkgPair(dep.TargetPkg(), ver));
+ output.push_back(ver);
+ getDepends(output, ver, recursive);
}
} else {
- output.push_back(PkgPair(dep.TargetPkg(), ver));
+// output.push_back(PkgPair(dep.TargetPkg(), ver));
+ output.push_back(ver);
}
}
dep++;
}
}
-void AptIntf::get_requires(PkgList &output,
- pkgCache::PkgIterator pkg,
- bool recursive)
+void AptIntf::getRequires(PkgList &output,
+ const pkgCache::VerIterator &ver,
+ bool recursive)
{
for (pkgCache::PkgIterator parentPkg = packageCache->PkgBegin(); !parentPkg.end(); ++parentPkg) {
if (_cancel) {
break;
}
+
// Ignore packages that exist only due to dependencies.
if (parentPkg.VersionList().end() && parentPkg.ProvidesList().end()) {
continue;
}
// Don't insert virtual packages instead add what it provides
- pkgCache::VerIterator ver = find_ver(parentPkg);
- if (ver.end() == false) {
+ const pkgCache::VerIterator &parentVer = find_ver(parentPkg);
+ if (parentVer.end() == false) {
PkgList deps;
- get_depends(deps, parentPkg, false);
- for (PkgList::iterator i=deps.begin(); i != deps.end(); ++i) {
- if (i->first == pkg) {
+ getDepends(deps, parentVer, false);
+ for (PkgList::iterator it = deps.begin(); it != deps.end(); ++it) {
+// if (i->ParentPkg() == ver) { TODO make sure this works!!!!
+ if (*it == ver) {
if (recursive) {
if (!contains(output, parentPkg)) {
- output.push_back(PkgPair(parentPkg, ver));
- get_requires(output, parentPkg, recursive);
+// output.push_back(PkgPair(parentPkg, ver));
+ output.push_back(parentVer);
+ getRequires(output, parentVer, recursive);
}
} else {
- output.push_back(PkgPair(parentPkg, ver));
+// output.push_back(PkgPair(parentPkg, ver));
+ output.push_back(parentVer);
}
break;
}
@@ -1125,7 +1126,7 @@ bool AptIntf::checkTrusted(pkgAcquire &fetcher, PkBackend *backend)
// The pkgAcquire::Item had a version hiden on it's subclass
// pkgAcqArchive but it was protected our subclass exposes that
pkgAcqArchiveSane *archive = static_cast<pkgAcqArchiveSane*>(*I);
- untrusted.push_back(PkgPair(archive->version().ParentPkg(), archive->version()));
+ untrusted.push_back(archive->version());
UntrustedList += string((*I)->ShortDesc()) + " ";
}
@@ -1154,17 +1155,19 @@ bool AptIntf::checkTrusted(pkgAcquire &fetcher, PkBackend *backend)
return false;
}
-bool AptIntf::TryToInstall(pkgCache::PkgIterator Pkg,
+bool AptIntf::TryToInstall(const pkgCache::PkgIterator &constPkg,
pkgDepCache &Cache,
pkgProblemResolver &Fix,
bool Remove,
bool BrokenFix,
unsigned int &ExpectedInst)
{
+ pkgCache::PkgIterator Pkg = constPkg;
// This is a pure virtual package and there is a single available provides
if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 &&
Pkg.ProvidesList()->NextProvides == 0) {
pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
+ // TODO this is UGLY!!! create a local PkgIterator for this
Pkg = Tmp;
}
@@ -1304,16 +1307,16 @@ void AptIntf::emitChangedPackages(pkgCacheFile &Cache)
for (pkgCache::PkgIterator pkg = Cache->PkgBegin(); ! pkg.end(); ++pkg) {
if (Cache[pkg].NewInstall() == true) {
// installing
- installing.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ installing.push_back(find_candidate_ver(pkg));
} else if (Cache[pkg].Delete() == true) {
// removing
- removing.push_back(PkgPair(pkg, find_ver(pkg)));
+ removing.push_back(find_ver(pkg));
} else if (Cache[pkg].Upgrade() == true) {
// updating
- updating.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ updating.push_back(find_candidate_ver(pkg));
} else if (Cache[pkg].Downgrade() == true) {
// downgrading
- downgrading.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ downgrading.push_back(find_candidate_ver(pkg));
}
}
@@ -1329,16 +1332,16 @@ void AptIntf::populateInternalPackages(pkgCacheFile &Cache)
for (pkgCache::PkgIterator pkg = Cache->PkgBegin(); ! pkg.end(); ++pkg) {
if (Cache[pkg].NewInstall() == true) {
// installing
- m_pkgs.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ m_pkgs.push_back(find_candidate_ver(pkg));
} else if (Cache[pkg].Delete() == true) {
// removing
- m_pkgs.push_back(PkgPair(pkg, find_ver(pkg)));
+ m_pkgs.push_back(find_ver(pkg));
} else if (Cache[pkg].Upgrade() == true) {
// updating
- m_pkgs.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ m_pkgs.push_back(find_candidate_ver(pkg));
} else if (Cache[pkg].Downgrade() == true) {
// downgrading
- m_pkgs.push_back(PkgPair(pkg, find_candidate_ver(pkg)));
+ m_pkgs.push_back(find_candidate_ver(pkg));
}
}
}
@@ -1346,30 +1349,29 @@ void AptIntf::populateInternalPackages(pkgCacheFile &Cache)
void AptIntf::emitTransactionPackage(string name, PkInfoEnum state)
{
for (PkgList::iterator i = m_pkgs.begin(); i != m_pkgs.end(); ++i) {
- if (i->first.Name() == name) {
- emit_package(*i, PK_FILTER_ENUM_NONE, state);
+ if (i->ParentPkg().Name() == name) {
+ emitPackage(*i, PK_FILTER_ENUM_NONE, state);
return;
}
}
- PkgPair pkgPair;
- pkgPair.first = packageCache->FindPkg(name);
+ const pkgCache::PkgIterator &pkg = packageCache->FindPkg(name);
// Ignore packages that could not be found or that exist only due to dependencies.
- if (pkgPair.first.end() == true ||
- (pkgPair.first.VersionList().end() && pkgPair.first.ProvidesList().end())) {
+ if (pkg.end() == true ||
+ (pkg.VersionList().end() && pkg.ProvidesList().end())) {
return;
}
- pkgPair.second = find_ver(pkgPair.first);
+ const pkgCache::VerIterator &ver = find_ver(pkg);
// check to see if the provided package isn't virtual too
- if (pkgPair.second.end() == false) {
- emit_package(pkgPair, PK_FILTER_ENUM_NONE, state);
+ if (ver.end() == false) {
+ emitPackage(ver, PK_FILTER_ENUM_NONE, state);
}
- pkgPair.second = find_candidate_ver(pkgPair.first);
+ const pkgCache::VerIterator &candidateVer = find_candidate_ver(pkg);
// check to see if we found the package
- if (pkgPair.second.end() == false) {
- emit_package(pkgPair, PK_FILTER_ENUM_NONE, state);
+ if (candidateVer.end() == false) {
+ emitPackage(candidateVer, PK_FILTER_ENUM_NONE, state);
}
}
@@ -1712,7 +1714,6 @@ PkgList AptIntf::resolvePI(gchar **package_ids, PkBitfield filters)
break;
}
- PkgPair pair;
pi = package_ids[i];
// Check if it's a valid package id
@@ -1738,45 +1739,43 @@ PkgList AptIntf::resolvePI(gchar **package_ids, PkBitfield filters)
continue;
}
- pair.first = pkg;
- pair.second = find_ver(pkg);
+ const pkgCache::VerIterator &ver = find_ver(pkg);
// check to see if the provided package isn't virtual too
- if (pair.second.end() == false) {
- ret.push_back(pair);
+ if (ver.end() == false) {
+ ret.push_back(ver);
}
- pair.second = find_candidate_ver(pkg);
+ const pkgCache::VerIterator &candidateVer = find_candidate_ver(pkg);
// check to see if the provided package isn't virtual too
- if (pair.second.end() == false) {
- ret.push_back(pair);
+ if (candidateVer.end() == false) {
+ ret.push_back(candidateVer);
}
}
} else {
- pkgCache::PkgIterator pkg = packageCache->FindPkg(pi);
+ const pkgCache::PkgIterator &pkg = packageCache->FindPkg(pi);
// Ignore packages that could not be found or that exist only due to dependencies.
if (pkg.end() == true || (pkg.VersionList().end() && pkg.ProvidesList().end())) {
continue;
}
- pair.first = pkg;
- pair.second = find_ver(pkg);
+ const pkgCache::VerIterator &ver = find_ver(pkg);
// check to see if the provided package isn't virtual too
- if (pair.second.end() == false) {
- ret.push_back(pair);
+ if (ver.end() == false) {
+ ret.push_back(ver);
}
- pair.second = find_candidate_ver(pkg);
+ const pkgCache::VerIterator &candidateVer = find_candidate_ver(pkg);
// check to see if the provided package isn't virtual too
- if (pair.second.end() == false) {
- ret.push_back(pair);
+ if (candidateVer.end() == false) {
+ ret.push_back(candidateVer);
}
}
} else {
bool found;
- pair = find_package_id(pi, found);
+ const pkgCache::VerIterator &ver = findPackageId(pi, found);
// check to see if we found the package
if (found) {
- ret.push_back(pair);
+ ret.push_back(ver);
}
}
}
@@ -1787,13 +1786,13 @@ PkgList AptIntf::resolvePI(gchar **package_ids, PkBitfield filters)
bool AptIntf::markAutoInstalled(pkgCacheFile &cache, PkgList &pkgs, bool flag)
{
bool ret;
- for(PkgList::iterator i = pkgs.begin(); i != pkgs.end(); ++i) {
+ for(PkgList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
if (_cancel) {
break;
}
// Mark package as auto-installed
- cache->MarkAuto(i->first, flag);
+ cache->MarkAuto(it->ParentPkg(), flag);
}
return true;
@@ -2018,13 +2017,12 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
// new scope for the ActionGroup
{
pkgDepCache::ActionGroup group(Cache);
- for(PkgList::iterator i = install.begin(); i != install.end(); ++i) {
- pkgCache::PkgIterator Pkg = i->first;
+ for (PkgList::iterator it = install.begin(); it != install.end(); ++it) {
if (_cancel) {
break;
}
- if (TryToInstall(Pkg,
+ if (TryToInstall(it->ParentPkg(),
Cache,
Fix,
false, // remove
@@ -2038,13 +2036,12 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
markAutoInstalled(Cache, install, markAuto);
}
- for (PkgList::iterator i = remove.begin(); i != remove.end(); ++i) {
- pkgCache::PkgIterator Pkg = i->first;
+ for (PkgList::iterator it = remove.begin(); it != remove.end(); ++it) {
if (_cancel) {
break;
}
- if (TryToInstall(Pkg,
+ if (TryToInstall(it->ParentPkg(),
Cache,
Fix,
true, // remove
@@ -2175,7 +2172,7 @@ bool AptIntf::installPackages(pkgCacheFile &Cache, bool simulating)
}
// Append it to the list
- Stat.addPackagePair(PkgPair(pkg, ver));
+ Stat.addPackage(ver);
}
// Display statistics
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index 9727a653..15cf8ee0 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -45,8 +45,7 @@ vector<string> search_files (PkBackend *backend, gchar **values, bool &_cancel);
*/
vector<string> searchMimeType (PkBackend *backend, gchar **values, bool &error, bool &_cancel);
-typedef pair<pkgCache::PkgIterator, pkgCache::VerIterator> PkgPair;
-typedef vector<PkgPair> PkgList;
+typedef vector<pkgCache::VerIterator> PkgList;
class pkgProblemResolver;
@@ -62,8 +61,7 @@ public:
// Check the returned VerIterator.end()
// if it's true we could not find it
- pair<pkgCache::PkgIterator, pkgCache::VerIterator>
- find_package_id(const gchar *package_id, bool &found);
+ pkgCache::VerIterator findPackageId(const gchar *package_id, bool &found);
pkgCache::VerIterator find_ver(const pkgCache::PkgIterator &pkg);
pkgCache::VerIterator find_candidate_ver(const pkgCache::PkgIterator &pkg);
@@ -85,25 +83,25 @@ public:
/**
* Get depends
*/
- void get_depends(PkgList &output,
- pkgCache::PkgIterator pkg,
- bool recursive);
+ void getDepends(PkgList &output,
+ const pkgCache::VerIterator &ver,
+ bool recursive);
/**
* Get requires
*/
- void get_requires(PkgList &output,
- pkgCache::PkgIterator pkg,
- bool recursive);
+ void getRequires(PkgList &output,
+ const pkgCache::VerIterator &ver,
+ bool recursive);
/**
* Emits a package if it match the filters
*/
- void emit_package(const PkgPair &pair,
- PkBitfield filters = PK_FILTER_ENUM_NONE,
- PkInfoEnum state = PK_INFO_ENUM_UNKNOWN);
+ void emitPackage(const pkgCache::VerIterator &ver,
+ PkBitfield filters = PK_FILTER_ENUM_NONE,
+ PkInfoEnum state = PK_INFO_ENUM_UNKNOWN);
- bool matchPackage(const PkgPair &pair, PkBitfield filters);
+ bool matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters);
PkgList filterPackages(PkgList &packages, PkBitfield filters);
void emit_packages(PkgList &output,
@@ -115,13 +113,13 @@ public:
/**
* Emits details
*/
- void emitDetails(const pkgCache::PkgIterator &pkg, const pkgCache::VerIterator &ver);
+ void emitDetails(const pkgCache::VerIterator &ver);
void emitDetails(PkgList &pkgs);
/**
* Emits update detail
*/
- void emitUpdateDetails(const pkgCache::PkgIterator &pkg, const pkgCache::VerIterator &ver);
+ void emitUpdateDetails(const pkgCache::VerIterator &version);
void emitUpdateDetails(PkgList &pkgs);
/**
@@ -166,7 +164,7 @@ private:
bool &_cancel;
bool checkTrusted(pkgAcquire &fetcher, PkBackend *backend);
- bool TryToInstall(pkgCache::PkgIterator Pkg,
+ bool TryToInstall(const pkgCache::PkgIterator &constPkg,
pkgDepCache &Cache,
pkgProblemResolver &Fix,
bool Remove,
diff --git a/backends/aptcc/apt-utils.cpp b/backends/aptcc/apt-utils.cpp
index 2cc4ffb1..497e5935 100644
--- a/backends/aptcc/apt-utils.cpp
+++ b/backends/aptcc/apt-utils.cpp
@@ -375,10 +375,10 @@ string getBugzillaUrls(const string &changelog)
return ret;
}
-bool contains(PkgList packages, const pkgCache::PkgIterator pkg)
+bool contains(PkgList packages, const pkgCache::PkgIterator &pkg)
{
for (PkgList::iterator it = packages.begin(); it != packages.end(); ++it) {
- if (it->first == pkg) {
+ if (it->ParentPkg() == pkg) {
return true;
}
}
diff --git a/backends/aptcc/apt-utils.h b/backends/aptcc/apt-utils.h
index 11abf16b..122f32de 100644
--- a/backends/aptcc/apt-utils.h
+++ b/backends/aptcc/apt-utils.h
@@ -39,11 +39,11 @@ class compare
public:
compare() {}
- bool operator()(const PkgPair &a,
- const PkgPair &b) {
- int ret = strcmp(a.first.Name(), b.first.Name());
+ bool operator()(const pkgCache::VerIterator &a,
+ const pkgCache::VerIterator &b) {
+ int ret = strcmp(a.ParentPkg().Name(), b.ParentPkg().Name());
if (ret == 0) {
- return strcmp(a.second.VerStr(), b.second.VerStr()) < 0;
+ return strcmp(a.VerStr(), b.VerStr()) < 0;
}
return ret < 0;
}
@@ -55,10 +55,10 @@ class result_equality
public:
result_equality() {}
- bool operator() (const PkgPair &a, const PkgPair &b) {
- return strcmp(a.first.Name(), b.first.Name()) == 0 &&
- strcmp(a.second.VerStr(), b.second.VerStr()) == 0 &&
- strcmp(a.second.Arch(), b.second.Arch()) == 0;
+ bool operator() (const pkgCache::VerIterator &a, const pkgCache::VerIterator &b) {
+ return strcmp(a.ParentPkg().Name(), b.ParentPkg().Name()) == 0 &&
+ strcmp(a.VerStr(), b.VerStr()) == 0 &&
+ strcmp(a.Arch(), b.Arch()) == 0;
}
};
@@ -121,7 +121,7 @@ string getBugzillaUrls(const string &changelog);
/**
* Return if the given vector contain a package
*/
-bool contains(PkgList packages, const pkgCache::PkgIterator pkg);
+bool contains(PkgList packages, const pkgCache::PkgIterator &pkg);
/**
* Return if the given string ends with the other
diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp
index 27113d4e..80c1b278 100644
--- a/backends/aptcc/pk-backend-aptcc.cpp
+++ b/backends/aptcc/pk-backend-aptcc.cpp
@@ -192,9 +192,8 @@ static gboolean backend_get_depends_or_requires_thread(PkBackend *backend)
return false;
}
- PkgPair pkg_ver;
bool found;
- pkg_ver = m_apt->find_package_id(pi, found);
+ const pkgCache::VerIterator &ver = m_apt->findPackageId(pi, found);
if (!found) {
pk_backend_error_code (backend,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
@@ -204,9 +203,9 @@ static gboolean backend_get_depends_or_requires_thread(PkBackend *backend)
}
if (depends) {
- m_apt->get_depends(output, pkg_ver.first, recursive);
+ m_apt->getDepends(output, ver, recursive);
} else {
- m_apt->get_requires(output, pkg_ver.first, recursive);
+ m_apt->getRequires(output, ver, recursive);
}
}
@@ -278,9 +277,8 @@ static gboolean backend_get_files_thread(PkBackend *backend)
return false;
}
- PkgPair pkg_ver;
bool found;
- pkg_ver = m_apt->find_package_id(pi, found);
+ m_apt->findPackageId(pi, found);
if (!found) {
pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Couldn't find package");
delete m_apt;
@@ -415,11 +413,11 @@ static gboolean backend_get_or_update_system_thread (PkBackend *backend)
++pkg) {
if ((*Cache)[pkg].Upgrade() == true &&
(*Cache)[pkg].NewInstall() == false) {
- update.push_back(PkgPair(pkg, m_apt->find_candidate_ver(pkg)));
+ update.push_back(m_apt->find_candidate_ver(pkg));
} else if ((*Cache)[pkg].Upgradable() == true &&
pkg->CurrentVer != 0 &&
(*Cache)[pkg].Delete() == false) {
- kept.push_back(PkgPair(pkg, m_apt->find_candidate_ver(pkg)));
+ kept.push_back(m_apt->find_candidate_ver(pkg));
}
}
@@ -503,15 +501,15 @@ static gboolean backend_what_provides_thread(PkBackend *backend)
if (_cancel) {
break;
}
- pkgCache::PkgIterator pkg = m_apt->packageCache->FindPkg(i->c_str());
+ const pkgCache::PkgIterator &pkg = m_apt->packageCache->FindPkg(i->c_str());
if (pkg.end() == true) {
continue;
}
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == true) {
continue;
}
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
if (error && provides == PK_PROVIDES_ENUM_MIMETYPE) {
@@ -620,15 +618,14 @@ static gboolean pk_backend_download_packages_thread(PkBackend *backend)
break;
}
- PkgPair pkg_ver;
bool found;
- pkg_ver = m_apt->find_package_id(pi, found);
+ const pkgCache::VerIterator &ver = m_apt->findPackageId(pi, found);
// Ignore packages that could not be found or that exist only due to dependencies.
if (!found) {
_error->Error("Can't find this package id \"%s\".", pi);
continue;
} else {
- if(!pkg_ver.second.Downloadable()) {
+ if(!ver.Downloadable()) {
_error->Error("No downloadable files for %s,"
"perhaps it is a local or obsolete" "package?",
pi);
@@ -639,10 +636,10 @@ static gboolean pk_backend_download_packages_thread(PkBackend *backend)
if (get_archive(&fetcher,
m_apt->packageSourceList,
m_apt->packageRecords,
- pkg_ver.second,
+ ver,
directory,
storeFileName)) {
- Stat.addPackagePair(pkg_ver);
+ Stat.addPackage(ver);
}
string destFile = directory + "/" + flNotDir(storeFileName);
if (filelist.empty()) {
@@ -801,15 +798,15 @@ static gboolean pk_backend_search_files_thread(PkBackend *backend)
if (_cancel) {
break;
}
- pkgCache::PkgIterator pkg = m_apt->packageCache->FindPkg(i->c_str());
+ const pkgCache::PkgIterator &pkg = m_apt->packageCache->FindPkg(i->c_str());
if (pkg.end() == true) {
continue;
}
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == true) {
continue;
}
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
// It's faster to emmit the packages here rather than in the matching part
m_apt->emit_packages(output, filters);
@@ -873,7 +870,7 @@ static gboolean backend_search_groups_thread (PkBackend *backend)
}
// Ignore virtual packages
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == false) {
string section = pkg.VersionList().Section() == NULL ? "" : pkg.VersionList().Section();
@@ -886,7 +883,7 @@ static gboolean backend_search_groups_thread (PkBackend *backend)
i != groups.end();
++i) {
if (*i == get_enum_group(section)) {
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
break;
}
}
@@ -959,12 +956,12 @@ static gboolean backend_search_package_thread(PkBackend *backend)
continue;
}
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == false) {
if (m_matcher->matches(pkg.Name()) ||
m_matcher->matches(get_long_description(ver, m_apt->packageRecords))) {
// The package matched
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
} else if (m_matcher->matches(pkg.Name())) {
// The package is virtual and MATCHED the name
@@ -972,13 +969,13 @@ static gboolean backend_search_package_thread(PkBackend *backend)
// iterate over the provides list
for (pkgCache::PrvIterator Prv = pkg.ProvidesList(); Prv.end() == false; ++Prv) {
- ver = m_apt->find_ver(Prv.OwnerPkg());
+ const pkgCache::VerIterator &ownerVer = m_apt->find_ver(Prv.OwnerPkg());
// check to see if the provided package isn't virtual too
- if (ver.end() == false) {
+ if (ownerVer.end() == false) {
// we add the package now because we will need to
// remove duplicates later anyway
- output.push_back(PkgPair(Prv.OwnerPkg(), ver));
+ output.push_back(ownerVer);
}
}
}
@@ -995,20 +992,20 @@ static gboolean backend_search_package_thread(PkBackend *backend)
if (m_matcher->matches(pkg.Name())) {
// Don't insert virtual packages instead add what it provides
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == false) {
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
} else {
// iterate over the provides list
for (pkgCache::PrvIterator Prv = pkg.ProvidesList(); Prv.end() == false; ++Prv) {
- ver = m_apt->find_ver(Prv.OwnerPkg());
+ const pkgCache::VerIterator &ownerVer = m_apt->find_ver(Prv.OwnerPkg());
// check to see if the provided package isn't virtual too
- if (ver.end() == false)
+ if (ownerVer.end() == false)
{
// we add the package now because we will need to
// remove duplicates later anyway
- output.push_back(PkgPair(Prv.OwnerPkg(), ver));
+ output.push_back(ownerVer);
}
}
}
@@ -1364,9 +1361,9 @@ static gboolean backend_get_packages_thread(PkBackend *backend)
}
// Don't insert virtual packages as they don't have all kinds of info
- pkgCache::VerIterator ver = m_apt->find_ver(pkg);
+ const pkgCache::VerIterator &ver = m_apt->find_ver(pkg);
if (ver.end() == false) {
- output.push_back(PkgPair(pkg, ver));
+ output.push_back(ver);
}
}