This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=47e79b22a18fa1c7cfb5f48a0aa1de5065c7dbee

commit 47e79b22a18fa1c7cfb5f48a0aa1de5065c7dbee
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Aug 6 17:48:51 2025 +0200

    dpkg: Pass cidir and cidirrest before scriptname to maintscript functions
    
    This is the pathname to use for the new maintscript, and it makes more
    sense to pass it before the scriptname itself. This also makes the
    function prototypes closer to the ones with no pathname where the
    scriptname is followed by the script arguments.
    
    Changelog: internal
---
 src/main/cleanup.c |  6 +++---
 src/main/main.h    |  6 +++---
 src/main/script.c  |  9 +++++----
 src/main/unpack.c  | 10 +++++-----
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/main/cleanup.c b/src/main/cleanup.c
index 11126556d..a15fb759a 100644
--- a/src/main/cleanup.c
+++ b/src/main/cleanup.c
@@ -192,7 +192,7 @@ void cu_preinstverynew(int argc, void **argv) {
   char *cidirrest= (char*)argv[2];
 
   if (cleanup_pkg_failed++) return;
-  maintscript_new(pkg, POSTRMFILE, cidir, cidirrest,
+  maintscript_new(pkg, cidir, cidirrest, POSTRMFILE,
                   "abort-install", NULL);
   pkg_set_status(pkg, PKG_STAT_NOTINSTALLED);
   pkg_clear_eflags(pkg, PKG_EFLAG_REINSTREQ);
@@ -207,7 +207,7 @@ void cu_preinstnew(int argc, void **argv) {
   char *cidirrest= (char*)argv[2];
 
   if (cleanup_pkg_failed++) return;
-  maintscript_new(pkg, POSTRMFILE, cidir, cidirrest,
+  maintscript_new(pkg, cidir, cidirrest, POSTRMFILE,
                   "abort-install",
                   versiondescribe(&pkg->installed.version, vdew_nonambig),
                   versiondescribe(&pkg->available.version, vdew_nonambig),
@@ -225,7 +225,7 @@ void cu_preinstupgrade(int argc, void **argv) {
   enum pkgstatus *oldstatusp= (enum pkgstatus*)argv[3];
 
   if (cleanup_pkg_failed++) return;
-  maintscript_new(pkg, POSTRMFILE, cidir, cidirrest,
+  maintscript_new(pkg, cidir, cidirrest, POSTRMFILE,
                   "abort-upgrade",
                   versiondescribe(&pkg->installed.version, vdew_nonambig),
                   versiondescribe(&pkg->available.version, vdew_nonambig),
diff --git a/src/main/main.h b/src/main/main.h
index 454edebfc..23dc42ec9 100644
--- a/src/main/main.h
+++ b/src/main/main.h
@@ -242,12 +242,12 @@ int
 maintscript_installed(struct pkginfo *pkg, const char *scriptname, ...)
        DPKG_ATTR_SENTINEL;
 int maintscript_new(struct pkginfo *pkg,
-                    const char *scriptname,
-                    const char *cidir, char *cidirrest, ...)
+                    const char *cidir, char *cidirrest,
+                    const char *scriptname, ...)
        DPKG_ATTR_SENTINEL;
 int maintscript_fallback(struct pkginfo *pkg,
-                         const char *scriptname,
                          const char *cidir, char *cidirrest,
+                         const char *scriptname,
                          const char *ifok, const char *iffallback);
 
 /* Callers wanting to run the postinst use these two as they want to postpone
diff --git a/src/main/script.c b/src/main/script.c
index c6d7e7934..7e5000f1e 100644
--- a/src/main/script.c
+++ b/src/main/script.c
@@ -285,8 +285,9 @@ maintscript_postinst(struct pkginfo *pkg, ...)
 }
 
 int
-maintscript_new(struct pkginfo *pkg, const char *scriptname,
-                const char *cidir, char *cidirrest, ...)
+maintscript_new(struct pkginfo *pkg,
+                const char *cidir, char *cidirrest,
+                const char *scriptname, ...)
 {
        struct command cmd;
        struct stat stab;
@@ -297,7 +298,7 @@ maintscript_new(struct pkginfo *pkg, const char *scriptname,
        scriptdesc = str_fmt(_("new %s package %s maintainer script"),
                             pkg_name(pkg, pnaw_nonambig), scriptname);
 
-       va_start(args, cidirrest);
+       va_start(args, scriptname);
        command_init(&cmd, cidir, scriptdesc);
        command_add_arg(&cmd, scriptname);
        command_add_argv(&cmd, args);
@@ -325,8 +326,8 @@ maintscript_new(struct pkginfo *pkg, const char *scriptname,
 
 int
 maintscript_fallback(struct pkginfo *pkg,
-                     const char *scriptname,
                      const char *cidir, char *cidirrest,
+                     const char *scriptname,
                      const char *ifok, const char *iffallback)
 {
        struct command cmd;
diff --git a/src/main/unpack.c b/src/main/unpack.c
index ba440aee7..e729a4399 100644
--- a/src/main/unpack.c
+++ b/src/main/unpack.c
@@ -1383,7 +1383,7 @@ void process_archive(const char *filename) {
     pkg_set_status(pkg, PKG_STAT_HALFCONFIGURED);
     modstatdb_note(pkg);
     push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, 1, (void *)pkg);
-    maintscript_fallback(pkg, PRERMFILE, cidir, cidirrest,
+    maintscript_fallback(pkg, cidir, cidirrest, PRERMFILE,
                          "upgrade", "failed-upgrade");
     pkg_set_status(pkg, PKG_STAT_UNPACKED);
     oldversionstatus = PKG_STAT_UNPACKED;
@@ -1428,12 +1428,12 @@ void process_archive(const char *filename) {
   if (oldversionstatus == PKG_STAT_NOTINSTALLED) {
     push_cleanup(cu_preinstverynew, ~ehflag_normaltidy,
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
-    maintscript_new(pkg, PREINSTFILE, cidir, cidirrest,
+    maintscript_new(pkg, cidir, cidirrest, PREINSTFILE,
                     "install", NULL);
   } else if (oldversionstatus == PKG_STAT_CONFIGFILES) {
     push_cleanup(cu_preinstnew, ~ehflag_normaltidy,
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
-    maintscript_new(pkg, PREINSTFILE, cidir, cidirrest,
+    maintscript_new(pkg, cidir, cidirrest, PREINSTFILE,
                     "install",
                     versiondescribe(&pkg->installed.version, vdew_nonambig),
                     versiondescribe(&pkg->available.version, vdew_nonambig),
@@ -1441,7 +1441,7 @@ void process_archive(const char *filename) {
   } else {
     push_cleanup(cu_preinstupgrade, ~ehflag_normaltidy,
                  
4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus);
-    maintscript_new(pkg, PREINSTFILE, cidir, cidirrest,
+    maintscript_new(pkg, cidir, cidirrest, PREINSTFILE,
                     "upgrade",
                     versiondescribe(&pkg->installed.version, vdew_nonambig),
                     versiondescribe(&pkg->available.version, vdew_nonambig),
@@ -1579,7 +1579,7 @@ void process_archive(const char *filename) {
     pkg_set_status(pkg, PKG_STAT_HALFINSTALLED);
     modstatdb_note(pkg);
     push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, 1, (void *)pkg);
-    maintscript_fallback(pkg, POSTRMFILE, cidir, cidirrest,
+    maintscript_fallback(pkg, cidir, cidirrest, POSTRMFILE,
                          "upgrade", "failed-upgrade");
   }
 

-- 
Dpkg.Org's dpkg

Reply via email to