X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/591fd938c3840c4e49d684087a3340e1f0b40020..75a3362b6ada5dae64d6ca7f6a7bff0fcae956bb:/apt-pkg/packagemanager.cc?ds=inline

diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 155408bb4..d6172c6c4 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -13,10 +13,6 @@
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/packagemanager.h"
-#endif
-
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/orderlist.h>
 #include <apt-pkg/depcache.h>
@@ -29,7 +25,7 @@
     
 #include <apti18n.h>    
 #include <iostream>
-									/*}}}*/
+#include <fcntl.h> 
 
 using namespace std;
 
@@ -95,9 +91,10 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
    be downloaded. */
 bool pkgPackageManager::FixMissing()
 {   
+   pkgDepCache::ActionGroup group(Cache);
    pkgProblemResolver Resolve(&Cache);
    List->SetFileList(FileNames);
-   
+
    bool Bad = false;
    for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
@@ -106,7 +103,7 @@ bool pkgPackageManager::FixMissing()
    
       // Okay, this file is missing and we need it. Mark it for keep 
       Bad = true;
-      Cache.MarkKeep(I);
+      Cache.MarkKeep(I, false, false);
    }
  
    // We have to empty the list otherwise it will not have the new changes
@@ -593,7 +590,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
 	  Pkg.State() == pkgCache::PkgIterator::NeedsNothing &&
 	  (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
       {
-	 _error->Error("Internal Error, trying to manipulate a kept package");
+	 _error->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg.Name());
 	 return Failed;
       }
       
@@ -627,16 +624,35 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
    return Completed;
 }
 									/*}}}*/
+// PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/
+// ---------------------------------------------------------------------
+pkgPackageManager::OrderResult 
+pkgPackageManager::DoInstallPostFork(int statusFd)
+{
+      if(statusFd > 0)
+         // FIXME: use SetCloseExec here once it taught about throwing
+	 //        exceptions instead of doing _exit(100) on failure
+	 fcntl(statusFd,F_SETFD,FD_CLOEXEC); 
+      bool goResult = Go(statusFd);
+      if(goResult == false) 
+	 return Failed;
+
+      // if all was fine update the state file
+      if(Res == Completed) {
+	 Cache.writeStateFile(NULL);
+      }
+      return Res;
+};
+
 // PM::DoInstall - Does the installation				/*{{{*/
 // ---------------------------------------------------------------------
 /* This uses the filenames in FileNames and the information in the
    DepCache to perform the installation of packages.*/
-pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int status_fd)
+pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int statusFd)
 {
-   OrderResult Res = OrderInstall();
-   if (Res != Failed)
-      if (Go(status_fd) == false)
-	 return Failed;
-   return Res;
+   if(DoInstallPreFork() == Failed)
+      return Failed;
+   
+   return DoInstallPostFork(statusFd);
 }
 									/*}}}*/