From 590f1923121815b36ef889033c1c416a23cbe9a2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 27 Jul 2011 15:20:35 +0100 Subject: SmartConfigure and SmartUnPack have got smarter! The full descriptions of what they now do is in the apt-pkg/packagemanager.cc file. The short version is that they will both put the system in a state where there operation can be achived, this involves calling themselves and each other recursively. Because SmartConfigure can now configure a package and all its dependancies itself, there is no current need for DepAdd (at least in packagemanager.cc), SmartConfigure also performs the function of the short lived VerifyConfigure as it checks through all the dependancies before performing configuration. Another change is to use the ConfigureAll method in OrderInstall to clean up any packages left unconfigured during ImmConfigureAll. This is necessary to inprove the safety of ImmConfiguration and because of the new SIGINT functionality of dpkgpm.cc relies on no packages being left unconfigured between pairs of dpkg calls. While writing this commit log, I have realised that the SIGINT stuff is a prototype and not ready to be used yet as I have only tested it twice. --- apt-pkg/deb/dpkgpm.cc | 15 ++++++++++++--- apt-pkg/deb/dpkgpm.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5fbd1801a..3dbbd7c97 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -888,7 +889,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) OpenLog(); // this loop is runs once per operation - for (vector::const_iterator I = List.begin(); I != List.end();) + for (vector::const_iterator I = List.begin(); I != List.end() && !pkgPackageManager::SigINTStop;) { // Do all actions with the same Op in one run vector::const_iterator J = I; @@ -920,7 +921,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // the argument list is split in a way that A depends on B // and they are in the same "--configure A B" run // - with the split they may now be configured in different - // runs + // runs if (J - I > (signed)MaxArgs) J = I + MaxArgs; @@ -1062,7 +1063,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) it to all processes in the group. Since dpkg ignores the signal it doesn't die but we do! So we must also ignore it */ sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); - sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN); + sighandler_t old_SIGINT = signal(SIGINT,SigINT); // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1207,6 +1208,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); return _error->Errno("waitpid","Couldn't wait for subprocess"); } @@ -1247,6 +1249,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); if(master >= 0) @@ -1308,6 +1311,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) Cache.writeStateFile(NULL); return true; } + +void SigINT(int sig) { + cout << " -- SIGINT -- " << endl; + if (_config->FindB("APT::Immediate-Configure-All",false)) + pkgPackageManager::SigINTStop = true; +} /*}}}*/ // pkgDpkgPM::Reset - Dump the contents of the command list /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index b7b5a6def..fb92c58ea 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -113,4 +113,6 @@ class pkgDPkgPM : public pkgPackageManager virtual ~pkgDPkgPM(); }; +void SigINT(int sig); + #endif -- cgit v1.2.3 From 1cecd4376cebdd0225ee91707b7630bc35959474 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 31 Jul 2011 16:26:39 +0100 Subject: Only allow interupts when using, Immediate-Configure-All. TODO for dpkgpm: Useful messages about the interupt, what was done to what packages and what was not done to what packages. Only fail when the system is in a clean state, at the moment it will fail either a configure or install run. --- apt-pkg/deb/dpkgpm.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3dbbd7c97..479126658 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -889,7 +889,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) OpenLog(); // this loop is runs once per operation - for (vector::const_iterator I = List.begin(); I != List.end() && !pkgPackageManager::SigINTStop;) + for (vector::const_iterator I = List.begin(); I != List.end();) { // Do all actions with the same Op in one run vector::const_iterator J = I; @@ -921,7 +921,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // the argument list is split in a way that A depends on B // and they are in the same "--configure A B" run // - with the split they may now be configured in different - // runs + // runs, using Immediate-Configure-All can help prevent this. if (J - I > (signed)MaxArgs) J = I + MaxArgs; @@ -1064,6 +1064,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) it doesn't die but we do! So we must also ignore it */ sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); sighandler_t old_SIGINT = signal(SIGINT,SigINT); + + // Check here for any SIGINT + if (pkgPackageManager::SigINTStop) break; // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1102,7 +1105,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) sigprocmask(SIG_SETMASK, &original_sigmask, 0); } } - // Fork dpkg pid_t Child; _config->Set("APT::Keep-Fds::",fd[1]); -- cgit v1.2.3 From 17182c0c66630c2fcba938edb5b27668f7495854 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 1 Aug 2011 12:27:10 +0100 Subject: Only stop on SigInt if the system state is right (still needs more testing). More inprovements to the package manager to prevent packages from being configured twice. --- apt-pkg/deb/dpkgpm.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 479126658..68d9ca1de 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1066,7 +1066,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGINT = signal(SIGINT,SigINT); // Check here for any SIGINT - if (pkgPackageManager::SigINTStop) break; + if (pkgPackageManager::SigINTStop && + (I->Op == Item::Install || I->Op == Item::Remove || I->Op == Item::Purge)) break; // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1315,7 +1316,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) } void SigINT(int sig) { - cout << " -- SIGINT -- " << endl; if (_config->FindB("APT::Immediate-Configure-All",false)) pkgPackageManager::SigINTStop = true; } -- cgit v1.2.3 From 11b87a08ee6952c5b66b14842283df3ea26b90ac Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 2 Aug 2011 10:29:11 +0100 Subject: Inproved the SIGINT stop in the dpkgpm, not perfect yet but it should work when using Immediate-Configure-All. --- apt-pkg/deb/dpkgpm.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 68d9ca1de..57361ccdc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -954,6 +954,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]); Args[n++] = status_fd_buf; Size += strlen(Args[n-1]); + + unsigned long const Op = I->Op; switch (I->Op) { @@ -1066,9 +1068,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGINT = signal(SIGINT,SigINT); // Check here for any SIGINT - if (pkgPackageManager::SigINTStop && - (I->Op == Item::Install || I->Op == Item::Remove || I->Op == Item::Purge)) break; - + if (pkgPackageManager::SigINTStop && (Op == Item::Remove || Op == Item::Purge || Op == Item::Install)) + break; + + // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1290,6 +1293,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) } } CloseLog(); + + if (pkgPackageManager::SigINTStop) + _error->Warning(_("Operation was interrupted before it could finish")); if (RunScripts("DPkg::Post-Invoke") == false) return false; -- cgit v1.2.3