summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-03-20 09:27:08 +0000
committerJulian Andres Klode <jak@debian.org>2025-03-20 09:27:08 +0000
commit7ef14b64596bd0ca78feaea5fda22b8d524de286 (patch)
tree930952bbc30c82538982dd0343d26573195ba87f
parentd4d1366ef45d4002e1fd05ef8bdcb0c5039b8370 (diff)
parent8ed6bea2083e055b50dfbd8bebf1355cce502f3f (diff)
Merge branch 'smaller-dumps' into 'main'
Write minimized EDSP dumps in crash report, Dir::log::solver See merge request apt-team/apt!465
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/edsp.cc32
-rw-r--r--apt-pkg/edsp.h16
-rw-r--r--apt-private/private-install.cc2
-rwxr-xr-xtest/integration/test-solver3-evaluation5
5 files changed, 52 insertions, 5 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index f462b6eda..96ff8b285 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -368,7 +368,7 @@ const Configuration::getCompressors(bool const Cached) {
{ CompressorsDone.push_back(NAME); compressors.emplace_back(NAME, EXT, BINARY, ARG, DEARG, COST); }
APT_ADD_COMPRESSOR(".", "", "", nullptr, nullptr, 0)
if (_config->Exists("Dir::Bin::zstd") == false || FileExists(_config->Find("Dir::Bin::zstd")) == true)
- APT_ADD_COMPRESSOR("zstd", ".zst", "zstd", "-19", "-d", 60)
+ APT_ADD_COMPRESSOR("zstd", ".zst", "zstd", "-6", "-d", 60)
#ifdef HAVE_ZSTD
else
APT_ADD_COMPRESSOR("zstd", ".zst", "false", nullptr, nullptr, 60)
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 88569d3c4..02e8d4ef4 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,
@@ -786,7 +816,7 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
FileFd output;
bool Okay = CreateDumpFile("EDSP::Resolve", "solver", output);
Okay &= EDSP::WriteRequest(Cache, output, flags, nullptr);
- return Okay && EDSP::WriteScenario(Cache, output, nullptr);
+ return Okay && EDSP::WriteLimitedScenario(Cache, output, nullptr);
}
_error->PushToStack();
int solver_in, solver_out;
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
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 29e23a57e..e3d176ffe 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -107,7 +107,7 @@ static void WriteApportReport(pkgCacheFile &Cache, std::string &title, std::vect
edspFlags |= EDSP::Request::FORBID_NEW_INSTALL;
EDSP::WriteRequest(Cache, edspDump, edspFlags, &Progress);
- EDSP::WriteScenario(Cache, edspDump, &Progress);
+ EDSP::WriteLimitedScenario(Cache, edspDump, &Progress);
edspDump.Close();
Progress.OverallProgress(50, 100, 50, _("Writing error report"));
diff --git a/test/integration/test-solver3-evaluation b/test/integration/test-solver3-evaluation
index af12698b5..a873d5b21 100755
--- a/test/integration/test-solver3-evaluation
+++ b/test/integration/test-solver3-evaluation
@@ -13,6 +13,7 @@ insertpackage 'unstable' 'y' 'all' '3' 'Depends: b | a'
insertpackage 'unstable' 'a' 'all' '3' 'Depends: c'
insertpackage 'unstable' 'b' 'all' '3'
insertpackage 'unstable' 'c' 'all' '3'
+insertpackage 'unstable' 'unrelated' 'all' '3'
setupaptarchive
@@ -114,7 +115,7 @@ AptSolverDump:
Package: apport
Architecture: all
Version: 3
- APT-ID: 5
+ APT-ID: 6
Source: apport
Source-Version: 3
Priority: optional
@@ -208,7 +209,7 @@ Depends: b | a
Package: apport
Architecture: all
Version: 3
-APT-ID: 5
+APT-ID: 6
Source: apport
Source-Version: 3
Priority: optional