chantra / rpms / rpm

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