The following commit has been merged in the master branch:
commit dd1780342ab9fb7fecf4a81e8809504814f03787
Author: Guillem Jover <[email protected]>
Date: Sat Aug 22 01:41:14 2009 +0200
Pass ‘struct pkginfo’ instead of pkg name to maint script functions
This allows us to retrieve package information from the maintainer
script invoking functions.
diff --git a/src/cleanup.c b/src/cleanup.c
index 17dd9cd..ff71fd8 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -173,7 +173,7 @@ void cu_preinstverynew(int argc, void **argv) {
char *cidirrest= (char*)argv[2];
if (cleanup_pkg_failed++) return;
- maintainer_script_new(pkg->name, POSTRMFILE,"post-removal",cidir,cidirrest,
+ maintainer_script_new(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
"abort-install", NULL);
pkg->status= stat_notinstalled;
pkg->eflag &= ~eflag_reinstreq;
@@ -188,7 +188,7 @@ void cu_preinstnew(int argc, void **argv) {
char *cidirrest= (char*)argv[2];
if (cleanup_pkg_failed++) return;
- maintainer_script_new(pkg->name, POSTRMFILE,"post-removal",cidir,cidirrest,
+ maintainer_script_new(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
"abort-install",
versiondescribe(&pkg->installed.version,
vdew_nonambig),
NULL);
@@ -205,7 +205,7 @@ void cu_preinstupgrade(int argc, void **argv) {
enum pkgstatus *oldstatusp= (enum pkgstatus*)argv[3];
if (cleanup_pkg_failed++) return;
- maintainer_script_new(pkg->name, POSTRMFILE,"post-removal",cidir,cidirrest,
+ maintainer_script_new(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
"abort-upgrade",
versiondescribe(&pkg->installed.version,
vdew_nonambig),
diff --git a/src/help.c b/src/help.c
index a66a30e..089d91d 100644
--- a/src/help.c
+++ b/src/help.c
@@ -245,7 +245,12 @@ static void setexecute(const char *path, struct stat
*stab) {
if (!chmod(path,0755)) return;
ohshite(_("unable to set execute permissions on `%.250s'"),path);
}
-static int do_script(const char *pkg, const char *scriptname, const char
*scriptpath, struct stat *stab, char *const arglist[], const char *desc, const
char *name, int warn) {
+
+static int
+do_script(struct pkginfo *pkg,
+ const char *scriptname, const char *scriptpath, struct stat *stab,
+ char *const arglist[], const char *desc, const char *name, int warn)
+{
const char *scriptexec;
int c1, r;
setexecute(scriptpath,stab);
@@ -261,7 +266,7 @@ static int do_script(const char *pkg, const char
*scriptname, const char *script
narglist[r]= arglist[r];
scriptexec= preexecscript(scriptpath,(char * const *)narglist);
narglist[0]= scriptexec;
- if (setenv(MAINTSCRIPTPKGENVVAR, pkg, 1) ||
+ if (setenv(MAINTSCRIPTPKGENVVAR, pkg->name, 1) ||
setenv(MAINTSCRIPTDPKGENVVAR, PACKAGE_VERSION, 1))
ohshite(_("unable to setenv for maintainer script"));
execv(scriptexec,(char * const *)narglist);
@@ -297,7 +302,7 @@ vmaintainer_script_installed(struct pkginfo *pkg, const
char *scriptname,
}
ohshite(_("unable to stat %s `%.250s'"), buf, scriptpath);
}
- do_script(pkg->name, scriptname, scriptpath, &stab, arglist, _("unable to
execute %s"), buf, 0);
+ do_script(pkg, scriptname, scriptpath, &stab, arglist, _("unable to execute
%s"), buf, 0);
return 1;
}
@@ -334,9 +339,11 @@ maintainer_script_postinst(struct pkginfo *pkg, ...)
return r;
}
-int maintainer_script_new(const char *pkgname,
- const char *scriptname, const char *description,
- const char *cidir, char *cidirrest, ...) {
+int
+maintainer_script_new(struct pkginfo *pkg,
+ const char *scriptname, const char *description,
+ const char *cidir, char *cidirrest, ...)
+{
char *const *arglist;
struct stat stab;
va_list ap;
@@ -355,7 +362,7 @@ int maintainer_script_new(const char *pkgname,
}
ohshite(_("unable to stat %s `%.250s'"), buf, cidir);
}
- do_script(pkgname, scriptname, cidir, &stab, arglist,
+ do_script(pkg, scriptname, cidir, &stab, arglist,
_("unable to execute %s"), buf, 0);
post_script_tasks();
@@ -386,7 +393,7 @@ int maintainer_script_alternative(struct pkginfo *pkg,
warning(_("unable to stat %s '%.250s': %s"),
buf,oldscriptpath,strerror(errno));
} else {
- if (!do_script(pkg->name, scriptname, oldscriptpath, &stab, arglist,
+ if (!do_script(pkg, scriptname, oldscriptpath, &stab, arglist,
_("unable to execute %s"), buf, PROCWARN)) {
post_script_tasks();
return 1;
@@ -408,7 +415,7 @@ int maintainer_script_alternative(struct pkginfo *pkg,
ohshite(_("unable to stat %s `%.250s'"),buf,cidir);
}
- do_script(pkg->name, scriptname, cidir, &stab, arglist, _("unable to execute
%s"), buf, 0);
+ do_script(pkg, scriptname, cidir, &stab, arglist, _("unable to execute %s"),
buf, 0);
fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
post_script_tasks();
diff --git a/src/main.h b/src/main.h
index cd8c7b6..c9d8af4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -204,7 +204,7 @@ struct filenamenode *namenodetouse(struct filenamenode*,
struct pkginfo*);
/* all ...'s are const char*'s ... */
int maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
const char *description, ...);
-int maintainer_script_new(const char *pkgname,
+int maintainer_script_new(struct pkginfo *pkg,
const char *scriptname, const char *description,
const char *cidir, char *cidirrest, ...);
int maintainer_script_alternative(struct pkginfo *pkg,
diff --git a/src/processarc.c b/src/processarc.c
index 0116f48..9024681 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -482,19 +482,19 @@ void process_archive(const char *filename) {
if (oldversionstatus == stat_notinstalled) {
push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, NULL, 0,
3,(void*)pkg,(void*)cidir,(void*)cidirrest);
- maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir,
cidirrest,
+ maintainer_script_new(pkg, PREINSTFILE, "pre-installation", cidir,
cidirrest,
"install", NULL);
} else if (oldversionstatus == stat_configfiles) {
push_cleanup(cu_preinstnew, ~ehflag_normaltidy, NULL, 0,
3,(void*)pkg,(void*)cidir,(void*)cidirrest);
- maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir,
cidirrest,
+ maintainer_script_new(pkg, PREINSTFILE, "pre-installation", cidir,
cidirrest,
"install", versiondescribe(&pkg->installed.version,
vdew_nonambig),
NULL);
} else {
push_cleanup(cu_preinstupgrade, ~ehflag_normaltidy, NULL, 0,
4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus);
- maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir,
cidirrest,
+ maintainer_script_new(pkg, PREINSTFILE, "pre-installation", cidir,
cidirrest,
"upgrade", versiondescribe(&pkg->installed.version,
vdew_nonambig),
NULL);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]