diff options
author | Michael Vogt <mvo@debian.org> | 2014-04-01 13:57:22 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-04-01 13:57:22 +0200 |
commit | 8a1c9010137a8c49d9808f2db34b9ee277138986 (patch) | |
tree | 5ec5c0103cb896407d8c9542fac0ec8ab3313602 /apt-pkg/deb/dpkgpm.cc | |
parent | fa55ccaa85ca8f85251300f5c5f574edc0c3ca71 (diff) | |
parent | 417e83d0d79637266e04c98189c62ce85bcdf737 (diff) |
Merge branch 'debian/sid' into ubuntu/master
Conflicts:
apt-pkg/deb/dpkgpm.cc
debian/apt.auto-removal.sh
debian/changelog
vendor/debian/sources.list.in
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 25a1e6055..c52b83c6e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -10,40 +10,45 @@ // Includes /*{{{*/ #include <config.h> -#include <apt-pkg/dpkgpm.h> -#include <apt-pkg/error.h> +#include <apt-pkg/cachefile.h> #include <apt-pkg/configuration.h> #include <apt-pkg/depcache.h> -#include <apt-pkg/pkgrecords.h> -#include <apt-pkg/strutl.h> +#include <apt-pkg/dpkgpm.h> +#include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> -#include <apt-pkg/cachefile.h> -#include <apt-pkg/packagemanager.h> #include <apt-pkg/install-progress.h> +#include <apt-pkg/packagemanager.h> +#include <apt-pkg/pkgrecords.h> +#include <apt-pkg/strutl.h> +#include <apt-pkg/cacheiterators.h> +#include <apt-pkg/macros.h> +#include <apt-pkg/pkgcache.h> -#include <unistd.h> -#include <stdlib.h> +#include <errno.h> #include <fcntl.h> +#include <grp.h> +#include <pty.h> +#include <pwd.h> +#include <signal.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> #include <sys/select.h> #include <sys/stat.h> -#include <sys/types.h> +#include <sys/time.h> #include <sys/wait.h> -#include <signal.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <algorithm> -#include <sstream> -#include <map> -#include <pwd.h> -#include <grp.h> -#include <iomanip> - #include <termios.h> +#include <time.h> #include <unistd.h> -#include <sys/ioctl.h> -#include <pty.h> -#include <stdio.h> +#include <algorithm> +#include <cstring> +#include <iostream> +#include <map> +#include <set> +#include <string> +#include <utility> +#include <vector> #include <apti18n.h> /*}}}*/ @@ -394,10 +399,14 @@ bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version) that are due to be installed. */ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) { + bool result = true; + Configuration::Item const *Opts = _config->Tree(Cnf); if (Opts == 0 || Opts->Child == 0) return true; Opts = Opts->Child; + + sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN); unsigned int Count = 1; for (; Opts != 0; Opts = Opts->Next, Count++) @@ -405,6 +414,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) if (Opts->Value.empty() == true) continue; + if(_config->FindB("Debug::RunScripts", false) == true) + std::clog << "Running external script with list of all .deb file: '" + << Opts->Value << "'" << std::endl; + // Determine the protocol version string OptSec = Opts->Value; string::size_type Pos; @@ -419,8 +432,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) std::set<int> KeepFDs; MergeKeepFdsFromConfiguration(KeepFDs); int Pipes[2]; - if (pipe(Pipes) != 0) - return _error->Errno("pipe","Failed to create IPC pipe to subprocess"); + if (pipe(Pipes) != 0) { + result = _error->Errno("pipe","Failed to create IPC pipe to subprocess"); + break; + } if (InfoFD != (unsigned)Pipes[0]) SetCloseExec(Pipes[0],true); else @@ -454,8 +469,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) } close(Pipes[0]); FILE *F = fdopen(Pipes[1],"w"); - if (F == 0) - return _error->Errno("fdopen","Faild to open new FD"); + if (F == 0) { + result = _error->Errno("fdopen","Faild to open new FD"); + break; + } // Feed it the filenames. if (Version <= 1) @@ -483,11 +500,14 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) fclose(F); // Clean up the sub process - if (ExecWait(Process,Opts->Value.c_str()) == false) - return _error->Error("Failure running script %s",Opts->Value.c_str()); + if (ExecWait(Process,Opts->Value.c_str()) == false) { + result = _error->Error("Failure running script %s",Opts->Value.c_str()); + break; + } } + signal(SIGPIPE, old_sigpipe); - return true; + return result; } /*}}}*/ // DPkgPM::DoStdin - Read stdin and pass to slave pty /*{{{*/ @@ -1525,28 +1545,18 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) // here but keep the loop going and just report it as a error // for later bool const stopOnError = _config->FindB("Dpkg::StopOnError",true); - - if(stopOnError) - RunScripts("DPkg::Post-Invoke"); - if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) + if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) strprintf(d->dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]); else if (WIFEXITED(Status) != 0) strprintf(d->dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status)); - else + else strprintf(d->dpkg_error, "Sub-process %s exited unexpectedly",Args[0]); + _error->Error("%s", d->dpkg_error.c_str()); - if(d->dpkg_error.size() > 0) - _error->Error("%s", d->dpkg_error.c_str()); - - if(stopOnError) - { - CloseLog(); - StopPtyMagic(); - d->progress->Stop(); - return false; - } - } + if(stopOnError) + break; + } } // dpkg is done at this point d->progress->Stop(); @@ -1577,10 +1587,10 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) } Cache.writeStateFile(NULL); - return true; + return d->dpkg_error.empty(); } -void SigINT(int sig) { +void SigINT(int /*sig*/) { pkgPackageManager::SigINTStop = true; } /*}}}*/ |