summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-06-07 10:03:41 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-06-07 10:03:41 +0200
commit614adaa09f9f24dccd9e2e8bb4eb00d17285c92e (patch)
treebc2def8dc62ec49a60fa162b38cd47ee51b77b7e /apt-pkg/deb
parent89b70b5a5c80b15d928b6593604bacc02a1b9a51 (diff)
* apt-pkg/deb/dpkgpm.cc, apt-pkg/contrib/fileutl.{cc,h}:
- move the RunScripts() code into fileutl.{cc,h} * apt-pkg/cachefile.cc: - add support for "APT::Update::{Pre,Post}-Invoke" scripts
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc56
1 files changed, 2 insertions, 54 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 667db8ff2..fe13614c5 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -16,6 +16,7 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
#include <unistd.h>
#include <stdlib.h>
@@ -93,60 +94,7 @@ bool pkgDPkgPM::Remove(PkgIterator Pkg,bool Purge)
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;
+ RunScripts(Cnf);
}
/*}}}*/
// DPkgPM::SendV2Pkgs - Send version 2 package info /*{{{*/