From 49a4525691ef3ef674d1886c2149dd9b118717fa Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mar 25 2020 08:22:21 +0000 Subject: Fix packages getting erased on failed update with dnf (RhBug:1620275) When adding update elements, we set the erase element to depend on the install element, but if an API user adds the same erasure manually after adding the update, we know its a duplicate erasure and filter it out, BUT we zero out the dependent element in the process. And if installing the update now fails, we end up removing the whole package due to that missing dependent element. This never happens with rpm itself so we can't easily test it, but is 100% reproducable with dnf (at least dnf 3-4). Apparently it adds all erasures by itself (which is kind of understandable I guess, perhaps we should better allow this in the API) --- diff --git a/lib/depends.c b/lib/depends.c index 9f4db8f..094864f 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -121,7 +121,8 @@ static int removePackage(rpmts ts, Header h, rpmte depends) /* Filter out duplicate erasures. */ if (packageHashGetEntry(tsmem->removedPackages, dboffset, &pp, NULL, NULL)) { - rpmteSetDependsOn(pp[0], depends); + if (depends) + rpmteSetDependsOn(pp[0], depends); return 0; }