[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#58859: display-maintainer-script-filename-on-error patch



This patch against dpkg CVS addresses #58859 - it gives users more
descriptive error messages when installing packages with broken maintainer
scripts (system-observer-evil is a purposefully-broken version of a local
package of mine called system-observer):

[scenario: postinst lacks #!/bin/sh at the top]

frantica:~/src$ sudo dpkg -i system-observer-evil_0.7-1_i386.deb
(Reading database ... 56946 files and directories currently installed.)
Preparing to replace system-observer-evil 0.7-1 (using system-observer-evil_0.7-1_i386.deb) ...
Unpacking replacement system-observer-evil ...
Setting up system-observer-evil (0.7-1) ...
dpkg (subprocess): unable to execute /var/lib/dpkg/info/system-observer-evil.postinst: Exec format error
dpkg: error processing system-observer-evil (--install):
 subprocess /var/lib/dpkg/info/system-observer-evil.postinst returned error exit status 2
Errors were encountered while processing:
 system-observer-evil

[scenario: postinst has 'exit 1' at the end]

frantica:~/src$ sudo dpkg -i system-observer-evil_0.7-1_i386.deb
(Reading database ... 56946 files and directories currently installed.)
Preparing to replace system-observer-evil 0.7-1 (using system-observer-evil_0.7-1_i386.deb) ...
Unpacking replacement system-observer-evil ...
Setting up system-observer-evil (0.7-1) ...
dpkg: error processing system-observer-evil (--install):
 subprocess /var/lib/dpkg/info/system-observer-evil.postinst returned error exit status 1
Errors were encountered while processing:
 system-observer-evil

Here's the patch:

--- main/help.c.orig	Fri Jul 20 13:05:00 2001
+++ main/help.c	Fri Jul 20 14:33:15 2001
@@ -283,13 +283,11 @@
   char *const *arglist;
   struct stat stab;
   va_list ap;
-  char buf[100];
 
   scriptpath= pkgadminfile(pkg,scriptname);
   va_start(ap,description);
   arglist= vbuildarglist(scriptname,ap);
   va_end(ap);
-  sprintf(buf,"%s script",description);
 
   if (stat(scriptpath,&stab)) {
     if (errno == ENOENT) {
@@ -298,7 +296,7 @@
     }
     ohshite(_("unable to stat installed %s script `%.250s'"),description,scriptpath);
   }
-  do_script(pkg->name, scriptname, scriptpath, &stab, arglist, _("unable to execute %s"), buf, 0);
+  do_script(pkg->name, scriptname, scriptpath, &stab, arglist, _("unable to execute %s"), scriptpath, 0);
   ensure_diversions();
   return 1;
 }
@@ -309,12 +307,10 @@
   char *const *arglist;
   struct stat stab;
   va_list ap;
-  char buf[100];
   
   va_start(ap,cidirrest);
   arglist= vbuildarglist(scriptname,ap);
   va_end(ap);
-  sprintf(buf,"%s script",description);
 
   strcpy(cidirrest,scriptname);
   if (stat(cidir,&stab)) {
@@ -324,7 +320,7 @@
     }
     ohshite(_("unable to stat new %s script `%.250s'"),description,cidir);
   }
-  do_script(pkgname, scriptname, cidir, &stab, arglist, _("unable to execute new %s"), buf, 0);
+  do_script(pkgname, scriptname, cidir, &stab, arglist, _("unable to execute new script %s"), cidir, 0);
   ensure_diversions();
   return 1;
 }
@@ -343,7 +339,7 @@
                         ifok,versiondescribe(&pkg->available.version,
                                              vdew_nonambig),
                         (char*)0);
-  sprintf(buf,_("old %s script"),description);
+  sprintf(buf,_("old script %s"),oldscriptpath);
   if (stat(oldscriptpath,&stab)) {
     if (errno == ENOENT) {
       debug(dbg_scripts,"maintainer_script_alternative nonexistent %s `%s'",
@@ -365,7 +361,7 @@
                                                    vdew_nonambig),
                         (char*)0);
   strcpy(cidirrest,scriptname);
-  sprintf(buf,_("new %s script"),description);
+  sprintf(buf,_("new script %s"),cidir);
 
   if (stat(cidir,&stab)) {
     if (errno == ENOENT)



Reply to: