From 0206be8e22f7c28fc8664b0687a0a8cb51db1eb36a61b2b66fcb187dd94e84d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Schr=C3=B6der?= <mls@suse.com>
Date: Fri, 18 Feb 2022 13:47:06 +0000
Subject: [PATCH] tweak

OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=599
---
 0001-fix-minimize_writes.patch | 26 +++++++++++++++-----------
 rpm.changes                    |  3 ++-
 rpm.spec                       |  8 ++------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/0001-fix-minimize_writes.patch b/0001-fix-minimize_writes.patch
index 4225f7d..e0d59c9 100644
--- a/0001-fix-minimize_writes.patch
+++ b/0001-fix-minimize_writes.patch
@@ -1,16 +1,20 @@
-From 03f146e955e099c24f7a49eff461645e1c0a0fd7 Fri 28  1 16:00:15 2022
-From: Simon Vogl <simon.vogl@gmx.net>
-Date: Fri, 28 Jan 2022 16:00:15 UTC
-Subject: [PATCH] Fix minimize_writes not minimizing writes
+commit 03f146e955e099c24f7a49eff461645e1c0a0fd7
+Author: Panu Matilainen <pmatilai@redhat.com>
+Date:   Thu Jan 13 11:25:30 2022 +0200
 
-A regression in commit 13f70e3 caused minimize_writes
-to actually not minimize anything. FA_TOUCH needs different kind of verification, stat the file instead
-to see if it needs creating afterall.
+    Fix minimize_writes not minimizing writes since 4.15 regression
+    
+    Commit 13f70e3710b2df49a923cc6450ff4a8f86e65666 caused minimize_writes
+    to actually not minimize anything since fsmVerify() only "verifies"
+    the thing does NOT exist anymore when it exist. Sigh.
+    
+    FA_TOUCH needs different kind of verification, stat the file instead
+    to see if it needs creating afterall. This is all soooo broken...
+    
+    Fixes: #1881
 
-diff --git a/lib/fsm.c b/lib/fsm.c
-index af0125db4..935a0a5c6 100644
---- a/lib/fsm.c
-+++ b/lib/fsm.c
+--- lib/fsm.c.orig
++++ lib/fsm.c
 @@ -945,7 +945,12 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
  	    }
  	    /* Assume file does't exist when tmp suffix is in use */
diff --git a/rpm.changes b/rpm.changes
index 2a17cce..3533946 100644
--- a/rpm.changes
+++ b/rpm.changes
@@ -6,7 +6,8 @@ Tue Feb  1 12:47:02 UTC 2022 - Dirk Müller <dmueller@suse.com>
 -------------------------------------------------------------------
 Fri Jan 28 17:00:15 CEST 2022 - simon.vogl@gmx.net
 
-- Added 0001-fix-minimize_writes.patch to fix minimize_writes not working
+- Fix minimize_writes not minimizing writes since 4.15 regression
+  new patch: 0001-fix-minimize_writes.patch
 
 -------------------------------------------------------------------
 Fri Jan 28 14:19:02 UTC 2022 - Dirk Müller <dmueller@suse.com>
diff --git a/rpm.spec b/rpm.spec
index 4f52c0d..9f66a3f 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -71,8 +71,6 @@ Source8:        rpmconfigcheck
 Source9:        sysconfig.services-rpm
 Source12:       baselibs.conf
 Source13:       rpmconfigcheck.service
-# PATCH-FIX-UPSTREAM
-Patch1:         0001-fix-minimize_writes.patch
 # quilt patches start here
 Patch5:         usr-lib-sysimage-rpm.patch
 Patch13:        ignore-auxv.diff
@@ -120,6 +118,7 @@ Patch132:       verbosearg.diff
 Patch133:       zstdpool.diff
 Patch134:       zstdthreaded.diff
 Patch135:       ocaml-cmxs.diff
+Patch136:       0001-fix-minimize_writes.patch
 Patch200:       finddebuginfo.diff
 Patch201:       finddebuginfo-absolute-links.diff
 Patch202:       debugsubpkg.diff
@@ -248,7 +247,7 @@ rm -rf sqlite
 %patch -P 100        -P 102 -P 103
 %patch                                                  -P 117
 %patch -P 122 -P 123               -P 131 -P 132 -P 133 -P 134
-%patch -P 135
+%patch -P 135 -P 136
 
 # debugedit patches
 pushd debugedit-5.0
@@ -264,9 +263,6 @@ popd
 %patch6464
 %endif
 
-# minimize_writes patch
-%patch1 -p1
-
 rm -f m4/libtool.m4
 rm -f m4/lt*.m4