]> err.no Git - dpkg/commitdiff
Cleanup on maintainer script failures
authorIan Jackson <ian@davenant.greenend.org.uk>
Fri, 28 Mar 2008 14:52:56 +0000 (16:52 +0200)
committerGuillem Jover <guillem@debian.org>
Sun, 30 Mar 2008 09:46:43 +0000 (12:46 +0300)
ChangeLog
src/help.c

index 0178cade9d56ad7a3ca44da3adfe4b27b7d0e85d..5adc162f7eae5b5fad643359daa5d031b30a2bff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-28  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+       * src/help.c (cu_post_script_tasks): New function.
+       (do_script): Install cu_post_script_tasks as a cleanup handler.
+       (maintainer_script_alternative): Call post_script_tasks if the
+       first do_script invokation fails instead of it succeeding.
+
 2008-03-28  Ian Jackson  <ian@davenant.greenend.org.uk>,
             Guillem Jover  <guillem@debian.org>
 
index e4db9f072bbef72345d4264fd4e45ea7ff5b7564..8e00a2df73e08474ddde91153d190ae6a3c681b3 100644 (file)
@@ -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"));