michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
2a5b6a
From 3c99b06c7776345cfc3a3d4fd0c59fe671644317 Mon Sep 17 00:00:00 2001
2a5b6a
From: Lubos Kardos <lkardos@redhat.com>
2a5b6a
Date: Wed, 21 Oct 2015 15:25:47 +0200
2a5b6a
Subject: [PATCH] Overwrite a file if it is not marked as config any more.
2a5b6a
2a5b6a
If a file was marked as config in the previous version of a package but
2a5b6a
it is not marked as config in currently being installed version of
2a5b6a
the package then backup the old file as .rpmsave and overwrite it with
2a5b6a
the new file. (rhbz:1263859)
2a5b6a
---
2a5b6a
 lib/rpmfi.c | 12 ++++++++++++
2a5b6a
 1 file changed, 12 insertions(+)
2a5b6a
2a5b6a
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
2a5b6a
index 924ff4b..28a697e 100644
2a5b6a
--- a/lib/rpmfi.c
2a5b6a
+++ b/lib/rpmfi.c
2a5b6a
@@ -1040,6 +1040,12 @@ rpmFileAction rpmfilesDecideFate(rpmfiles ofi, int oix,
2a5b6a
 	        goto exit;		/* file identical in new, replace. */
2a5b6a
 	}
2a5b6a
 
2a5b6a
+	/* if new file is no longer config, backup it and replace it */
2a5b6a
+	if (!(newFlags & RPMFILE_CONFIG)) {
2a5b6a
+	    action = FA_SAVE;
2a5b6a
+	    goto exit;
2a5b6a
+	}
2a5b6a
+
2a5b6a
 	/* If file can be determined identical in old and new pkg, let it be */
2a5b6a
 	if (newWhat == REG && oalgo == nalgo && odiglen == ndiglen) {
2a5b6a
 	    if (odigest && ndigest && memcmp(odigest, ndigest, odiglen) == 0) {
2a5b6a
@@ -1071,6 +1077,12 @@ rpmFileAction rpmfilesDecideFate(rpmfiles ofi, int oix,
2a5b6a
 		goto exit;		/* unmodified config file, replace. */
2a5b6a
 	}
2a5b6a
 
2a5b6a
+	/* if new file is no longer config, backup it and replace it */
2a5b6a
+	if (!(newFlags & RPMFILE_CONFIG)) {
2a5b6a
+	    action = FA_SAVE;
2a5b6a
+	    goto exit;
2a5b6a
+	}
2a5b6a
+
2a5b6a
 	/* If link is identical in old and new pkg, let it be */
2a5b6a
 	if (newWhat == LINK && oFLink && nFLink && rstreq(oFLink, nFLink)) {
2a5b6a
 	    action = FA_SKIP;		/* identical file, don't bother. */
2a5b6a
-- 
2a5b6a
2.5.5
2a5b6a