]> git.saurik.com Git - apt.git/commitdiff
re-add APT::Keep-Fds:: for the dpkg status-fd in dpkgpm.cc as we always need this
authorMichael Vogt <mvo@debian.org>
Mon, 14 Oct 2013 06:42:48 +0000 (08:42 +0200)
committerMichael Vogt <mvo@debian.org>
Mon, 14 Oct 2013 06:42:48 +0000 (08:42 +0200)
apt-pkg/deb/dpkgpm.cc
apt-pkg/iprogress.cc
apt-pkg/packagemanager.cc
apt-private/private-install.cc

index 36d8c829aa0b58e023b258522c85e8d3aaf2a743..fbb5e4c96d4e5cbdfbcb4297aa3903ef21aa073b 100644 (file)
@@ -1264,6 +1264,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
         _error->DumpErrors(std::cerr);
       _error->RevertToStack();
 
+      // this is the dpkg status-fd, we need to keep it
+      _config->Set("APT::Keep-Fds::",fd[1]);
+
        // Tell the progress that its starting and fork dpkg 
       d->progress->Start();
       pid_t Child = ExecFork();
@@ -1316,6 +1319,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
       if (_config->FindB("DPkg::UseIoNice", false) == true)
         ionice(Child);
 
+      // clear the Keep-Fd again
+      _config->Clear("APT::Keep-Fds",fd[1]);
+
       // Wait for dpkg
       int Status = 0;
 
index 7de190da080defbd27a8c4a42a91e4ce0eea02db..bed991d68f3eda0e0b44a610c96c58586920bc32 100644 (file)
@@ -8,7 +8,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sstream>
-
+#include <fcntl.h>
 
 namespace APT {
 namespace Progress {
@@ -42,7 +42,12 @@ void PackageManagerProgressFd::WriteToStatusFd(std::string s)
 
 void PackageManagerProgressFd::Start()
 {
-   _config->Set("APT::Keep-Fds::", OutStatusFd);
+   if(OutStatusFd <= 0)
+      return;
+
+   // FIXME: use SetCloseExec here once it taught about throwing
+   //        exceptions instead of doing _exit(100) on failure
+   fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); 
 
    // send status information that we are about to fork dpkg
    std::ostringstream status;
index 32bc5284ef730f51c878ffca408a99cff174c19e..3690a64c35a2b431f375d498afed3e8097c9b001 100644 (file)
@@ -26,7 +26,6 @@
 #include <apt-pkg/sptr.h>
 
 #include <iostream>
-#include <fcntl.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -1034,18 +1033,11 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
 pkgPackageManager::OrderResult 
 pkgPackageManager::DoInstallPostFork(APT::Progress::PackageManager *progress)
 {
-// FIXME: port to new structure
-#if 0
-      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); 
-#endif
-      bool goResult = Go(progress);
-      if(goResult == false) 
-        return Failed;
-
-      return Res;
+   bool goResult = Go(progress);
+   if(goResult == false) 
+      return Failed;
+   
+   return Res;
 };
                                                                        /*}}}*/ 
 // PM::DoInstall - Does the installation                               /*{{{*/
index d1066c86943caa21ce2e7a2f33810014fec558df..8d72faecc1689600d5df83cfe362a3060b158cf1 100644 (file)
@@ -104,12 +104,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
    if (_config->FindB("APT::Get::Simulate") == true)
    {
       pkgSimulate PM(Cache);
+
       int status_fd = _config->FindI("APT::Status-Fd",-1);
       APT::Progress::PackageManager *progress = NULL;
       if (status_fd > 0)
          progress = new APT::Progress::PackageManagerProgressFd(status_fd);
       pkgPackageManager::OrderResult Res = PM.DoInstall(progress);
       delete progress;
+
       if (Res == pkgPackageManager::Failed)
         return false;
       if (Res != pkgPackageManager::Completed)
@@ -341,6 +343,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
       // FIXME: make this a factory
       // select the right progress
       int status_fd = _config->FindI("APT::Status-Fd",-1);
+
       APT::Progress::PackageManager *progress = NULL;
       if (status_fd > 0)
          progress = new APT::Progress::PackageManagerProgressFd(status_fd);