Based on a patch by Ian Jackson <ian@davenant.greenend.org.uk>.
+2008-03-28 Ian Jackson <ian@davenant.greenend.org.uk>,
+ Guillem Jover <guillem@debian.org>
+
+ * src/main.h (maintainer_script_postinst): New prototype.
+ * src/help.c (post_script_tasks): New function.
+ (maintainer_script_installed): Renamed to ...
+ (vmaintainer_script_installed): ... this. Dot not call
+ ensure_diversions.
+ (maintainer_script_installed): New function.
+ (maintainer_script_postinst): Likewise.
+ (maintainer_script_new): Call post_script_tasks instead of directly
+ calling ensure_diversions.
+ (maintainer_script_alternative): Likewise.
+ * src/cleanup.c (cu_prermupgrade): Use maintainer_script_postinst
+ instead of maintainer_script_installed.
+ (cu_prermdeconfigure): Likewise.
+ (cu_prerminfavour): Likewise.
+ (cu_prermremove): Likewise.
+ (deferred_configure): Likewise.
+ * src/configure.c (deferred_configure): Likewise.
+
2008-03-28 Ian Jackson <ian@davenant.greenend.org.uk>,
Guillem Jover <guillem@debian.org>
struct pkginfo *pkg= (struct pkginfo*)argv[0];
if (cleanup_pkg_failed++) return;
- maintainer_script_installed(pkg,POSTINSTFILE,"post-installation",
- "abort-upgrade",
- versiondescribe(&pkg->available.version,
- vdew_nonambig),
- NULL);
+ maintainer_script_postinst(pkg, "abort-upgrade",
+ versiondescribe(&pkg->available.version,
+ vdew_nonambig),
+ NULL);
pkg->eflag &= ~eflagf_reinstreq;
post_postinst_tasks(pkg, stat_installed);
cleanup_pkg_failed--;
struct pkginfo *infavour= (struct pkginfo*)argv[2];
if (conflictor) {
- maintainer_script_installed(deconf, POSTINSTFILE, "post-installation",
- "abort-deconfigure",
- "in-favour", infavour->name,
- versiondescribe(&infavour->available.version,
- vdew_nonambig),
- "removing", conflictor->name,
- versiondescribe(&conflictor->installed.version,
- vdew_nonambig),
- NULL);
+ maintainer_script_postinst(deconf, "abort-deconfigure",
+ "in-favour", infavour->name,
+ versiondescribe(&infavour->available.version,
+ vdew_nonambig),
+ "removing", conflictor->name,
+ versiondescribe(&conflictor->installed.version,
+ vdew_nonambig),
+ NULL);
} else {
- maintainer_script_installed(deconf, POSTINSTFILE, "post-installation",
- "abort-deconfigure",
- "in-favour", infavour->name,
- versiondescribe(&infavour->available.version,
- vdew_nonambig),
- NULL);
+ maintainer_script_postinst(deconf, "abort-deconfigure",
+ "in-favour", infavour->name,
+ versiondescribe(&infavour->available.version,
+ vdew_nonambig),
+ NULL);
}
post_postinst_tasks(deconf, stat_installed);
struct pkginfo *infavour= (struct pkginfo*)argv[1];
if (cleanup_conflictor_failed++) return;
- maintainer_script_installed(conflictor,POSTINSTFILE,"post-installation",
- "abort-remove", "in-favour", infavour->name,
- versiondescribe(&infavour->available.version,
- vdew_nonambig),
- NULL);
+ maintainer_script_postinst(conflictor, "abort-remove",
+ "in-favour", infavour->name,
+ versiondescribe(&infavour->available.version,
+ vdew_nonambig),
+ NULL);
conflictor->eflag &= ~eflagf_reinstreq;
post_postinst_tasks(conflictor, stat_installed);
cleanup_conflictor_failed--;
enum pkgstatus *oldpkgstatus= (enum pkgstatus*)argv[1];
if (cleanup_pkg_failed++) return;
- maintainer_script_installed(pkg,POSTINSTFILE,"post-installation",
- "abort-remove", NULL);
+ maintainer_script_postinst(pkg, "abort-remove", NULL);
pkg->eflag &= ~eflagf_reinstreq;
post_postinst_tasks(pkg, *oldpkgstatus);
cleanup_pkg_failed--;
modstatdb_note(pkg);
- maintainer_script_installed(pkg, POSTINSTFILE, "post-installation",
- "configure",
- informativeversion(&pkg->configversion) ?
- versiondescribe(&pkg->configversion,
- vdew_nonambig) : "",
- NULL);
+ maintainer_script_postinst(pkg, "configure",
+ informativeversion(&pkg->configversion) ?
+ versiondescribe(&pkg->configversion,
+ vdew_nonambig) : "",
+ NULL);
pkg->eflag= eflagv_ok;
post_postinst_tasks(pkg, stat_installed);
modstatdb_note(pkg);
}
+static void
+post_script_tasks(void)
+{
+ ensure_diversions();
+}
+
static void setexecute(const char *path, struct stat *stab) {
if ((stab->st_mode & 0555) == 0555) return;
if (!chmod(path,0755)) return;
return r;
}
-int maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
- const char *description, ...) {
- /* all ...'s are const char*'s */
+static int
+vmaintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
+ const char *description, va_list ap)
+{
const char *scriptpath;
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) {
- debug(dbg_scripts,"maintainer_script_installed nonexistent %s",scriptname);
+ debug(dbg_scripts, "vmaintainer_script_installed nonexistent %s",
+ scriptname);
return 0;
}
ohshite(_("unable to stat installed %s script `%.250s'"),description,scriptpath);
}
do_script(pkg->name, scriptname, scriptpath, &stab, arglist, _("unable to execute %s"), buf, 0);
- ensure_diversions();
+
return 1;
}
-
+
+/* All ...'s are const char*'s. */
+int
+maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
+ const char *description, ...)
+{
+ int r;
+ va_list ap;
+
+ va_start(ap, description);
+ r = vmaintainer_script_installed(pkg, scriptname, description, ap);
+ va_end(ap);
+ if (r)
+ post_script_tasks();
+
+ return r;
+}
+
+int
+maintainer_script_postinst(struct pkginfo *pkg, ...)
+{
+ int r;
+ va_list ap;
+
+ va_start(ap, pkg);
+ r = vmaintainer_script_installed(pkg, POSTINSTFILE, "post-installation", ap);
+ va_end(ap);
+ if (r)
+ ensure_diversions();
+
+ return r;
+}
+
int maintainer_script_new(const char *pkgname,
const char *scriptname, const char *description,
const char *cidir, char *cidirrest, ...) {
ohshite(_("unable to stat new %s script `%.250s'"),description,cidir);
}
do_script(pkgname, scriptname, cidir, &stab, arglist, _("unable to execute new %s"), buf, 0);
- ensure_diversions();
+ post_script_tasks();
+
return 1;
}
} else {
if (!do_script(pkg->name, scriptname, oldscriptpath, &stab, arglist, _("unable to execute %s"), buf, PROCWARN))
return 1;
- ensure_diversions();
+ post_script_tasks();
}
fprintf(stderr, _("dpkg - trying script from the new package instead ...\n"));
do_script(pkg->name, scriptname, cidir, &stab, arglist, _("unable to execute %s"), buf, 0);
fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
- ensure_diversions();
+ post_script_tasks();
+
return 1;
}
const char *scriptname, const char *description,
const char *cidir, char *cidirrest,
const char *ifok, const char *iffallback);
+int maintainer_script_postinst(struct pkginfo *pkg, ...);
void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
void clear_istobes(void);