aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python-smartpm/smart-prefer-same-arch.patch
blob: b1305b512d3301046000d9a5d0508c8a959c93cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
From 1749592a76425449c1f3119fb14db3f5e14226ed Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Tue, 27 Oct 2015 06:20:45 -0700
Subject: [PATCH] smart/transaction.py: prefer same arch when install

We had made smart install multilib RDEPENDS correctly from
package_manager.py, but it couldn't handle RRECOMMANDS, this patch fix
the issue from python-smartpm-native, and make it work well.

The logic is: when pkg_A rdepends/rrecommands pkg_B, then let pkg_B use
pkg_A's arch when possible.

This patch fixed:
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
RPM_PREFER_ELF_ARCH = "1"
IMAGE_INSTALL_append = " lib32-connman-gnome"
MACHINE = "qemux86-64"

$ bitbake core-image-sato

Only 64bit loaders like libgdk-pixbuf-2.0-loader-jpeg and
libgdk-pixbuf-2.0-loader-png were installed before this patch since they
are in RRECOMMANDS, now both 32bit and 64bit are installed.

This patch is for native only to minimize the impact for this release,
the main problem is the "if attempt:", otherwise, more packages like
lib32-libc6-dev will be installed when populate_sdk, but only libc6-dev
were installed before. We need reconstruct the way that we install the
complentary packages in future release, the "if attempt:" make they work
together atm.

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 smart/transaction.py |   28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/smart/transaction.py b/smart/transaction.py
index f022aae..63a837c 100644
--- a/smart/transaction.py
+++ b/smart/transaction.py
@@ -22,6 +22,7 @@
 from smart.const import INSTALL, REMOVE, UPGRADE, FIX, REINSTALL, KEEP, LOCKED_EXCLUDE, LOCKED_INSTALL, LOCKED_CONFLICT, LOCKED_CONFLICT_BY, LOCKED_NO_COEXIST, LOCKED_SYSCONF, LOCKED_REMOVE
 from smart.cache import PreRequires, Package
 from smart import *
+from smart.backends.rpm.rpmver import splitarch
 
 def lock_reason(pkg, lockvalue):
     try:
@@ -618,6 +619,7 @@ class Transaction(object):
                     self._remove(namepkg, changeset, locked, pending, depth)
 
         # Install packages required by this one.
+        pkgarch = splitarch(pkg.version)[1]
         for req in pkg.requires + pkg.recommends:
 
             reqrequired = req in pkg.requires
@@ -626,6 +628,8 @@ class Transaction(object):
             prvpkgs = {}
             lockedpkgs = {}
             found = False
+            found_same_arch = False
+            same_arch_in_provides = False
             for prv in req.providedby:
                 for prvpkg in prv.packages:
                     if not reqrequired:
@@ -633,9 +637,19 @@ class Transaction(object):
                             continue
                         elif pkgconf.testFlag("ignore-recommends", prvpkg):
                             continue
+                    prvpkgarch = splitarch(prvpkg.version)[1]
+                    if pkgarch == prvpkgarch:
+                        # Found a same arch in provides
+                        same_arch_in_provides = True
                     if isinst(prvpkg):
                         found = True
-                        break
+                        if attempt:
+                            break
+                        if pkgarch == prvpkgarch:
+                            # Found the best match
+                            found_same_arch = True
+                            break
+                        continue
                     if prvpkg not in locked:
                         prvpkgs[prvpkg] = True
                     else:
@@ -643,7 +657,7 @@ class Transaction(object):
                 else:
                     continue
                 break
-            if found:
+            if found_same_arch or (found and attempt) or (found and not same_arch_in_provides):
                 # Someone is already providing it. Good.
                 continue
 
@@ -672,7 +686,15 @@ class Transaction(object):
 
                     # It's only a recommend, skip
                     continue
-
+            if len(prvpkgs) > 1 and not attempt:
+                prvarchs = set()
+                for prv in prvpkgs:
+                    prvarchs.add(splitarch(prv.version)[1])
+                if pkgarch in prvarchs:
+                    # Prefer the one which has the same arch
+                    for prv in prvpkgs.copy():
+                        if splitarch(prv.version)[1] != pkgarch:
+                                del prvpkgs[prv]
             if len(prvpkgs) == 1:
                 # Don't check locked here. prvpkgs was
                 # already filtered above.
-- 
1.7.9.5