]> git.saurik.com Git - apt.git/commitdiff
write auto-bits before calling dpkg & again after if needed
authorDavid Kalnischkies <david@kalnischkies.de>
Wed, 29 Jun 2016 14:10:12 +0000 (16:10 +0200)
committerJulian Andres Klode <jak@debian.org>
Wed, 31 Aug 2016 11:18:41 +0000 (13:18 +0200)
Writing first means that even in the event of a power-failure the
autobit is saved for future processing instead of "forgotten" so that
the package is treated as manually installed.

In some cases we have to re-run the writing after dpkg is done through
as dpkg can let packages disappear and in such cases apt will move
autobits around (or in that case non-autobits) which we need to store.

(cherry picked from commit 309f497b7280a45e3626493318adb6d39ba5c69b)

apt-pkg/deb/dpkgpm.cc

index 834cb0e25262688d55a02fe4493e59cd401376c2..23d3ff9778acd7c221a00c1d4a927fb0394997ae 100644 (file)
@@ -1248,6 +1248,11 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
    if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false)
       return false;
 
+   auto const noopDPkgInvocation = _config->FindB("Debug::pkgDPkgPM",false);
+   // store auto-bits as they are supposed to be after dpkg is run
+   if (noopDPkgInvocation == false)
+      Cache.writeStateFile(NULL);
+
    // support subpressing of triggers processing for special
    // cases like d-i that runs the triggers handling manually
    bool const TriggersPending = _config->FindB("DPkg::TriggersPending", false);
@@ -1434,7 +1439,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
 
       J = I;
       
-      if (_config->FindB("Debug::pkgDPkgPM",false) == true)
+      if (noopDPkgInvocation == true)
       {
         for (std::vector<const char *>::const_iterator a = Args.begin();
              a != Args.end(); ++a)
@@ -1613,7 +1618,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
    if (pkgPackageManager::SigINTStop)
        _error->Warning(_("Operation was interrupted before it could finish"));
 
-   if (_config->FindB("Debug::pkgDPkgPM",false) == false)
+   if (noopDPkgInvocation == false)
    {
       std::string const oldpkgcache = _config->FindFile("Dir::cache::pkgcache");
       if (oldpkgcache.empty() == false && RealFileExists(oldpkgcache) == true &&
@@ -1630,7 +1635,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
       }
    }
 
-   Cache.writeStateFile(NULL);
+   // disappearing packages can forward their auto-bit
+   if (disappearedPkgs.empty() == false)
+      Cache.writeStateFile(NULL);
 
    d->progress->Stop();