- preserve rpmdb file attributes across --rebuilddb (#70367).
authorjbj <devnull@localhost>
Thu, 1 Aug 2002 21:20:26 +0000 (21:20 +0000)
committerjbj <devnull@localhost>
Thu, 1 Aug 2002 21:20:26 +0000 (21:20 +0000)
CVS patchset: 5590
CVS date: 2002/08/01 21:20:26

CHANGES
rpm.spec.in
rpmdb/rpmdb.c

diff --git a/CHANGES b/CHANGES
index 177e37b..c1ad459 100644 (file)
--- a/CHANGES
+++ b/CHANGES
        - configurable (default off) build failure iff unpackaged files (PLD).
        - change from default off to default on.
        - python: methods to disable all new features for benchmarking.
+       - preserve rpmdb file attributes across --rebuilddb (#70367).
 
 4.0.3 -> 4.0.4:
        - solaris: translate i86pc to i386 (#57182).
index 169f673..65ac488 100644 (file)
@@ -519,6 +519,7 @@ fi
 * Thu Aug  1 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.63
 - add check-files to rpm-build manifest.
 - python: methods to disable all new features for benchmarking.
+- preserve rpmdb file attributes across --rebuilddb (#70367).
 
 * Wed Jul 31 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.62
 - make --querytags a common option, fix errant regex (#70135).
index 358f7d4..a369d30 100644 (file)
@@ -3505,6 +3505,7 @@ static int rpmdbMoveDatabase(const char * prefix,
 {
     int i;
     char * ofilename, * nfilename;
+    struct stat * nst = alloca(sizeof(*nst));
     int rc = 0;
     int xx;
  
@@ -3559,8 +3560,19 @@ static int rpmdbMoveDatabase(const char * prefix,
                continue;
            sprintf(nfilename, "%s/%s/%s", prefix, newdbpath, base);
            (void)rpmCleanPath(nfilename);
-           if ((xx = Rename(ofilename, nfilename)) != 0)
+           if (Stat(nfilename, nst))
+               continue;
+           if ((xx = Rename(ofilename, nfilename)) != 0) {
                rc = 1;
+               continue;
+           }
+           xx = chown(nfilename, nst->st_uid, nst->st_gid);
+           xx = chmod(nfilename, (nst->st_mode & 07777));
+           {   struct utimbuf stamp;
+               stamp.actime = nst->st_atime;
+               stamp.modtime = nst->st_mtime;
+               xx = utime(nfilename, &stamp);
+           }
        }
        for (i = 0; i < 16; i++) {
            sprintf(ofilename, "%s/%s/__db.%03d", prefix, olddbpath, i);