chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
0b2921
From a144c29831a39ed303d6ea8d2ae91e1c36d64c84 Mon Sep 17 00:00:00 2001
0b2921
Message-Id: <a144c29831a39ed303d6ea8d2ae91e1c36d64c84.1559799452.git.pmatilai@redhat.com>
0b2921
From: Panu Matilainen <pmatilai@redhat.com>
0b2921
Date: Wed, 15 May 2019 13:51:19 +0300
0b2921
Subject: [PATCH] Fix packages getting erased on failed update with dnf
0b2921
 (RhBug:1620275)
0b2921
0b2921
When adding update elements, we set the erase element to depend on the
0b2921
install element, but if an API user adds the same erasure manually
0b2921
after adding the update, we know its a duplicate erasure and filter
0b2921
it out, BUT we zero out the dependent element in the process. And
0b2921
if installing the update now fails, we end up removing the whole package
0b2921
due to that missing dependent element.
0b2921
0b2921
This never happens with rpm itself so we can't easily test it, but is
0b2921
100% reproducable with dnf (at least dnf 3-4). Apparently it adds all
0b2921
erasures by itself (which is kind of understandable I guess, perhaps
0b2921
we should better allow this in the API)
0b2921
---
0b2921
 lib/depends.c | 3 ++-
0b2921
 1 file changed, 2 insertions(+), 1 deletion(-)
0b2921
0b2921
diff --git a/lib/depends.c b/lib/depends.c
0b2921
index 6e9866eae..f8a6084ab 100644
0b2921
--- a/lib/depends.c
0b2921
+++ b/lib/depends.c
0b2921
@@ -121,7 +121,8 @@ static int removePackage(rpmts ts, Header h, rpmte depends)
0b2921
 
0b2921
     /* Filter out duplicate erasures. */
0b2921
     if (packageHashGetEntry(tsmem->removedPackages, dboffset, &pp, NULL, NULL)) {
0b2921
-	rpmteSetDependsOn(pp[0], depends);
0b2921
+	if (depends)
0b2921
+	    rpmteSetDependsOn(pp[0], depends);
0b2921
 	return 0;
0b2921
     }
0b2921
 
0b2921
-- 
0b2921
2.21.0
0b2921