]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add experimental support for self-destruct packages
authorMichael Schroeder <mls@suse.de>
Fri, 8 Nov 2019 14:09:54 +0000 (15:09 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 20 May 2021 09:39:40 +0000 (11:39 +0200)
Self-destruct packages will not be part of the transaction. But
they still will obsolete packages, thus updating to a self-destruct
package will lead to the erasure of the old package.

src/knownid.h
src/transaction.c

index 3bea6d3c02f7b187acd9ac715a026ddf910a3ca1..006ca245c2d17c06de3f0225f224e880457598ac 100644 (file)
@@ -264,6 +264,8 @@ KNOWNID(SOLVABLE_PREREQ_IGNOREINST, "solvable:prereq_ignoreinst"),  /* ignore the
 
 KNOWNID(UPDATE_STATUS,                 "update:status"),               /* "stable", "testing", ...*/
 
+KNOWNID(LIBSOLV_SELF_DESTRUCT_PKG,      "libsolv-self-destruct-pkg()"),        /* this package will self-destruct on installation */
+
 KNOWNID(ID_NUM_INTERNAL,               0)
 
 #ifdef KNOWNID_INITIALIZE
index 9a329661681428bc2b3a5476dca6191843794a8d..9758fa1961a8b434f2357e3413c25f2475b62eac 100644 (file)
@@ -646,6 +646,8 @@ create_transaction_info(Transaction *trans, Queue *decisionq)
       s = pool->solvables + p;
       if (!s->repo || s->repo == installed)
        continue;
+      if (!MAPTST(&trans->transactsmap, p))
+       continue;
       multi = trans->multiversionmap.size && MAPTST(&trans->multiversionmap, p);
       FOR_PROVIDES(p2, pp2, s->name)
        {
@@ -726,9 +728,10 @@ transaction_create_decisionq(Pool *pool, Queue *decisionq, Map *multiversionmap)
 {
   Repo *installed = pool->installed;
   int i, needmulti;
-  Id p;
+  Id p, pp;
   Solvable *s;
   Transaction *trans;
+  Map selfdestructmap;
 
   trans = transaction_create(pool);
   if (multiversionmap && !multiversionmap->size)
@@ -736,6 +739,13 @@ transaction_create_decisionq(Pool *pool, Queue *decisionq, Map *multiversionmap)
   queue_empty(&trans->steps);
   map_init(&trans->transactsmap, pool->nsolvables);
   needmulti = 0;
+  map_init(&selfdestructmap, 0);
+  FOR_PROVIDES(p, pp, LIBSOLV_SELF_DESTRUCT_PKG)
+    {
+      if (!selfdestructmap.size)
+       map_grow(&selfdestructmap, pool->nsolvables);
+      MAPSET(&selfdestructmap, p);
+    }
   for (i = 0; i < decisionq->count; i++)
     {
       p = decisionq->elements[i];
@@ -746,11 +756,14 @@ transaction_create_decisionq(Pool *pool, Queue *decisionq, Map *multiversionmap)
        MAPSET(&trans->transactsmap, -p);
       if (!(installed && s->repo == installed) && p > 0)
        {
+         if (selfdestructmap.size && MAPTST(&selfdestructmap, p))
+           continue;
          MAPSET(&trans->transactsmap, p);
          if (multiversionmap && MAPTST(multiversionmap, p))
            needmulti = 1;
        }
     }
+  map_free(&selfdestructmap);
   MAPCLR(&trans->transactsmap, SYSTEMSOLVABLE);
   if (needmulti)
     map_init_clone(&trans->multiversionmap, multiversionmap);