The following commit has been merged in the master branch:
commit bbd5801c99ffd0b117beaf4bf24f32fa797ece6a
Author: Guillem Jover <guil...@debian.org>
Date:   Wed Nov 30 03:53:54 2011 +0100

    libdpkg: Pass pkgbin to trig_parse_ci callbacks
    
    [hert...@debian.org:
     - Track pkgbin in struct trigfileint. ]

diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 658b1f5..f5d49f4 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -150,8 +150,9 @@ struct trigkindinfo {
        /* Rest are for everyone: */
        void (*activate_awaiter)(struct pkginfo *pkg /* may be NULL */);
        void (*activate_done)(void);
-       void (*interest_change)(const char *name, struct pkginfo *pkg, int 
signum,
-                               enum trig_options opts);
+       void (*interest_change)(const char *name, struct pkginfo *pkg,
+                               struct pkgbin *pkgbin,
+                               int signum, enum trig_options opts);
 };
 
 static const struct trigkindinfo tki_explicit, tki_file, tki_unknown;
@@ -216,7 +217,8 @@ trk_unknown_activate_done(void)
 }
 
 static void DPKG_ATTR_NORET
-trk_unknown_interest_change(const char *trig, struct pkginfo *pkg, int signum,
+trk_unknown_interest_change(const char *trig, struct pkginfo *pkg,
+                            struct pkgbin *pkgbin, int signum,
                             enum trig_options opts)
 {
        ohshit(_("invalid or unknown syntax in trigger name `%.250s'"
@@ -312,7 +314,8 @@ trk_explicit_activate_awaiter(struct pkginfo *aw)
 }
 
 static void
-trk_explicit_interest_change(const char *trig,  struct pkginfo *pkg, int 
signum,
+trk_explicit_interest_change(const char *trig,  struct pkginfo *pkg,
+                             struct pkgbin *pkgbin, int signum,
                              enum trig_options opts)
 {
        char buf[1024];
@@ -379,7 +382,8 @@ static int filetriggers_edited = -1;
  * but die if already present.
  */
 static void
-trk_file_interest_change(const char *trig, struct pkginfo *pkg, int signum,
+trk_file_interest_change(const char *trig, struct pkginfo *pkg,
+                         struct pkgbin *pkgbin, int signum,
                          enum trig_options opts)
 {
        struct filenamenode *fnn;
@@ -403,6 +407,7 @@ trk_file_interest_change(const char *trig, struct pkginfo 
*pkg, int signum,
 
        tfi = nfmalloc(sizeof(*tfi));
        tfi->pkg = pkg;
+       tfi->pkgbin = pkgbin;
        tfi->fnn = fnn;
        tfi->options = opts;
        tfi->samefile_next = *trigh.namenode_interested(fnn);
@@ -475,6 +480,7 @@ trig_file_interests_ensure(void)
        FILE *f;
        char linebuf[1024], *space;
        struct pkginfo *pkg;
+       struct pkgbin *pkgbin;
        const char *emsg;
 
        if (filetriggers_edited >= 0)
@@ -509,7 +515,8 @@ trig_file_interests_ensure(void)
                                 "package name `%.250s' (for interest in file "
                                 "`%.250s'): %.250s"), space, linebuf, emsg);
                pkg = pkg_db_find(space);
-               trk_file_interest_change(linebuf, pkg, +2, trig_opts);
+               pkgbin = &pkg->installed;
+               trk_file_interest_change(linebuf, pkg, pkgbin, +2, trig_opts);
        }
        pop_cleanup(ehflag_normaltidy);
 ok:
@@ -567,32 +574,33 @@ static const struct trigkindinfo tki_file = {
 /*---------- Trigger control info file. ----------*/
 
 static void
-trig_cicb_interest_change(const char *trig, struct pkginfo *pkg, int signum,
+trig_cicb_interest_change(const char *trig, struct pkginfo *pkg,
+                          struct pkgbin *pkgbin, int signum,
                           enum trig_options opts)
 {
        const struct trigkindinfo *tki = trig_classify_byname(trig);
 
        assert(filetriggers_edited >= 0);
-       tki->interest_change(trig, pkg, signum, opts);
+       tki->interest_change(trig, pkg, pkgbin, signum, opts);
 }
 
 void
 trig_cicb_interest_delete(const char *trig, struct pkginfo *pkg,
-                          enum trig_options opts)
+                          struct pkgbin *pkgbin, enum trig_options opts)
 {
-       trig_cicb_interest_change(trig, pkg, -1, opts);
+       trig_cicb_interest_change(trig, pkg, pkgbin, -1, opts);
 }
 
 void
 trig_cicb_interest_add(const char *trig, struct pkginfo *pkg,
-                       enum trig_options opts)
+                       struct pkgbin *pkgbin, enum trig_options opts)
 {
-       trig_cicb_interest_change(trig, pkg, +1, opts);
+       trig_cicb_interest_change(trig, pkg, pkgbin, +1, opts);
 }
 
 void
 trig_cicb_statuschange_activate(const char *trig, struct pkginfo *pkg,
-                                enum trig_options opts)
+                                struct pkgbin *pkgbin, enum trig_options opts)
 {
        struct pkginfo *aw = pkg;
 
@@ -603,7 +611,7 @@ trig_cicb_statuschange_activate(const char *trig, struct 
pkginfo *pkg,
 
 static void
 parse_ci_call(const char *file, const char *cmd, trig_parse_cicb *cb,
-              const char *trig, struct pkginfo *pkg,
+              const char *trig, struct pkginfo *pkg, struct pkgbin *pkgbin,
               enum trig_options opts)
 {
        const char *emsg;
@@ -614,12 +622,13 @@ parse_ci_call(const char *file, const char *cmd, 
trig_parse_cicb *cb,
                         "syntax in trigger name `%.250s': %.250s"),
                       file, trig, emsg);
        if (cb)
-               cb(trig, pkg, opts);
+               cb(trig, pkg, pkgbin, opts);
 }
 
 void
 trig_parse_ci(const char *file, trig_parse_cicb *interest,
-              trig_parse_cicb *activate, struct pkginfo *pkg)
+              trig_parse_cicb *activate, struct pkginfo *pkg,
+              struct pkgbin *pkgbin)
 {
        FILE *f;
        char linebuf[MAXTRIGDIRECTIVE], *cmd, *spc, *eol;
@@ -649,13 +658,13 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
                while (cisspace(*spc))
                        spc++;
                if (!strcmp(cmd, "interest")) {
-                       parse_ci_call(file, cmd, interest, spc, pkg, 
trig_await);
+                       parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, 
trig_await);
                } else if (!strcmp(cmd, "interest-noawait")) {
-                       parse_ci_call(file, cmd, interest, spc, pkg, 
trig_noawait);
+                       parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, 
trig_noawait);
                } else if (!strcmp(cmd, "activate")) {
-                       parse_ci_call(file, cmd, activate, spc, pkg, 
trig_await);
+                       parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, 
trig_await);
                } else if (!strcmp(cmd, "activate-noawait")) {
-                       parse_ci_call(file, cmd, activate, spc, pkg, 
trig_noawait);
+                       parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, 
trig_noawait);
                } else {
                        ohshit(_("triggers ci file contains unknown directive 
`%.250s'"),
                               cmd);
diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h
index 20399b2..a1c25ff 100644
--- a/lib/dpkg/triglib.h
+++ b/lib/dpkg/triglib.h
@@ -45,6 +45,7 @@ enum trig_options {
 
 struct trigfileint {
        struct pkginfo *pkg;
+       struct pkgbin *pkgbin;
        struct filenamenode *fnn;
        enum trig_options options;
        struct trigfileint *samefile_next;
@@ -95,15 +96,16 @@ void trig_file_interests_ensure(void);
 void trig_file_interests_save(void);
 
 typedef void trig_parse_cicb(const char *trig, struct pkginfo *pkg,
-                             enum trig_options to);
+                             struct pkgbin *pkgbin, enum trig_options to);
 void trig_cicb_interest_delete(const char *trig, struct pkginfo *pkg,
-                               enum trig_options to);
+                             struct pkgbin *pkgbin, enum trig_options to);
 void trig_cicb_interest_add(const char *trig, struct pkginfo *pkg,
-                            enum trig_options to);
+                             struct pkgbin *pkgbin, enum trig_options to);
 void trig_cicb_statuschange_activate(const char *trig, struct pkginfo *pkg,
-                                     enum trig_options to);
+                             struct pkgbin *pkgbin, enum trig_options to);
 void trig_parse_ci(const char *file, trig_parse_cicb *interest,
-                   trig_parse_cicb *activate, struct pkginfo *pkg);
+                   trig_parse_cicb *activate, struct pkginfo *pkg,
+                   struct pkgbin *pkgbin);
 
 void trig_incorporate(enum modstatdb_rw cstatus);
 
diff --git a/src/processarc.c b/src/processarc.c
index fc96368..b151c5e 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -571,7 +571,7 @@ void process_archive(const char *filename) {
 
   trig_activate_packageprocessing(pkg);
   strcpy(cidirrest, TRIGGERSCIFILE);
-  trig_parse_ci(cidir, NULL, trig_cicb_statuschange_activate, pkg);
+  trig_parse_ci(cidir, NULL, trig_cicb_statuschange_activate, pkg, 
&pkg->available);
 
   /* Read the conffiles, and copy the hashes across. */
   newconffiles = NULL;
@@ -1048,8 +1048,8 @@ void process_archive(const char *filename) {
    * Then we go through the new list adding them. */
   strcpy(cidirrest, TRIGGERSCIFILE);
   trig_parse_ci(pkgadminfile(pkg, &pkg->installed, TRIGGERSCIFILE),
-                trig_cicb_interest_delete, NULL, pkg);
-  trig_parse_ci(cidir, trig_cicb_interest_add, NULL, pkg);
+                trig_cicb_interest_delete, NULL, pkg, &pkg->installed);
+  trig_parse_ci(cidir, trig_cicb_interest_add, NULL, pkg, &pkg->available);
   trig_file_interests_save();
 
   /* We also install the new maintainer scripts, and any other
diff --git a/src/remove.c b/src/remove.c
index ec0e6a3..9d633e7 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -293,7 +293,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
                                 "remove", NULL);
 
     trig_parse_ci(pkgadminfile(pkg, &pkg->installed, TRIGGERSCIFILE),
-                  trig_cicb_interest_delete, NULL, pkg);
+                  trig_cicb_interest_delete, NULL, pkg, &pkg->installed);
     trig_file_interests_save();
 
     debug(dbg_general, "removal_bulk cleaning info directory");
diff --git a/src/trigproc.c b/src/trigproc.c
index 973cfb8..c5b231c 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -136,7 +136,7 @@ trig_activate_packageprocessing(struct pkginfo *pkg)
              pkg->set->name);
 
        trig_parse_ci(pkgadminfile(pkg, &pkg->installed, TRIGGERSCIFILE), NULL,
-                     trig_cicb_statuschange_activate, pkg);
+                     trig_cicb_statuschange_activate, pkg, &pkg->installed);
 }
 
 /*========== Actual trigger processing. ==========*/
@@ -351,7 +351,7 @@ trigproc(struct pkginfo *pkg)
 
 static void
 transitional_interest_callback_ro(const char *trig, struct pkginfo *pkg,
-                                  enum trig_options opts)
+                                  struct pkgbin *pkgbin, enum trig_options 
opts)
 {
        struct pkginfo *pend = pkg;
 
@@ -364,12 +364,13 @@ transitional_interest_callback_ro(const char *trig, 
struct pkginfo *pkg,
 
 static void
 transitional_interest_callback(const char *trig, struct pkginfo *pkg,
-                               enum trig_options opts)
+                               struct pkgbin *pkgbin, enum trig_options opts)
 {
        struct pkginfo *pend = pkg;
+       struct pkgbin *pendbin = pkgbin;
 
-       trig_cicb_interest_add(trig, pend, opts);
-       transitional_interest_callback_ro(trig, pend, opts);
+       trig_cicb_interest_add(trig, pend, pendbin, opts);
+       transitional_interest_callback_ro(trig, pend, pendbin, opts);
 }
 
 /*
@@ -393,7 +394,8 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
                trig_parse_ci(pkgadminfile(pkg, &pkg->installed, 
TRIGGERSCIFILE),
                              cstatus >= msdbrw_write ?
                              transitional_interest_callback :
-                             transitional_interest_callback_ro, NULL, pkg);
+                             transitional_interest_callback_ro, NULL,
+                             pkg, &pkg->installed);
                /* Ensure we're not creating incoherent data that can't
                 * be written down. This should never happen in theory but
                 * can happen if you restore an old status file that is

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to