[Rpm-maint] [PATCH 15/18] Remember that a package was installed with --nopolicy

Steve Lawrence slawrence at tresys.com
Wed Dec 23 20:57:35 UTC 2009


Policy modules should be ignored during policy conflict detection if a
package was installed with --nopolicy. This patch remembers if a package
was installed with --nopolicy by added a new tag, RPMTAG_NOPOLICIES,
and setting its value to the time the package was installed. When doing
conflict checks, the existence of the tag in a header tells rpm to ignore
its policies during conflict detection.
---
 lib/psm.c    |    4 ++++
 lib/rpmpol.c |    2 +-
 lib/rpmtag.h |    1 +
 3 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/psm.c b/lib/psm.c
index 48b4d34..524f9ff 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1397,6 +1397,10 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
 		headerPutChar(h, RPMTAG_FILESTATES, fileStates, fc);
 	    }
 
+	    if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOLICY) {
+		headerPutUint32(h, RPMTAG_NOPOLICIES, &installTime, 1);
+	    }
+
 	    headerPutUint32(h, RPMTAG_INSTALLTIME, &installTime, 1);
 	    headerPutUint32(h, RPMTAG_INSTALLCOLOR, &tscolor, 1);
 	    headerFree(h);
diff --git a/lib/rpmpol.c b/lib/rpmpol.c
index e727ad3..4de17ba 100644
--- a/lib/rpmpol.c
+++ b/lib/rpmpol.c
@@ -920,7 +920,7 @@ rpmRC rpmpolsCheckConflicts(rpmpols ps, rpmdb db)
 			/* check this rpmpol against all currently installed policies */
 			rpmdbMatchIterator mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
 			while ((h = rpmdbNextIterator(mi)) != NULL) {
-				if (!headerIsEntry(h, RPMTAG_POLICIES)) {
+				if (!headerIsEntry(h, RPMTAG_POLICIES) || headerIsEntry(h, RPMTAG_NOPOLICIES)) {
 					continue;
 				}
 
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
index 95fa8a7..677383a 100644
--- a/lib/rpmtag.h
+++ b/lib/rpmtag.h
@@ -282,6 +282,7 @@ typedef enum rpmTag_e {
     RPMTAG_POLICYFLAGS		= 2103,	/* i[] */
     RPMTAG_POLICYOBSOLETES		= 2104,	/* s[] */
     RPMTAG_POLICYOBSOLETESBY		= 2105,	/* i[] */
+    RPMTAG_NOPOLICIES		= 2106, /* i */
     RPMTAG_FILENAMES		= 5000, /* s[] extension */
     RPMTAG_FILEPROVIDE		= 5001, /* s[] extension */
     RPMTAG_FILEREQUIRE		= 5002, /* s[] extension */
-- 
1.6.0.6



More information about the Rpm-maint mailing list