summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/edsp.cc30
-rw-r--r--apt-pkg/edsp.h16
2 files changed, 46 insertions, 0 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 88569d3c4..2e6ef6271 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -327,6 +327,36 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
Progress->Done();
return Okay;
}
+
+static void MarkPackage(std::vector<bool> &pkgset, pkgCache::PkgIterator pkg)
+{
+ if (pkgset[pkg->ID])
+ return;
+ pkgset[pkg->ID] = true;
+ for (auto ver = pkg.VersionList(); not ver.end(); ++ver)
+ {
+ for (auto P = ver.ProvidesList(); not P.end(); ++P)
+ MarkPackage(pkgset, P.ParentPkg());
+ for (auto D = ver.DependsList(); not D.end(); ++D)
+ {
+ std::unique_ptr<pkgCache::Version *[]> targets(D.AllTargets());
+ for (size_t i = 0; targets[i] != 0; ++i)
+ MarkPackage(pkgset, pkgCache::VerIterator(*ver.Cache(), targets[i]).ParentPkg());
+
+ MarkPackage(pkgset, D.TargetPkg());
+ }
+ }
+}
+
+bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
+ OpProgress *Progress)
+{
+ std::vector<bool> pkgset(Cache.Head().PackageCount);
+ for (auto Pkg = Cache.PkgBegin(); not Pkg.end(); ++Pkg)
+ if (Cache[Pkg].Install() || Pkg->CurrentVer)
+ MarkPackage(pkgset, Pkg);
+ return WriteLimitedScenario(Cache, output, pkgset, Progress);
+}
/*}}}*/
// EDSP::WriteRequest - to the given file descriptor /*{{{*/
bool EDSP::WriteRequest(pkgDepCache &Cache, FileFd &output,
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index 0c37e231d..22767bd7b 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -91,6 +91,22 @@ namespace EDSP /*{{{*/
std::vector<bool> const &pkgset,
OpProgress *Progress = NULL);
+ /** \brief creates a limited scenario representing the package universe
+ *
+ * This method works similar to #WriteScenario as it works in the same
+ * way but doesn't send the complete universe to the solver but only
+ * packages reachable from installed packages or packages marked for
+ * install.
+ *
+ * \param Cache is the known package universe
+ * \param output is written to this "file"
+ * \param Progress is an instance to report progress to
+ *
+ * \return true if universe was composed successfully, otherwise false
+ */
+ APT_PUBLIC bool WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
+ OpProgress *Progress = NULL);
+
/** \brief waits and acts on the information returned from the solver
*
* This method takes care of interpreting whatever the solver sends