[Rpm-maint] [PATCH v2 3/5] Add common Collection requirements

Panu Matilainen pmatilai at laiskiainen.org
Mon Jun 28 06:57:22 UTC 2010


On Fri, 25 Jun 2010, Panu Matilainen wrote:
> Hmm. With packages providing collections instead of rpm itself, and 
> collection members requiring the provider, we're already at least halfway 
> there: we just make RPMSENSE_COLLECTION to show up as isErasePreReq() and 
> isInstallPreReq(), to force the collection provider to be installed before 
> the collection members. And in case of "strict" collections, make ordering 
> add an RPMSENSE_ANY relation from the collection provider to each collection 
> member, creating an strongly connected component of the collection, which 
> should behave just the way SELinux wants it.
> For "relaxed" collections, the provider -> member relation is not added so 
> they can be more freely ordered.
>
> Should be fairly trivial even ... or so the theory goes ;)

And trivial it is... to a point (apply on top of the previous two 
collections-in-packages patches):

>From 6e9708e01133c6ad1ac276d51a6f101b06fe9552 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai at redhat.com>
Date: Mon, 28 Jun 2010 09:37:01 +0300
Subject: [PATCH] Turn collections into strongly connected components
  - make RPMSENSE_COLLECTION in requires a install+erase pre-req to aid
    snipping loops the right way around
  - add an RPMSENSE_ANY relation from collection provider to all collection
    members to create a strongly connected component of the entire collection,
    forcing the collection to be installed before any packages depending
    on its members.

---
  lib/order.c |   24 ++++++++++--------------
  lib/rpmds.h |    4 ++--
  2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/lib/order.c b/lib/order.c
index adcd678..6e8f826 100644
--- a/lib/order.c
+++ b/lib/order.c
@@ -224,7 +224,6 @@ static inline int addRelation(rpmts ts,
  			      rpmds requires)
  {
      rpmte q;
-    ARGV_const_t qcolls;
      rpmsenseFlags dsflags;

      dsflags = rpmdsFlags(requires);
@@ -245,21 +244,18 @@ static inline int addRelation(rpmts ts,

      addSingleRelation(p, q, dsflags);

+#if 0
      /*
-     * Disabled for now, collection dependencies should take care of this...
-     * or it needs to be controlled by additional flags to avoid creating
-     * gigantic dependency loops in the common cases.
+     * Make collection providers require collection members, creating
+     * a strongly connected component of the collection so that anything
+     * depending on collection members depends on the entire collection.
+     * TODO: This should only be done for "strict" collections, "relaxed"
+     *       collections do not need such ordering constraints.
+     * TODO: How to ensure this behavior when collection provider is
+     *       already installed and not part of the transaction?
       */
-#if 0
-    /* If q is a member of any collections, make sure p requires all packages
-     * that are also in those collections */
-    for (qcolls = rpmteCollections(q); qcolls && *qcolls; qcolls++) {
-	rpmte *te;
-	rpmte *tes = rpmalAllInCollection(al, *qcolls);
-	for (te = tes; te && *te; te++) {
-	    addSingleRelation(p, *te, RPMSENSE_SCRIPT_PRE);
-	}
-	_free(tes);
+    if (dsflags & RPMSENSE_COLLECTION) {
+	addSingleRelation(q, p, RPMSENSE_ANY);
      }
  #endif

diff --git a/lib/rpmds.h b/lib/rpmds.h
index d99add9..b3d8eb7 100644
--- a/lib/rpmds.h
+++ b/lib/rpmds.h
@@ -73,9 +73,9 @@ typedef	enum rpmsenseFlags_e {

  #define	_notpre(_x)		((_x) & ~RPMSENSE_PREREQ)
  #define	_INSTALL_ONLY_MASK \
-    _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS)
+    _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS|RPMSENSE_COLLECTION)
  #define	_ERASE_ONLY_MASK  \
-    _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
+    _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN|RPMSENSE_COLLECTION)

  #define	isLegacyPreReq(_x)  (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
  #define	isInstallPreReq(_x)	((_x) & _INSTALL_ONLY_MASK)
-- 
1.7.0.1


What's not so trivial is doing this when the collection provider is 
already installed so it's not a transaction member. The (strict) 
collection ordering requirements are unlike anything else in rpm so they 
need something new to be invented.

One possibility might be creating a dummy element of the already installed 
collection providers so there's something for ordering to hang the 
relations from. Or teach the ordering to treat collections as special 
strongly connected components without creating the actual relations.

 	- Panu -


More information about the Rpm-maint mailing list