+static std::string getDpkgStatusLocation(Configuration &Cnf) {
+ auto const cnfstatedir = Cnf.Find("Dir::State", "var/lib/apt/");
+ std::string statedir;
+ if (APT::String::Endswith(cnfstatedir, "/apt/"))
+ statedir.assign(cnfstatedir, 0, cnfstatedir.length() - 5);
+ else if (APT::String::Endswith(cnfstatedir, "/apt"))
+ statedir.assign(cnfstatedir, 0, cnfstatedir.length() - 4);
+ if (statedir.empty())
+ Cnf.Set("Dir::State", "var/lib/dpkg");
+ else
+ Cnf.Set("Dir::State", flCombine(statedir, "dpkg"));
+ auto const cnfrootdir = Cnf.Find("RootDir");
+ if (Cnf.Exists("RootDir") == true)
+ Cnf.Set("RootDir", "");
+ Cnf.Set("Dir::State::status", "status");
+ auto const statusfile = Cnf.FindFile("Dir::State::status");
+ if (cnfrootdir.empty() == false)
+ Cnf.Set("RootDir", cnfrootdir);
+ Cnf.Set("Dir::State", cnfstatedir);
+ return statusfile;
+}