#include <apt-pkg/edsp.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/pkgsystem.h>
#include <ctype.h>
#include <stddef.h>
{
if (Cache[Pkg].Delete() == true)
{
- fprintf(output, "Remove: %d\n", Pkg.CurrentVer()->ID);
+ fprintf(output, "Remove: %d\n", _system->GetVersionMapping(Pkg.CurrentVer()->ID));
if (Debug == true)
fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), Pkg.CurrentVer().VerStr());
}
else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
{
pkgCache::VerIterator const CandVer = Cache.GetCandidateVersion(Pkg);
- fprintf(output, "Install: %d\n", CandVer->ID);
+ fprintf(output, "Install: %d\n", _system->GetVersionMapping(CandVer->ID));
if (Debug == true)
fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), CandVer.VerStr());
}
else if (Cache[Pkg].Garbage == true)
{
- fprintf(output, "Autoremove: %d\n", Pkg.CurrentVer()->ID);
+ fprintf(output, "Autoremove: %d\n", _system->GetVersionMapping(Pkg.CurrentVer()->ID));
if (Debug == true)
fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), Pkg.CurrentVer().VerStr());
}
{
std::string action;
if (Cache[Pkg].Delete() == true)
- WriteOkay(Okay, output, "Remove: ", Pkg.CurrentVer()->ID, "\n");
+ WriteOkay(Okay, output, "Remove: ", _system->GetVersionMapping(Pkg.CurrentVer()->ID), "\n");
else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
- WriteOkay(Okay, output, "Install: ", Cache.GetCandidateVersion(Pkg)->ID, "\n");
+ WriteOkay(Okay, output, "Install: ", _system->GetVersionMapping(Cache.GetCandidateVersion(Pkg)->ID), "\n");
else if (Cache[Pkg].Garbage == true)
- WriteOkay(Okay, output, "Autoremove: ", Pkg.CurrentVer()->ID, "\n");
+ WriteOkay(Okay, output, "Autoremove: ", _system->GetVersionMapping(Pkg.CurrentVer()->ID), "\n");
else
continue;
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgsystem.h>
/*}}}*/
// ListParser::NewVersion - Fill in the version structure /*{{{*/
bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
{
- Ver->ID = Section.FindI("APT-ID", Ver->ID);
+ _system->SetVersionMapping(Ver->ID, Section.FindI("APT-ID", Ver->ID));
return debListParser::NewVersion(Ver);
}
/*}}}*/
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
+#include <map>
#include <cassert>
#include <cstring>
/*}}}*/
pkgSystem **pkgSystem::GlobalList = SysList;
unsigned long pkgSystem::GlobalListLen = 0;
+class APT_HIDDEN pkgSystemPrivate /*{{{*/
+{
+public:
+ typedef decltype(pkgCache::Version::ID) idtype;
+ std::map<idtype,idtype> idmap;
+ pkgSystemPrivate() {}
+};
+ /*}}}*/
// System::pkgSystem - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* Add it to the global list.. */
pkgSystem::pkgSystem(char const * const label, pkgVersioningSystem * const vs) :
- Label(label), VS(vs), d(NULL)
+ Label(label), VS(vs), d(new pkgSystemPrivate())
{
assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
SysList[GlobalListLen] = this;
return {};
}
/*}}}*/
+// pkgSystem::Set/GetVersionMapping - for internal/external communcation/*{{{*/
+void pkgSystem::SetVersionMapping(map_id_t const in, map_id_t const out)
+{
+ if (in == out)
+ return;
+ d->idmap.emplace(in, out);
+}
+map_id_t pkgSystem::GetVersionMapping(map_id_t const in) const
+{
+ auto const o = d->idmap.find(in);
+ return (o == d->idmap.end()) ? in : o->second;
+}
+ /*}}}*/
pkgSystem::~pkgSystem() {}