Skip to content

Commit

Permalink
Add experimental support for self-destruct packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlschroe committed Nov 8, 2019
1 parent 4120051 commit 25356d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/knownid.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ KNOWNID(SOLVABLE_BUILDFLAVOR, "solvable:buildflavor"), /* conda */

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
Expand Down
15 changes: 14 additions & 1 deletion src/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -726,16 +728,24 @@ 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)
multiversionmap = 0; /* ignore empty map */
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];
Expand All @@ -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);
Expand Down

0 comments on commit 25356d1

Please sign in to comment.