1From 1ed066fc6fa7d7afffe3545c4e3ea937529e6c49 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Thu, 7 May 2020 17:40:58 +0800
4Subject: [PATCH] lib/transaction.c: fix file conflicts for MIPS64 N32
5
6This patch is from:
7https://github.com/rpm-software-management/rpm/issues/193
8
9Error: Transaction check error:
10  file /sbin/ldconfig conflicts between attempted installs of
11ldconfig-2.31+git0+71f2b249a2-r0.mips64_n32 and
12lib32-ldconfig-2.31+git0+71f2b249a2-r0.mips32r2
13...
14
15This was because:
16transactions_color = 001 (ELF32) & 010 (ELF64) & 100 (ELF32 N32 MIPS64)
17FColor = Current file color (001) & transaction_color (111)
18oFcolor = Previous file color (100) & transaction_color (111)
19
20In handleColorConflict, it only deal with conditons "new preferred" or
21"old preferred". But not deal with the situation where neither is the
22preferred type. so for tri-lib system, like mips64/mips64 n32/mips(32),
23"Transaction check error" occurred.
24
25Fixed by performing a 'last-in-wins' resolution when "neither is preferred".
26
27Upstream-Status: Submitted <https://github.com/rpm-software-management/rpm/issues/193>
28
29Signed-off-by: Changqing Li <changqing.li@windriver.com>
30---
31 lib/transaction.c | 13 ++++++++++++-
32 1 file changed, 12 insertions(+), 1 deletion(-)
33
34diff --git a/lib/transaction.c b/lib/transaction.c
35index 67b9db5..82386b8 100644
36--- a/lib/transaction.c
37+++ b/lib/transaction.c
38@@ -391,7 +391,18 @@ static int handleColorConflict(rpmts ts,
39 		    rpmfsSetAction(ofs, ofx, FA_CREATE);
40 		rpmfsSetAction(fs, fx, FA_SKIPCOLOR);
41 		rConflicts = 0;
42-	    }
43+	    }else {
44+                /*
45+                 * If neither is already skipped, we skip the old one, and
46+                 * install the new one (last in wins).
47+                 */
48+                if (ofs && !XFA_SKIPPING(rpmfsGetAction(ofs, ofx)) &&
49+                    fs && !XFA_SKIPPING(rpmfsGetAction(fs, fx))) {
50+                    rpmfsSetAction(ofs, ofx, FA_SKIPCOLOR);
51+                    rpmfsSetAction(fs, fx, FA_CREATE);
52+                }
53+                rConflicts = 0;
54+            }
55 	}
56     }
57
58--
592.7.4
60
61