diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-01-07 18:48:47 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-01-07 18:48:47 +0100 |
commit | fa321bf3dbf363879cfc799b6c1cc4e5af50ffd8 (patch) | |
tree | 99b7519226389fa71c92bfddd810126fc3b6cfb6 /apt-pkg/deb/dpkgpm.cc | |
parent | d7bab8f1142e474ac4bafd139e93439aeddfd546 (diff) | |
parent | 760d4968005c97f0d5fd6403633f367aac89c763 (diff) |
* merged the apt--DoListUpdate branch, this provides a common interface
for "apt-get update" like operations for the frontends and also provides
hooks to run stuff in APT::Update::{Pre,Post}-Invoke
* merged the apt--DoListUpdate branch, this provides a common interface
for "apt-get update" like operations for the frontends and also provides
hooks to run stuff in APT::Update::{Pre,Post}-Invoke
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index afedc3c13..8123a7aba 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -15,6 +15,7 @@ #include <apt-pkg/pkgrecords.h> #include <apt-pkg/strutl.h> #include <apti18n.h> +#include <apt-pkg/fileutl.h> #include <unistd.h> #include <stdlib.h> @@ -96,68 +97,6 @@ bool pkgDPkgPM::Remove(PkgIterator Pkg,bool Purge) return true; } /*}}}*/ -// DPkgPM::RunScripts - Run a set of scripts /*{{{*/ -// --------------------------------------------------------------------- -/* This looks for a list of script sto run from the configuration file, - each one is run with system from a forked child. */ -bool pkgDPkgPM::RunScripts(const char *Cnf) -{ - Configuration::Item const *Opts = _config->Tree(Cnf); - if (Opts == 0 || Opts->Child == 0) - return true; - Opts = Opts->Child; - - // Fork for running the system calls - pid_t Child = ExecFork(); - - // This is the child - if (Child == 0) - { - if (chdir("/tmp/") != 0) - _exit(100); - - unsigned int Count = 1; - for (; Opts != 0; Opts = Opts->Next, Count++) - { - if (Opts->Value.empty() == true) - continue; - - if (system(Opts->Value.c_str()) != 0) - _exit(100+Count); - } - _exit(0); - } - - // Wait for the child - int Status = 0; - while (waitpid(Child,&Status,0) != Child) - { - if (errno == EINTR) - continue; - return _error->Errno("waitpid","Couldn't wait for subprocess"); - } - - // Restore sig int/quit - signal(SIGQUIT,SIG_DFL); - signal(SIGINT,SIG_DFL); - - // Check for an error code. - if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0) - { - unsigned int Count = WEXITSTATUS(Status); - if (Count > 100) - { - Count -= 100; - for (; Opts != 0 && Count != 1; Opts = Opts->Next, Count--); - _error->Error("Problem executing scripts %s '%s'",Cnf,Opts->Value.c_str()); - } - - return _error->Error("Sub-process returned an error code"); - } - - return true; -} - /*}}}*/ // DPkgPM::SendV2Pkgs - Send version 2 package info /*{{{*/ // --------------------------------------------------------------------- /* This is part of the helper script communication interface, it sends |