Blame touch_backport.diff

344f55
--- ./lib/fsm.c.orig	2019-06-26 14:17:31.407985702 +0000
344f55
+++ ./lib/fsm.c	2020-10-19 09:49:02.709129763 +0000
344f55
@@ -926,10 +926,6 @@ int rpmPackageFilesInstall(rpmts ts, rpm
344f55
         if (!skip) {
344f55
 	    int setmeta = 1;
344f55
 
344f55
-	    /* When touching we don't need any of this... */
344f55
-	    if (action == FA_TOUCH)
344f55
-		goto touch;
344f55
-
344f55
 	    /* Directories replacing something need early backup */
344f55
 	    if (!suffix) {
344f55
 		rc = fsmBackup(fi, action);
344f55
@@ -941,6 +937,17 @@ int rpmPackageFilesInstall(rpmts ts, rpm
344f55
 		rc = RPMERR_ENOENT;
344f55
 	    }
344f55
 
344f55
+	    /* See if the file was removed while our attention was elsewhere */
344f55
+	    if (rc == RPMERR_ENOENT && action == FA_TOUCH) {
344f55
+		rpmlog(RPMLOG_DEBUG, "file %s vanished unexpectedly\n", fpath);
344f55
+		action = FA_CREATE;
344f55
+		fsmDebug(fpath, action, &sb);
344f55
+	    }
344f55
+
344f55
+	    /* When touching we don't need any of this... */
344f55
+	    if (action == FA_TOUCH)
344f55
+		goto touch;
344f55
+
344f55
             if (S_ISREG(sb.st_mode)) {
344f55
 		if (rc == RPMERR_ENOENT) {
344f55
 		    rc = fsmMkfile(fi, fpath, files, psm, nodigest,
344f55
--- ./lib/transaction.c.orig	2020-10-19 09:47:25.761418056 +0000
344f55
+++ ./lib/transaction.c	2020-10-19 09:48:20.837254277 +0000
344f55
@@ -483,13 +483,6 @@ static void handleInstInstalledFile(cons
344f55
 	rpmfsSetAction(fs, fx, action);
344f55
     }
344f55
 
344f55
-    /* Skip already existing files - if 'minimize_writes' is set. */
344f55
-    if ((!isCfgFile) && (rpmfsGetAction(fs, fx) == FA_UNKNOWN)  && ts->min_writes) {
344f55
-	if (rpmfileContentsEqual(otherFi, ofx, fi, fx)) {
344f55
-	   rpmfsSetAction(fs, fx, FA_TOUCH);
344f55
-	}
344f55
-    }
344f55
-
344f55
     otherFileSize = rpmfilesFSize(otherFi, ofx);
344f55
 
344f55
     /* Only account for the last file of a hardlink set */
344f55
@@ -499,6 +492,16 @@ static void handleInstInstalledFile(cons
344f55
 
344f55
     /* Add one to make sure the size is not zero */
344f55
     rpmfilesSetFReplacedSize(fi, fx, otherFileSize + 1);
344f55
+
344f55
+    /* Just touch already existing files if minimize_writes is enabled */
344f55
+    if (ts->min_writes) {
344f55
+	if ((!isCfgFile) && (rpmfsGetAction(fs, fx) == FA_UNKNOWN)) {
344f55
+	    /* XXX fsm can't handle FA_TOUCH of hardlinked files */
344f55
+	    int nolinks = (nlink == 1 && rpmfilesFNlink(fi, fx) == 1);
344f55
+	    if (nolinks && rpmfileContentsEqual(otherFi, ofx, fi, fx))
344f55
+	       rpmfsSetAction(fs, fx, FA_TOUCH);
344f55
+	}
344f55
+    }
344f55
 }
344f55
 
344f55
 /**