summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpm-respect-arch.patch
blob: 9b63b37fead290aee31d38fc269bfbe4a1234073 (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
rpmts.c: respect to the arch priorities

Let rpm respect to the priorities when choose alternatives rpm, the arch
which comes first is preferred.

Upstream-Status: Pending

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 lib/rpmts.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/rpmts.c b/lib/rpmts.c
index 3fbbc9e..40ec08e 100644
--- a/lib/rpmts.c
+++ b/lib/rpmts.c
@@ -353,6 +353,7 @@ int rpmtsSolve(rpmts ts, rpmds ds, /*@unused@*/ const void * data)
     Header h = NULL;
     size_t bhnamelen = 0;
     time_t bhtime = 0;
+    const char *bharch = NULL;
     rpmTag rpmtag;
     const char * keyp;
     size_t keylen = 0;
@@ -409,6 +410,7 @@ fprintf(stderr, "--> %s(%p,%p,%p)\n", __FUNCTION__, ts, ds, data);
 	while ((h = rpmmiNext(mi)) != NULL) {
 	    size_t hnamelen;
 	    time_t htime;
+	    const char *harch = NULL;
 
 	    if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
 		continue;
@@ -431,12 +433,23 @@ fprintf(stderr, "--> %s(%p,%p,%p)\n", __FUNCTION__, ts, ds, data);
 	    if (htime <= bhtime)
 		continue;
 
+	    /* XXX Respect to the arch priorities */
+	    he->tag = RPMTAG_ARCH;
+	    xx = headerGet(h, he, 0);
+	    harch = ((xx && he->p.str) ? xstrdup(he->p.str) : NULL);
+	    he->p.ptr = _free(he->p.ptr);
+	    if (bharch && (strcmp(bharch, harch) != 0))
+		continue;
+
 	    /* Save new "best" candidate. */
 	    (void)headerFree(bh);
 	    bh = NULL;
 	    bh = headerLink(h);
 	    bhtime = htime;
 	    bhnamelen = hnamelen;
+	    bharch = _free(bharch);
+	    bharch = xstrdup(harch);
+	    harch = _free(harch);
 	}
 	mi = rpmmiFree(mi);
 
@@ -449,6 +462,7 @@ fprintf(stderr, "--> %s(%p,%p,%p)\n", __FUNCTION__, ts, ds, data);
       } while (1);
 
     }
+    bharch = _free(bharch);
 
     /* Is there a suggested resolution? */
     if (bh == NULL)
-- 
1.7.1