Sfoglia il codice sorgente

Fix --no-act in triggers related code

Closes: #495097
Guillem Jover 18 anni fa
parent
commit
df21e28ec2
5 ha cambiato i file con 62 aggiunte e 35 eliminazioni
  1. 12 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 37 27
      lib/dbmodify.c
  4. 4 2
      src/help.c
  5. 8 6
      src/trigproc.c

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+2008-08-15  Guillem Jover  <guillem@debian.org>
+
+	* lib/dbmodify.c (modstatdb_note): Do not call modstatdb_note_core if
+	cstatus does not allow writting. Move the core functionallity to ...
+	(modstatdb_note_core): ... here. New function.
+	* src/help.c (post_postinst_tasks_core): Do not call trig_incorporate
+	if running under --no-act.
+	* src/trigproc.c (trigproc): Do not call maintainer_script_postinst
+	if running under --no-act.
+	(trig_transitional_activate): Do not call trig_file_interests_save
+	if cstatus does not allow writting.
+
 2008-08-15  Guillem Jover  <guillem@debian.org>
 2008-08-15  Guillem Jover  <guillem@debian.org>
 
 
 	* lib/dpkg-db.h (trig_enqueue_awaited_pend): New function prototype.
 	* lib/dpkg-db.h (trig_enqueue_awaited_pend): New function prototype.

+ 1 - 0
debian/changelog

@@ -18,6 +18,7 @@ dpkg (1.14.21) UNRELEASED; urgency=low
   * When loading the status file fix up any inconsistent package in state
   * When loading the status file fix up any inconsistent package in state
     triggers-awaited w/o the corresponding package with pending triggers.
     triggers-awaited w/o the corresponding package with pending triggers.
     Closes: #487637, #486843, #489068
     Closes: #487637, #486843, #489068
+  * Fix --no-act in triggers related code. Closes: #495097
 
 
   [ Updated scripts translations ]
   [ Updated scripts translations ]
   * Russian (Yuri Kozlov). Closes: #490076
   * Russian (Yuri Kozlov). Closes: #490076

+ 37 - 27
lib/dbmodify.c

@@ -241,6 +241,41 @@ void modstatdb_shutdown(void) {
   free(updatefnbuf);
   free(updatefnbuf);
 }
 }
 
 
+static void
+modstatdb_note_core(struct pkginfo *pkg)
+{
+  assert(cstatus >= msdbrw_write);
+
+  varbufreset(&uvb);
+  varbufrecord(&uvb, pkg, &pkg->installed);
+
+  if (fwrite(uvb.buf, 1, uvb.used, importanttmp) != uvb.used)
+    ohshite(_("unable to write updated status of `%.250s'"), pkg->name);
+  if (fflush(importanttmp))
+    ohshite(_("unable to flush updated status of `%.250s'"), pkg->name);
+  if (ftruncate(fileno(importanttmp), uvb.used))
+    ohshite(_("unable to truncate for updated status of `%.250s'"), pkg->name);
+  if (fsync(fileno(importanttmp)))
+    ohshite(_("unable to fsync updated status of `%.250s'"), pkg->name);
+  if (fclose(importanttmp))
+    ohshite(_("unable to close updated status of `%.250s'"), pkg->name);
+  sprintf(updatefnrest, IMPORTANTFMT, nextupdate);
+  if (rename(importanttmpfile, updatefnbuf))
+    ohshite(_("unable to install updated status of `%.250s'"), pkg->name);
+
+  /* Have we made a real mess? */
+  assert(strlen(updatefnrest) <= IMPORTANTMAXLEN);
+
+  nextupdate++;
+
+  if (nextupdate > MAXUPDATES) {
+    modstatdb_checkpoint();
+    nextupdate = 0;
+  }
+
+  createimptmp();
+}
+
 /* Note: If anyone wants to set some triggers-pending, they must also
 /* Note: If anyone wants to set some triggers-pending, they must also
  * set status appropriately, or we will undo it. That is, it is legal
  * set status appropriately, or we will undo it. That is, it is legal
  * to call this when pkg->status and pkg->trigpend_head disagree and
  * to call this when pkg->status and pkg->trigpend_head disagree and
@@ -250,8 +285,6 @@ void modstatdb_shutdown(void) {
 void modstatdb_note(struct pkginfo *pkg) {
 void modstatdb_note(struct pkginfo *pkg) {
   struct trigaw *ta;
   struct trigaw *ta;
 
 
-  assert(cstatus >= msdbrw_write);
-
   onerr_abort++;
   onerr_abort++;
 
 
   if (pkg->status != stat_triggerspending &&
   if (pkg->status != stat_triggerspending &&
@@ -268,31 +301,8 @@ void modstatdb_note(struct pkginfo *pkg) {
 	      versiondescribe(&pkg->installed.version, vdew_nonambig));
 	      versiondescribe(&pkg->installed.version, vdew_nonambig));
   statusfd_send("status: %s: %s", pkg->name, statusinfos[pkg->status].name);
   statusfd_send("status: %s: %s", pkg->name, statusinfos[pkg->status].name);
 
 
-  varbufreset(&uvb);
-  varbufrecord(&uvb, pkg, &pkg->installed);
-  if (fwrite(uvb.buf, 1, uvb.used, importanttmp) != uvb.used)
-    ohshite(_("unable to write updated status of `%.250s'"), pkg->name);
-  if (fflush(importanttmp))
-    ohshite(_("unable to flush updated status of `%.250s'"), pkg->name);
-  if (ftruncate(fileno(importanttmp), uvb.used))
-    ohshite(_("unable to truncate for updated status of `%.250s'"), pkg->name);
-  if (fsync(fileno(importanttmp)))
-    ohshite(_("unable to fsync updated status of `%.250s'"), pkg->name);
-  if (fclose(importanttmp))
-    ohshite(_("unable to close updated status of `%.250s'"), pkg->name);
-  sprintf(updatefnrest, IMPORTANTFMT, nextupdate);
-  if (rename(importanttmpfile, updatefnbuf))
-    ohshite(_("unable to install updated status of `%.250s'"), pkg->name);
-  assert(strlen(updatefnrest)<=IMPORTANTMAXLEN); /* or we've made a real mess */
-
-  nextupdate++;  
-
-  if (nextupdate > MAXUPDATES) {
-    modstatdb_checkpoint();
-    nextupdate= 0;
-  }
-
-  createimptmp();
+  if (cstatus >= msdbrw_write)
+    modstatdb_note_core(pkg);
 
 
   if (!pkg->trigpend_head && pkg->othertrigaw_head) {
   if (!pkg->trigpend_head && pkg->othertrigaw_head) {
     /* Automatically remove us from other packages' Triggers-Awaited.
     /* Automatically remove us from other packages' Triggers-Awaited.

+ 4 - 2
src/help.c

@@ -239,8 +239,10 @@ post_postinst_tasks_core(struct pkginfo *pkg)
 {
 {
   modstatdb_note(pkg);
   modstatdb_note(pkg);
 
 
-  debug(dbg_triggersdetail, "post_postinst_tasks_core - trig_incorporate");
-  trig_incorporate(msdbrw_write, admindir);
+  if (!f_noact) {
+    debug(dbg_triggersdetail, "post_postinst_tasks_core - trig_incorporate");
+    trig_incorporate(msdbrw_write, admindir);
+  }
 }
 }
 
 
 static void
 static void

+ 8 - 6
src/trigproc.c

@@ -298,9 +298,11 @@ trigproc(struct pkginfo *pkg)
 		pkg->status = stat_halfconfigured;
 		pkg->status = stat_halfconfigured;
 		modstatdb_note(pkg);
 		modstatdb_note(pkg);
 
 
-		sincenothing = 0;
-		maintainer_script_postinst(pkg, "triggered",
-		                           namesarg.buf + 1, NULL);
+		if (!f_noact) {
+			sincenothing = 0;
+			maintainer_script_postinst(pkg, "triggered",
+			                           namesarg.buf + 1, NULL);
+		}
 
 
 		/* This is to cope if the package triggers itself: */
 		/* This is to cope if the package triggers itself: */
 		pkg->status = pkg->trigaw.head ? stat_triggersawaited :
 		pkg->status = pkg->trigaw.head ? stat_triggersawaited :
@@ -361,10 +363,10 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
 		              transitional_interest_callback_ro, NULL, pkg);
 		              transitional_interest_callback_ro, NULL, pkg);
 	}
 	}
 	iterpkgend(it);
 	iterpkgend(it);
-	if (cstatus >= msdbrw_write)
+	if (cstatus >= msdbrw_write) {
 		modstatdb_checkpoint();
 		modstatdb_checkpoint();
-
-	trig_file_interests_save();
+		trig_file_interests_save();
+	}
 }
 }
 
 
 /*========== hook setup ==========*/
 /*========== hook setup ==========*/