Currently an EDSP solver gets send basically all versions which means
the absolute count is the same, but that might not be true forever (and
with the skipping of rc-only versions it kinda is already) and even if
it were true, segfaulting on bad input seems wrong.
#include <apt-pkg/edsp.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/strutl.h>
#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>
#include <ctype.h>
#include <stddef.h>
{
if (Cache[Pkg].Delete() == true)
{
{
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);
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)
{
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());
}
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)
{
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)
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)
else if (Cache[Pkg].Garbage == true)
- WriteOkay(Okay, output, "Autoremove: ", Pkg.CurrentVer()->ID, "\n");
+ WriteOkay(Okay, output, "Autoremove: ", _system->GetVersionMapping(Pkg.CurrentVer()->ID), "\n");
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
#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)
{
// 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);
}
/*}}}*/
return debListParser::NewVersion(Ver);
}
/*}}}*/
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
#include <cassert>
#include <cstring>
/*}}}*/
#include <cassert>
#include <cstring>
/*}}}*/
pkgSystem **pkgSystem::GlobalList = SysList;
unsigned long pkgSystem::GlobalListLen = 0;
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) :
// 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;
{
assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
SysList[GlobalListLen] = this;
+// 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() {}
pkgSystem::~pkgSystem() {}
class Configuration;
class pkgIndexFile;
class Configuration;
class pkgIndexFile;
class pkgSystem
{
public:
class pkgSystem
{
public:
*/
std::vector<std::string> ArchitecturesSupported() const;
*/
std::vector<std::string> ArchitecturesSupported() const;
+ APT_HIDDEN void SetVersionMapping(map_id_t const in, map_id_t const out);
+ APT_HIDDEN map_id_t GetVersionMapping(map_id_t const in) const;
+
pkgSystem(char const * const Label, pkgVersioningSystem * const VS);
virtual ~pkgSystem();
private:
pkgSystem(char const * const Label, pkgVersioningSystem * const VS);
virtual ~pkgSystem();
private:
+ pkgSystemPrivate * const d;
};
// The environment we are operating in.
};
// The environment we are operating in.
cat solver.result
msgfail
fi
cat solver.result
msgfail
fi
+testsuccess grep '^APT-ID: 1$' "$APT_EDSP_DUMP_FILENAME"
+sed -i -e 's#^APT-ID: 1$#APT-ID: 10000#' "$APT_EDSP_DUMP_FILENAME"
+cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
+testsuccessequal 'Message: Done
+' tail -n2 solver.result
rm -f "$APT_EDSP_DUMP_FILENAME"
testsuccess aptinternalsolver scenario
rm -f "$APT_EDSP_DUMP_FILENAME"
testsuccess aptinternalsolver scenario