Bladeren bron

Pass ‘struct pkginfoperfile’ from maint script functions to do_script

This allows us to retrieve package information from either the installed
package or the one being installed from the maintainer script invoking
functions.
Guillem Jover 17 jaren geleden
bovenliggende
commit
ab95f0bb2f
1 gewijzigde bestanden met toevoegingen van 9 en 7 verwijderingen
  1. 9 7
      src/help.c

+ 9 - 7
src/help.c

@@ -247,7 +247,7 @@ static void setexecute(const char *path, struct stat *stab) {
 }
 }
 
 
 static int
 static int
-do_script(struct pkginfo *pkg,
+do_script(struct pkginfo *pkg, struct pkginfoperfile *pif,
           const char *scriptname, const char *scriptpath, struct stat *stab,
           const char *scriptname, const char *scriptpath, struct stat *stab,
           char *const arglist[], const char *desc, const char *name, int warn)
           char *const arglist[], const char *desc, const char *name, int warn)
 {
 {
@@ -302,7 +302,8 @@ vmaintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
     }
     }
     ohshite(_("unable to stat %s `%.250s'"), buf, scriptpath);
     ohshite(_("unable to stat %s `%.250s'"), buf, scriptpath);
   }
   }
-  do_script(pkg, scriptname, scriptpath, &stab, arglist, _("unable to execute %s"), buf, 0);
+  do_script(pkg, &pkg->installed, scriptname, scriptpath, &stab,
+            arglist, _("unable to execute %s"), buf, 0);
 
 
   return 1;
   return 1;
 }
 }
@@ -362,8 +363,8 @@ maintainer_script_new(struct pkginfo *pkg,
     }
     }
     ohshite(_("unable to stat %s `%.250s'"), buf, cidir);
     ohshite(_("unable to stat %s `%.250s'"), buf, cidir);
   }
   }
-  do_script(pkg, scriptname, cidir, &stab, arglist,
-            _("unable to execute %s"), buf, 0);
+  do_script(pkg, &pkg->available, scriptname, cidir, &stab,
+            arglist, _("unable to execute %s"), buf, 0);
   post_script_tasks();
   post_script_tasks();
 
 
   return 1;
   return 1;
@@ -393,8 +394,8 @@ int maintainer_script_alternative(struct pkginfo *pkg,
     warning(_("unable to stat %s '%.250s': %s"),
     warning(_("unable to stat %s '%.250s': %s"),
             buf,oldscriptpath,strerror(errno));
             buf,oldscriptpath,strerror(errno));
   } else {
   } else {
-    if (!do_script(pkg, scriptname, oldscriptpath, &stab, arglist,
-                   _("unable to execute %s"), buf, PROCWARN)) {
+    if (!do_script(pkg, &pkg->installed, scriptname, oldscriptpath, &stab,
+                   arglist, _("unable to execute %s"), buf, PROCWARN)) {
       post_script_tasks();
       post_script_tasks();
       return 1;
       return 1;
     }
     }
@@ -415,7 +416,8 @@ int maintainer_script_alternative(struct pkginfo *pkg,
       ohshite(_("unable to stat %s `%.250s'"),buf,cidir);
       ohshite(_("unable to stat %s `%.250s'"),buf,cidir);
   }
   }
 
 
-  do_script(pkg, scriptname, cidir, &stab, arglist, _("unable to execute %s"), buf, 0);
+  do_script(pkg, &pkg->available, scriptname, cidir, &stab,
+            arglist, _("unable to execute %s"), buf, 0);
   fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
   fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
 
 
   post_script_tasks();
   post_script_tasks();