Kaynağa Gözat

Use new package status setters instead of direct assignments

This does not apply for package constructors.
Guillem Jover 14 yıl önce
ebeveyn
işleme
7db64047f1
13 değiştirilmiş dosya ile 102 ekleme ve 67 silme
  1. 3 2
      lib/dpkg/parse.c
  2. 3 3
      lib/dpkg/pkg.c
  3. 3 2
      lib/dpkg/test/t-pkginfo.c
  4. 7 4
      lib/dpkg/triglib.c
  5. 6 3
      lib/dpkg/trignote.c
  6. 3 2
      src/archives.c
  7. 11 9
      src/cleanup.c
  8. 5 3
      src/configure.c
  9. 8 3
      src/help.c
  10. 16 15
      src/processarc.c
  11. 17 11
      src/remove.c
  12. 3 2
      src/select.c
  13. 17 8
      src/trigproc.c

+ 3 - 2
lib/dpkg/parse.c

@@ -3,7 +3,7 @@
  * parse.c - database file parsing, main package/field loop
  * parse.c - database file parsing, main package/field loop
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2006,2008-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006,2008-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/parsedump.h>
 #include <dpkg/parsedump.h>
 #include <dpkg/fdio.h>
 #include <dpkg/fdio.h>
 
 
@@ -272,7 +273,7 @@ pkg_parse_verify(struct parsedb_state *ps,
       (pkg->want == want_purge ||
       (pkg->want == want_purge ||
        pkg->want == want_deinstall ||
        pkg->want == want_deinstall ||
        pkg->want == want_hold)) {
        pkg->want == want_hold)) {
-    pkg->want = want_unknown;
+    pkg_set_want(pkg, want_unknown);
   }
   }
 }
 }
 
 

+ 3 - 3
lib/dpkg/pkg.c

@@ -95,9 +95,9 @@ pkg_blank(struct pkginfo *pkg)
 {
 {
 	pkg->set = NULL;
 	pkg->set = NULL;
 	pkg->arch_next = NULL;
 	pkg->arch_next = NULL;
-	pkg->status = stat_notinstalled;
-	pkg->eflag = eflag_ok;
-	pkg->want = want_unknown;
+	pkg_set_status(pkg, stat_notinstalled);
+	pkg_reset_eflags(pkg);
+	pkg_set_want(pkg, want_unknown);
 	pkg->priority = pri_unknown;
 	pkg->priority = pri_unknown;
 	pkg->otherpriority = NULL;
 	pkg->otherpriority = NULL;
 	pkg->section = NULL;
 	pkg->section = NULL;

+ 3 - 2
lib/dpkg/test/t-pkginfo.c

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * libdpkg - Debian packaging suite library routines
  * t-pkginfo.c - test pkginfo handling
  * t-pkginfo.c - test pkginfo handling
  *
  *
- * Copyright © 2009 Guillem Jover <guillem@debian.org>
+ * Copyright © 2009-2010,2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
 
 
 #include <dpkg/test.h>
 #include <dpkg/test.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 
 
 static void
 static void
 test_pkginfo_informative(void)
 test_pkginfo_informative(void)
@@ -32,7 +33,7 @@ test_pkginfo_informative(void)
 	pkg_blank(&pkg);
 	pkg_blank(&pkg);
 	test_fail(pkg_is_informative(&pkg, &pkg.installed));
 	test_fail(pkg_is_informative(&pkg, &pkg.installed));
 
 
-	pkg.want = want_purge;
+	pkg_set_want(&pkg, want_purge);
 	test_pass(pkg_is_informative(&pkg, &pkg.installed));
 	test_pass(pkg_is_informative(&pkg, &pkg.installed));
 
 
 	pkg_blank(&pkg);
 	pkg_blank(&pkg);

+ 7 - 4
lib/dpkg/triglib.c

@@ -4,7 +4,7 @@
  *
  *
  * Copyright © 2007 Canonical Ltd
  * Copyright © 2007 Canonical Ltd
  * Written by Ian Jackson <ian@chiark.greenend.org.uk>
  * Written by Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2008-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/dlist.h>
 #include <dpkg/dlist.h>
 #include <dpkg/dir.h>
 #include <dpkg/dir.h>
 #include <dpkg/trigdeferred.h>
 #include <dpkg/trigdeferred.h>
@@ -94,7 +95,7 @@ trig_record_activation(struct pkginfo *pend, struct pkginfo *aw, const char *tri
 	if (aw && pend->status > stat_configfiles)
 	if (aw && pend->status > stat_configfiles)
 		if (trig_note_aw(pend, aw)) {
 		if (trig_note_aw(pend, aw)) {
 			if (aw->status > stat_triggersawaited)
 			if (aw->status > stat_triggersawaited)
-				aw->status = stat_triggersawaited;
+				pkg_set_status(aw, stat_triggersawaited);
 			modstatdb_note_ifwrite(aw);
 			modstatdb_note_ifwrite(aw);
 		}
 		}
 }
 }
@@ -115,8 +116,10 @@ trig_clear_awaiters(struct pkginfo *notpend)
 			continue;
 			continue;
 		LIST_UNLINK_PART(aw->trigaw, ta, sameaw.);
 		LIST_UNLINK_PART(aw->trigaw, ta, sameaw.);
 		if (!aw->trigaw.head && aw->status == stat_triggersawaited) {
 		if (!aw->trigaw.head && aw->status == stat_triggersawaited) {
-			aw->status = aw->trigpend_head ? stat_triggerspending :
-			             stat_installed;
+			if (aw->trigpend_head)
+				pkg_set_status(aw, stat_triggerspending);
+			else
+				pkg_set_status(aw, stat_installed);
 			modstatdb_note(aw);
 			modstatdb_note(aw);
 		}
 		}
 	}
 	}

+ 6 - 3
lib/dpkg/trignote.c

@@ -4,7 +4,7 @@
  *
  *
  * Copyright © 2007 Canonical Ltd
  * Copyright © 2007 Canonical Ltd
  * Written by Ian Jackson <ian@chiark.greenend.org.uk>
  * Written by Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2008-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/pkg-list.h>
 #include <dpkg/pkg-list.h>
 #include <dpkg/dlist.h>
 #include <dpkg/dlist.h>
 #include <dpkg/triglib.h>
 #include <dpkg/triglib.h>
@@ -63,8 +64,10 @@ trig_note_pend(struct pkginfo *pend, const char *trig)
 	if (!trig_note_pend_core(pend, trig))
 	if (!trig_note_pend_core(pend, trig))
 		return false;
 		return false;
 
 
-	pend->status = pend->trigaw.head ? stat_triggersawaited :
-	               stat_triggerspending;
+	if (pend->trigaw.head)
+		pkg_set_status(pend, stat_triggersawaited);
+	else
+		pkg_set_status(pend, stat_triggerspending);
 
 
 	return true;
 	return true;
 }
 }

+ 3 - 2
src/archives.c

@@ -4,7 +4,7 @@
  *
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
  * Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
- * Copyright © 2007-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -44,6 +44,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/path.h>
 #include <dpkg/path.h>
 #include <dpkg/fdio.h>
 #include <dpkg/fdio.h>
 #include <dpkg/buffer.h>
 #include <dpkg/buffer.h>
@@ -1392,7 +1393,7 @@ wanttoinstall(struct pkginfo *pkg)
     if (f_alsoselect) {
     if (f_alsoselect) {
       printf(_("Selecting previously unselected package %s.\n"),
       printf(_("Selecting previously unselected package %s.\n"),
              pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
              pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
-      pkg->want = want_install;
+      pkg_set_want(pkg, want_install);
       return true;
       return true;
     } else {
     } else {
       printf(_("Skipping unselected package %s.\n"),
       printf(_("Skipping unselected package %s.\n"),

+ 11 - 9
src/cleanup.c

@@ -3,6 +3,7 @@
  * cleanup.c - cleanup functions, used when we need to unwind
  * cleanup.c - cleanup functions, used when we need to unwind
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -37,6 +38,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/options.h>
 #include <dpkg/options.h>
 
 
 #include "filesdb.h"
 #include "filesdb.h"
@@ -118,7 +120,7 @@ void cu_prermupgrade(int argc, void **argv) {
                              versiondescribe(&pkg->available.version,
                              versiondescribe(&pkg->available.version,
                                              vdew_nonambig),
                                              vdew_nonambig),
                              NULL);
                              NULL);
-  pkg->eflag &= ~eflag_reinstreq;
+  pkg_clear_eflags(pkg, eflag_reinstreq);
   post_postinst_tasks(pkg, stat_installed);
   post_postinst_tasks(pkg, stat_installed);
   cleanup_pkg_failed--;
   cleanup_pkg_failed--;
 }
 }
@@ -172,7 +174,7 @@ void cu_prerminfavour(int argc, void **argv) {
                              versiondescribe(&infavour->available.version,
                              versiondescribe(&infavour->available.version,
                                              vdew_nonambig),
                                              vdew_nonambig),
                              NULL);
                              NULL);
-  conflictor->eflag &= ~eflag_reinstreq;
+  pkg_clear_eflags(conflictor, eflag_reinstreq);
   post_postinst_tasks(conflictor, stat_installed);
   post_postinst_tasks(conflictor, stat_installed);
   cleanup_conflictor_failed--;
   cleanup_conflictor_failed--;
 }
 }
@@ -185,8 +187,8 @@ void cu_preinstverynew(int argc, void **argv) {
   if (cleanup_pkg_failed++) return;
   if (cleanup_pkg_failed++) return;
   maintainer_script_new(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
   maintainer_script_new(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
                         "abort-install", NULL);
                         "abort-install", NULL);
-  pkg->status= stat_notinstalled;
-  pkg->eflag &= ~eflag_reinstreq;
+  pkg_set_status(pkg, stat_notinstalled);
+  pkg_clear_eflags(pkg, eflag_reinstreq);
   pkgbin_blank(&pkg->installed);
   pkgbin_blank(&pkg->installed);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   cleanup_pkg_failed--;
   cleanup_pkg_failed--;
@@ -202,8 +204,8 @@ void cu_preinstnew(int argc, void **argv) {
                         "abort-install", versiondescribe(&pkg->installed.version,
                         "abort-install", versiondescribe(&pkg->installed.version,
                                                          vdew_nonambig),
                                                          vdew_nonambig),
                         NULL);
                         NULL);
-  pkg->status= stat_configfiles;
-  pkg->eflag &= ~eflag_reinstreq;
+  pkg_set_status(pkg, stat_configfiles);
+  pkg_clear_eflags(pkg, eflag_reinstreq);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   cleanup_pkg_failed--;
   cleanup_pkg_failed--;
 }
 }
@@ -220,8 +222,8 @@ void cu_preinstupgrade(int argc, void **argv) {
                         versiondescribe(&pkg->installed.version,
                         versiondescribe(&pkg->installed.version,
                                         vdew_nonambig),
                                         vdew_nonambig),
                         NULL);
                         NULL);
-  pkg->status= *oldstatusp;
-  pkg->eflag &= ~eflag_reinstreq;
+  pkg_set_status(pkg, *oldstatusp);
+  pkg_clear_eflags(pkg, eflag_reinstreq);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   cleanup_pkg_failed--;
   cleanup_pkg_failed--;
 }
 }
@@ -243,7 +245,7 @@ void cu_prermremove(int argc, void **argv) {
 
 
   if (cleanup_pkg_failed++) return;
   if (cleanup_pkg_failed++) return;
   maintainer_script_postinst(pkg, "abort-remove", NULL);
   maintainer_script_postinst(pkg, "abort-remove", NULL);
-  pkg->eflag &= ~eflag_reinstreq;
+  pkg_clear_eflags(pkg, eflag_reinstreq);
   post_postinst_tasks(pkg, *oldpkgstatus);
   post_postinst_tasks(pkg, *oldpkgstatus);
   cleanup_pkg_failed--;
   cleanup_pkg_failed--;
 }
 }

+ 5 - 3
src/configure.c

@@ -4,6 +4,7 @@
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1999, 2002 Wichert Akkerman <wichert@deephackmode.org>
  * Copyright © 1999, 2002 Wichert Akkerman <wichert@deephackmode.org>
+ * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -42,6 +43,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/string.h>
 #include <dpkg/string.h>
 #include <dpkg/buffer.h>
 #include <dpkg/buffer.h>
 #include <dpkg/file.h>
 #include <dpkg/file.h>
@@ -324,7 +326,7 @@ deferred_configure(struct pkginfo *pkg)
 	trig_activate_packageprocessing(pkg);
 	trig_activate_packageprocessing(pkg);
 
 
 	if (f_noact) {
 	if (f_noact) {
-		pkg->status = stat_installed;
+		pkg_set_status(pkg, stat_installed);
 		pkg->clientdata->istobe = itb_normal;
 		pkg->clientdata->istobe = itb_normal;
 		return;
 		return;
 	}
 	}
@@ -350,7 +352,7 @@ deferred_configure(struct pkginfo *pkg)
 		for (conff = pkg->installed.conffiles; conff; conff = conff->next)
 		for (conff = pkg->installed.conffiles; conff; conff = conff->next)
 			deferred_configure_conffile(pkg, conff);
 			deferred_configure_conffile(pkg, conff);
 
 
-		pkg->status = stat_halfconfigured;
+		pkg_set_status(pkg, stat_halfconfigured);
 	}
 	}
 
 
 	assert(pkg->status == stat_halfconfigured);
 	assert(pkg->status == stat_halfconfigured);
@@ -363,7 +365,7 @@ deferred_configure(struct pkginfo *pkg)
 	                                           vdew_nonambig) : "",
 	                                           vdew_nonambig) : "",
 	                           NULL);
 	                           NULL);
 
 
-	pkg->eflag = eflag_ok;
+	pkg_reset_eflags(pkg);
 	pkg->trigpend_head = NULL;
 	pkg->trigpend_head = NULL;
 	post_postinst_tasks(pkg, stat_installed);
 	post_postinst_tasks(pkg, stat_installed);
 }
 }

+ 8 - 3
src/help.c

@@ -3,6 +3,7 @@
  * help.c - various helper routines
  * help.c - various helper routines
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +37,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/path.h>
 #include <dpkg/path.h>
 #include <dpkg/subproc.h>
 #include <dpkg/subproc.h>
 #include <dpkg/command.h>
 #include <dpkg/command.h>
@@ -236,10 +238,13 @@ void
 post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status)
 post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status)
 {
 {
   if (new_status < stat_triggersawaited)
   if (new_status < stat_triggersawaited)
-    pkg->status = new_status;
+    pkg_set_status(pkg, new_status);
+  else if (pkg->trigaw.head)
+    pkg_set_status(pkg, stat_triggersawaited);
+  else if (pkg->trigpend_head)
+    pkg_set_status(pkg, stat_triggerspending);
   else
   else
-    pkg->status = pkg->trigaw.head ? stat_triggersawaited :
-                  pkg->trigpend_head ? stat_triggerspending : stat_installed;
+    pkg_set_status(pkg, stat_installed);
 
 
   post_postinst_tasks_core(pkg);
   post_postinst_tasks_core(pkg);
 }
 }

+ 16 - 15
src/processarc.c

@@ -3,7 +3,7 @@
  * processarc.c - the huge function process_archive
  * processarc.c - the huge function process_archive
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/path.h>
 #include <dpkg/path.h>
 #include <dpkg/buffer.h>
 #include <dpkg/buffer.h>
 #include <dpkg/subproc.h>
 #include <dpkg/subproc.h>
@@ -361,9 +362,9 @@ pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour)
   pkg_infodb_foreach(pkg, &pkg->installed, pkg_infodb_remove_file);
   pkg_infodb_foreach(pkg, &pkg->installed, pkg_infodb_remove_file);
   dir_sync_path(pkgadmindir());
   dir_sync_path(pkgadmindir());
 
 
-  pkg->status = stat_notinstalled;
-  pkg->want = want_unknown;
-  pkg->eflag = eflag_ok;
+  pkg_set_status(pkg, stat_notinstalled);
+  pkg_set_want(pkg, want_unknown);
+  pkg_reset_eflags(pkg);
 
 
   blankversion(&pkg->configversion);
   blankversion(&pkg->configversion);
   pkgbin_blank(&pkg->installed);
   pkgbin_blank(&pkg->installed);
@@ -670,8 +671,8 @@ void process_archive(const char *filename) {
       oldversionstatus == stat_triggersawaited ||
       oldversionstatus == stat_triggersawaited ||
       oldversionstatus == stat_triggerspending ||
       oldversionstatus == stat_triggerspending ||
       oldversionstatus == stat_installed) {
       oldversionstatus == stat_installed) {
-    pkg->eflag |= eflag_reinstreq;
-    pkg->status= stat_halfconfigured;
+    pkg_set_eflags(pkg, eflag_reinstreq);
+    pkg_set_status(pkg, stat_halfconfigured);
     modstatdb_note(pkg);
     modstatdb_note(pkg);
     push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     if (versioncompare(&pkg->available.version,
     if (versioncompare(&pkg->available.version,
@@ -682,7 +683,7 @@ void process_archive(const char *filename) {
       maintainer_script_installed(pkg, PRERMFILE, "pre-removal", "upgrade",
       maintainer_script_installed(pkg, PRERMFILE, "pre-removal", "upgrade",
                                   versiondescribe(&pkg->available.version,
                                   versiondescribe(&pkg->available.version,
                                                   vdew_nonambig), NULL);
                                                   vdew_nonambig), NULL);
-    pkg->status= stat_unpacked;
+    pkg_set_status(pkg, stat_unpacked);
     oldversionstatus= stat_unpacked;
     oldversionstatus= stat_unpacked;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
   }
   }
@@ -699,7 +700,7 @@ void process_archive(const char *filename) {
              pkg_name(deconpil->pkg, pnaw_nonambig));
              pkg_name(deconpil->pkg, pnaw_nonambig));
 
 
     trig_activate_packageprocessing(deconpil->pkg);
     trig_activate_packageprocessing(deconpil->pkg);
-    deconpil->pkg->status= stat_halfconfigured;
+    pkg_set_status(deconpil->pkg, stat_halfconfigured);
     modstatdb_note(deconpil->pkg);
     modstatdb_note(deconpil->pkg);
 
 
     /* This means that we *either* go and run postinst abort-deconfigure,
     /* This means that we *either* go and run postinst abort-deconfigure,
@@ -733,7 +734,7 @@ void process_archive(const char *filename) {
           conflictor[i]->status == stat_triggerspending ||
           conflictor[i]->status == stat_triggerspending ||
           conflictor[i]->status == stat_installed)) continue;
           conflictor[i]->status == stat_installed)) continue;
     trig_activate_packageprocessing(conflictor[i]);
     trig_activate_packageprocessing(conflictor[i]);
-    conflictor[i]->status= stat_halfconfigured;
+    pkg_set_status(conflictor[i], stat_halfconfigured);
     modstatdb_note(conflictor[i]);
     modstatdb_note(conflictor[i]);
     push_cleanup(cu_prerminfavour, ~ehflag_normaltidy, NULL, 0,
     push_cleanup(cu_prerminfavour, ~ehflag_normaltidy, NULL, 0,
                  2,(void*)conflictor[i],(void*)pkg);
                  2,(void*)conflictor[i],(void*)pkg);
@@ -742,14 +743,14 @@ void process_archive(const char *filename) {
                                 versiondescribe(&pkg->available.version,
                                 versiondescribe(&pkg->available.version,
                                                 vdew_nonambig),
                                                 vdew_nonambig),
                                 NULL);
                                 NULL);
-    conflictor[i]->status= stat_halfinstalled;
+    pkg_set_status(conflictor[i], stat_halfinstalled);
     modstatdb_note(conflictor[i]);
     modstatdb_note(conflictor[i]);
   }
   }
 
 
-  pkg->eflag |= eflag_reinstreq;
+  pkg_set_eflags(pkg, eflag_reinstreq);
   if (pkg->status == stat_notinstalled)
   if (pkg->status == stat_notinstalled)
     pkg->installed.version= pkg->available.version;
     pkg->installed.version= pkg->available.version;
-  pkg->status= stat_halfinstalled;
+  pkg_set_status(pkg, stat_halfinstalled);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   if (oldversionstatus == stat_notinstalled) {
   if (oldversionstatus == stat_notinstalled) {
     push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, NULL, 0,
     push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, NULL, 0,
@@ -885,7 +886,7 @@ void process_archive(const char *filename) {
   if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) {
   if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) {
     /* Packages that were in ‘installed’ and ‘postinstfailed’ have been
     /* Packages that were in ‘installed’ and ‘postinstfailed’ have been
      * reduced to ‘unpacked’ by now, by the running of the prerm script. */
      * reduced to ‘unpacked’ by now, by the running of the prerm script. */
-    pkg->status= stat_halfinstalled;
+    pkg_set_status(pkg, stat_halfinstalled);
     modstatdb_note(pkg);
     modstatdb_note(pkg);
     push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     maintainer_script_alternative(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
     maintainer_script_alternative(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
@@ -1288,7 +1289,7 @@ void process_archive(const char *filename) {
    * The only thing that we have left to do with it is remove
    * The only thing that we have left to do with it is remove
    * backup files, and we can leave the user to fix that if and when
    * backup files, and we can leave the user to fix that if and when
    * it happens (we leave the reinstall required flag, of course). */
    * it happens (we leave the reinstall required flag, of course). */
-  pkg->status= stat_unpacked;
+  pkg_set_status(pkg, stat_unpacked);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
 
 
   /* Now we delete all the backup files that we made when
   /* Now we delete all the backup files that we made when
@@ -1312,7 +1313,7 @@ void process_archive(const char *filename) {
 
 
   /* OK, we're now fully done with the main package.
   /* OK, we're now fully done with the main package.
    * This is quite a nice state, so we don't unwind past here. */
    * This is quite a nice state, so we don't unwind past here. */
-  pkg->eflag = eflag_ok;
+  pkg_reset_eflags(pkg);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
   push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 
 

+ 17 - 11
src/remove.c

@@ -3,6 +3,7 @@
  * remove.c - functionality for removing packages
  * remove.c - functionality for removing packages
  *
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +37,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/dir.h>
 #include <dpkg/dir.h>
 #include <dpkg/options.h>
 #include <dpkg/options.h>
 #include <dpkg/triglib.h>
 #include <dpkg/triglib.h>
@@ -106,8 +108,12 @@ void deferred_remove(struct pkginfo *pkg) {
     forcibleerr(fc_removeessential, _("This is an essential package -"
     forcibleerr(fc_removeessential, _("This is an essential package -"
                 " it should not be removed."));
                 " it should not be removed."));
 
 
-  if (!f_pending)
-    pkg->want = (cipaction->arg_int == act_purge) ? want_purge : want_deinstall;
+  if (!f_pending) {
+    if (cipaction->arg_int == act_purge)
+      pkg_set_want(pkg, want_purge);
+    else
+      pkg_set_want(pkg, want_deinstall);
+  }
   if (!f_noact) modstatdb_note(pkg);
   if (!f_noact) modstatdb_note(pkg);
 
 
   debug(dbg_general, "checking dependencies for remove `%s'",
   debug(dbg_general, "checking dependencies for remove `%s'",
@@ -151,7 +157,7 @@ void deferred_remove(struct pkginfo *pkg) {
 
 
   if (f_noact) {
   if (f_noact) {
     printf(_("Would remove or purge %s ...\n"), pkg_name(pkg, pnaw_nonambig));
     printf(_("Would remove or purge %s ...\n"), pkg_name(pkg, pnaw_nonambig));
-    pkg->status= stat_notinstalled;
+    pkg_set_status(pkg, stat_notinstalled);
     pkg->clientdata->istobe= itb_normal;
     pkg->clientdata->istobe= itb_normal;
     return;
     return;
   }
   }
@@ -165,7 +171,7 @@ void deferred_remove(struct pkginfo *pkg) {
     static enum pkgstatus oldpkgstatus;
     static enum pkgstatus oldpkgstatus;
 
 
     oldpkgstatus= pkg->status;
     oldpkgstatus= pkg->status;
-    pkg->status= stat_halfconfigured;
+    pkg_set_status(pkg, stat_halfconfigured);
     modstatdb_note(pkg);
     modstatdb_note(pkg);
     push_cleanup(cu_prermremove, ~ehflag_normaltidy, NULL, 0, 2,
     push_cleanup(cu_prermremove, ~ehflag_normaltidy, NULL, 0, 2,
                  (void *)pkg, (void *)&oldpkgstatus);
                  (void *)pkg, (void *)&oldpkgstatus);
@@ -173,7 +179,7 @@ void deferred_remove(struct pkginfo *pkg) {
                                 "remove", NULL);
                                 "remove", NULL);
 
 
     /* Will turn into ‘half-installed’ soon ... */
     /* Will turn into ‘half-installed’ soon ... */
-    pkg->status = stat_unpacked;
+    pkg_set_status(pkg, stat_unpacked);
   }
   }
 
 
   removal_bulk(pkg);
   removal_bulk(pkg);
@@ -214,7 +220,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
   static struct varbuf fnvb;
   static struct varbuf fnvb;
   struct stat stab;
   struct stat stab;
 
 
-    pkg->status= stat_halfinstalled;
+    pkg_set_status(pkg, stat_halfinstalled);
     modstatdb_note(pkg);
     modstatdb_note(pkg);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 
 
@@ -304,7 +310,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
     pkg_infodb_foreach(pkg, &pkg->installed, removal_bulk_remove_file);
     pkg_infodb_foreach(pkg, &pkg->installed, removal_bulk_remove_file);
     dir_sync_path(pkgadmindir());
     dir_sync_path(pkgadmindir());
 
 
-    pkg->status= stat_configfiles;
+    pkg_set_status(pkg, stat_configfiles);
     pkg->installed.essential = false;
     pkg->installed.essential = false;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
@@ -551,8 +557,8 @@ void removal_bulk(struct pkginfo *pkg) {
     /* If there are no config files and no postrm script then we
     /* If there are no config files and no postrm script then we
      * go straight into ‘purge’.  */
      * go straight into ‘purge’.  */
     debug(dbg_general, "removal_bulk no postrm, no conffiles, purging");
     debug(dbg_general, "removal_bulk no postrm, no conffiles, purging");
-    pkg->want= want_purge;
 
 
+    pkg_set_want(pkg, want_purge);
     blankversion(&pkg->configversion);
     blankversion(&pkg->configversion);
   } else if (pkg->want == want_purge) {
   } else if (pkg->want == want_purge) {
 
 
@@ -579,15 +585,15 @@ void removal_bulk(struct pkginfo *pkg) {
     if (unlink(filename) && errno != ENOENT)
     if (unlink(filename) && errno != ENOENT)
       ohshite(_("can't remove old postrm script"));
       ohshite(_("can't remove old postrm script"));
 
 
-    pkg->status= stat_notinstalled;
-    pkg->want = want_unknown;
+    pkg_set_status(pkg, stat_notinstalled);
+    pkg_set_want(pkg, want_unknown);
 
 
     /* This will mess up reverse links, but if we follow them
     /* This will mess up reverse links, but if we follow them
      * we won't go back because pkg->status is stat_notinstalled. */
      * we won't go back because pkg->status is stat_notinstalled. */
     pkgbin_blank(&pkg->installed);
     pkgbin_blank(&pkg->installed);
   }
   }
 
 
-  pkg->eflag = eflag_ok;
+  pkg_reset_eflags(pkg);
   modstatdb_note(pkg);
   modstatdb_note(pkg);
 
 
   debug(dbg_general, "removal done");
   debug(dbg_general, "removal done");

+ 3 - 2
src/select.c

@@ -3,6 +3,7 @@
  * select.c - by-hand (rather than dselect-based) package selection
  * select.c - by-hand (rather than dselect-based) package selection
  *
  *
  * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2006,2008-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -148,7 +149,7 @@ setselections(const char *const *argv)
     if (nv == NULL)
     if (nv == NULL)
       ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf);
       ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf);
     pkg = pkg_db_find(namevb.buf);
     pkg = pkg_db_find(namevb.buf);
-    pkg->want = nv->value;
+    pkg_set_want(pkg, nv->value);
     if (c == EOF) break;
     if (c == EOF) break;
     lno++;
     lno++;
   }
   }
@@ -174,7 +175,7 @@ clearselections(const char *const *argv)
   it = pkg_db_iter_new();
   it = pkg_db_iter_new();
   while ((pkg = pkg_db_iter_next_pkg(it))) {
   while ((pkg = pkg_db_iter_next_pkg(it))) {
     if (!pkg->installed.essential)
     if (!pkg->installed.essential)
-      pkg->want = want_deinstall;
+      pkg_set_want(pkg, want_deinstall);
   }
   }
   pkg_db_iter_free(it);
   pkg_db_iter_free(it);
 
 

+ 17 - 8
src/trigproc.c

@@ -4,6 +4,7 @@
  *
  *
  * Copyright © 2007 Canonical Ltd
  * Copyright © 2007 Canonical Ltd
  * written by Ian Jackson <ian@chiark.greenend.org.uk>
  * written by Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  *
  *
  * This is free software; you can redistribute it and/or modify
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * it under the terms of the GNU General Public License as published by
@@ -31,6 +32,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
 #include <dpkg/pkg-queue.h>
 #include <dpkg/pkg-queue.h>
 #include <dpkg/triglib.h>
 #include <dpkg/triglib.h>
 
 
@@ -287,7 +289,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
 	      pkg_name(giveup, pnaw_nonambig));
 	      pkg_name(giveup, pnaw_nonambig));
 	assert(giveup->status == stat_triggersawaited ||
 	assert(giveup->status == stat_triggersawaited ||
 	       giveup->status == stat_triggerspending);
 	       giveup->status == stat_triggerspending);
-	giveup->status = stat_halfconfigured;
+	pkg_set_status(giveup, stat_halfconfigured);
 	modstatdb_note(giveup);
 	modstatdb_note(giveup);
 	print_error_perpackage(_("triggers looping, abandoned"),
 	print_error_perpackage(_("triggers looping, abandoned"),
 	                       giveup->set->name);
 	                       giveup->set->name);
@@ -334,7 +336,7 @@ trigproc(struct pkginfo *pkg)
 
 
 		/* Setting the status to half-configured
 		/* Setting the status to half-configured
 		 * causes modstatdb_note to clear pending triggers. */
 		 * causes modstatdb_note to clear pending triggers. */
-		pkg->status = stat_halfconfigured;
+		pkg_set_status(pkg, stat_halfconfigured);
 		modstatdb_note(pkg);
 		modstatdb_note(pkg);
 
 
 		if (!f_noact) {
 		if (!f_noact) {
@@ -344,9 +346,12 @@ trigproc(struct pkginfo *pkg)
 		}
 		}
 
 
 		/* 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->trigpend_head ? stat_triggerspending :
-		              stat_installed;
+		if (pkg->trigaw.head)
+			pkg_set_status(pkg, stat_triggersawaited);
+		else if (pkg->trigpend_head)
+			pkg_set_status(pkg, stat_triggerspending);
+		else
+			pkg_set_status(pkg, stat_installed);
 
 
 		post_postinst_tasks_core(pkg);
 		post_postinst_tasks_core(pkg);
 	} else {
 	} else {
@@ -412,9 +417,13 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
 		 * not in sync with the infodb files. */
 		 * not in sync with the infodb files. */
 		if (pkg->status < stat_triggersawaited)
 		if (pkg->status < stat_triggersawaited)
 			continue;
 			continue;
-		pkg->status = pkg->trigaw.head ? stat_triggersawaited :
-		              pkg->trigpend_head ? stat_triggerspending :
-		              stat_installed;
+
+		if (pkg->trigaw.head)
+			pkg_set_status(pkg, stat_triggersawaited);
+		else if (pkg->trigpend_head)
+			pkg_set_status(pkg, stat_triggerspending);
+		else
+			pkg_set_status(pkg, stat_installed);
 	}
 	}
 	pkg_db_iter_free(it);
 	pkg_db_iter_free(it);