summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Jackson <ian@davenant.greenend.org.uk>2008-03-28 16:52:56 +0200
committerGuillem Jover <guillem@debian.org>2008-03-30 12:46:43 +0300
commitfb732996116eabe5ce7f2f3618a20b2d97b9890a (patch)
treed49d6a05ae0c8aacfc7e3b8bb0450f9b5ac98ea3 /src
parent56cabe4594ccbc3927fd78669bee9ba73e2660a7 (diff)
downloaddpkg-fb732996116eabe5ce7f2f3618a20b2d97b9890a.tar.gz
Cleanup on maintainer script failures
Diffstat (limited to 'src')
-rw-r--r--src/help.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/help.c b/src/help.c
index e4db9f072..8e00a2df7 100644
--- a/src/help.c
+++ b/src/help.c
@@ -230,6 +230,12 @@ post_script_tasks(void)
ensure_diversions();
}
+static void
+cu_post_script_tasks(int argc, void **argv)
+{
+ post_script_tasks();
+}
+
static void setexecute(const char *path, struct stat *stab) {
if ((stab->st_mode & 0555) == 0555) return;
if (!chmod(path,0755)) return;
@@ -240,6 +246,8 @@ static int do_script(const char *pkg, const char *scriptname, const char *script
int c1, r;
setexecute(scriptpath,stab);
+ push_cleanup(cu_post_script_tasks, ehflag_bombout, NULL, 0, 0);
+
c1= m_fork();
if (!c1) {
const char **narglist;
@@ -255,6 +263,9 @@ static int do_script(const char *pkg, const char *scriptname, const char *script
script_catchsignals(); /* This does a push_cleanup() */
r= waitsubproc(c1,name,warn);
pop_cleanup(ehflag_normaltidy);
+
+ pop_cleanup(ehflag_normaltidy);
+
return r;
}
@@ -368,9 +379,11 @@ int maintainer_script_alternative(struct pkginfo *pkg,
_("dpkg: warning - unable to stat %s `%.250s': %s\n"),
buf,oldscriptpath,strerror(errno));
} else {
- if (!do_script(pkg->name, scriptname, oldscriptpath, &stab, arglist, _("unable to execute %s"), buf, PROCWARN))
+ if (!do_script(pkg->name, scriptname, oldscriptpath, &stab, arglist,
+ _("unable to execute %s"), buf, PROCWARN)) {
+ post_script_tasks();
return 1;
- post_script_tasks();
+ }
}
fprintf(stderr, _("dpkg - trying script from the new package instead ...\n"));