summaryrefslogtreecommitdiff
path: root/lib/rpmfi.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-08-28 09:04:09 +0300
committerPanu Matilainen <pmatilai@redhat.com>2007-08-28 09:04:09 +0300
commite64bf5b93ab689e6031fce4489e4ae38ebaebef1 (patch)
tree4924525e2362d99904ffcf3b9ab9a5d6b968a58d /lib/rpmfi.c
parent10d01f417760b655fec562234e09aee2f85c64f2 (diff)
downloadrpm-e64bf5b93ab689e6031fce4489e4ae38ebaebef1.tar.gz
rpm-e64bf5b93ab689e6031fce4489e4ae38ebaebef1.tar.bz2
rpm-e64bf5b93ab689e6031fce4489e4ae38ebaebef1.zip
Avoid .rpmnew when the file hasn't changed in package (rhbz#194246)
The current behavior of %config(noreplace) creates a .rpmnewfile iff the type of the current file has been changed wrto what was originally installed. The patch changes this behavior so when old and new (in db and in package) is identical -> not changed, the function returns FA_SKIP -> it won't clobber anything, it simply skips installation of the file from the package. This patch handles also the opposite case when old and new packages contain %config symlink and we have regular file on disk. Patch from Tomas Mraz.
Diffstat (limited to 'lib/rpmfi.c')
-rw-r--r--lib/rpmfi.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index bed84893d..3cca3bc18 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -579,7 +579,7 @@ fileAction rpmfiDecideFate(const rpmfi ofi, rpmfi nfi, int skipMissing)
if (newWhat == XDIR)
return FA_CREATE;
- if (diskWhat != newWhat)
+ if (diskWhat != newWhat && dbWhat != REG && dbWhat != LINK)
return save;
else if (newWhat != dbWhat && diskWhat != dbWhat)
return save;
@@ -595,11 +595,13 @@ fileAction rpmfiDecideFate(const rpmfi ofi, rpmfi nfi, int skipMissing)
memset(buffer, 0, sizeof(buffer));
if (dbWhat == REG) {
const unsigned char * omd5, * nmd5;
- if (domd5(fn, (unsigned char *)buffer, 0, NULL))
- return FA_CREATE; /* assume file has been removed */
omd5 = rpmfiMD5(ofi);
- if (omd5 && !memcmp(omd5, buffer, 16))
- return FA_CREATE; /* unmodified config file, replace. */
+ if (diskWhat == REG) {
+ if (domd5(fn, (unsigned char *)buffer, 0, NULL))
+ return FA_CREATE; /* assume file has been removed */
+ if (omd5 && !memcmp(omd5, buffer, 16))
+ return FA_CREATE; /* unmodified config file, replace. */
+ }
nmd5 = rpmfiMD5(nfi);
/*@-nullpass@*/
if (omd5 && nmd5 && !memcmp(omd5, nmd5, 16))
@@ -607,11 +609,13 @@ fileAction rpmfiDecideFate(const rpmfi ofi, rpmfi nfi, int skipMissing)
/*@=nullpass@*/
} else /* dbWhat == LINK */ {
const char * oFLink, * nFLink;
+ oFLink = rpmfiFLink(ofi);
+ if (diskWhat == LINK) {
if (readlink(fn, buffer, sizeof(buffer) - 1) == -1)
return FA_CREATE; /* assume file has been removed */
- oFLink = rpmfiFLink(ofi);
if (oFLink && !strcmp(oFLink, buffer))
return FA_CREATE; /* unmodified config file, replace. */
+ }
nFLink = rpmfiFLink(nfi);
/*@-nullpass@*/
if (oFLink && nFLink && !strcmp(oFLink, nFLink))