2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * create architecture policies
23 static const char *archpolicies[] = {
24 #if defined(FEDORA) || defined(MAGEIA)
25 "x86_64_v4", "x86_64_v4:x86_64_v3:x86_64_v2:x86_64:athlon:i686:i586:i486:i386",
26 "x86_64_v3", "x86_64_v3:x86_64_v2:x86_64:athlon:i686:i586:i486:i386",
27 "x86_64_v2", "x86_64_v2:x86_64:athlon:i686:i586:i486:i386",
28 "x86_64", "x86_64:athlon:i686:i586:i486:i386",
30 "x86_64_v4", "x86_64_v4:x86_64_v3:x86_64_v2:x86_64:i686:i586:i486:i386",
31 "x86_64_v3", "x86_64_v3:x86_64_v2:x86_64:i686:i586:i486:i386",
32 "x86_64_v2", "x86_64_v2:x86_64:i686:i586:i486:i386",
33 "x86_64", "x86_64:i686:i586:i486:i386",
35 "i686", "i686:i586:i486:i386",
36 "i586", "i586:i486:i386",
38 "s390x", "s390x:s390",
40 "ppc64p7", "ppc64p7:ppc64:ppc",
41 "ia64", "ia64:i686:i586:i486:i386",
42 "armv8hcnl", "armv8hcnl:armv8hnl:armv8hl:armv7hnl:armv7hl:armv6hl",
43 "armv8hnl", "armv8hnl:armv8hl:armv7hnl:armv7hl:armv6hl",
44 "armv8hl", "armv8hl:armv7hl:armv6hl",
45 "armv8l", "armv8l:armv7l:armv6l:armv5tejl:armv5tel:armv5tl:armv5l:armv4tl:armv4l:armv3l",
46 "armv7hnl", "armv7hnl:armv7hl:armv6hl",
47 "armv7hl", "armv7hl:armv6hl",
48 "armv7l", "armv7l:armv6l:armv5tejl:armv5tel:armv5tl:armv5l:armv4tl:armv4l:armv3l",
49 "armv6l", "armv6l:armv5tejl:armv5tel:armv5tl:armv5l:armv4tl:armv4l:armv3l",
50 "armv5tejl", "armv5tejl:armv5tel:armv5tl:armv5l:armv4tl:armv4l:armv3l",
51 "armv5tel", "armv5tel:armv5tl:armv5l:armv4tl:armv4l:armv3l",
52 "armv5tl", "armv5tl:armv5l:armv4tl:armv4l:armv3l",
53 "armv5l", "armv5l:armv4tl:armv4l:armv3l",
54 "armv4tl", "armv4tl:armv4l:armv3l",
55 "armv4l", "armv4l:armv3l",
57 "sparc64v", "sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc",
58 "sparc64", "sparc64:sparcv9:sparcv8:sparc",
59 "sparcv9v", "sparcv9v:sparcv9:sparcv8:sparc",
60 "sparcv9", "sparcv9:sparcv8:sparc",
61 "sparcv8", "sparcv8:sparc",
62 #if defined(FEDORA) || defined(MAGEIA)
63 "ia32e", "ia32e:x86_64:athlon:i686:i586:i486:i386",
64 "athlon", "athlon:i686:i586:i486:i386",
65 "amd64", "amd64:x86_64:athlon:i686:i586:i486:i386",
66 "geode", "geode:i586:i486:i386",
67 "ppc64iseries", "ppc64iseries:ppc64:ppc",
68 "ppc64pseries", "ppc64pseries:ppc64:ppc",
74 pool_setarch(Pool *pool, const char *arch)
79 /* convert arch to known policy */
80 for (i = 0; archpolicies[i]; i += 2)
81 if (!strcmp(archpolicies[i], arch))
83 arch = archpolicies[i + 1];
87 pool_setarchpolicy(pool, arch);
91 * we support three relations:
93 * a = b both architectures a and b are treated as equivalent
94 * a > b a is considered a "better" architecture, the solver
95 * should change from a to b, but must not change from b to a
96 * a : b a is considered a "better" architecture, the solver
97 * must not change the architecture from a to b or b to a
100 pool_setarchpolicy(Pool *pool, const char *arch)
102 unsigned int score = 0x10001;
108 pool->id2arch = solv_free(pool->id2arch);
109 pool->id2color = solv_free(pool->id2color);
117 /* note that we overallocate one element to be compatible with
118 * old versions that accessed id2arch[lastarch].
119 * id2arch[lastarch] will always be zero */
120 id2arch = solv_calloc(lastarch + 1, sizeof(Id));
121 id2arch[id] = 1; /* the "noarch" class */
126 l = strcspn(arch, ":=>");
129 id = pool_strn2id(pool, arch, l, 1);
132 id2arch = solv_realloc2(id2arch, (id + 255 + 1), sizeof(Id));
133 memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id));
136 if (id2arch[id] == 0)
146 if ((d = *arch++) == 0)
149 pool->id2arch = id2arch;
150 pool->lastarch = lastarch;
154 pool_arch2color_slow(Pool *pool, Id arch)
159 if ((unsigned int)arch >= (unsigned int)pool->lastarch)
160 return ARCHCOLOR_ALL;
162 pool->id2color = solv_calloc(pool->lastarch + 1, 1);
163 s = pool_id2str(pool, arch);
164 if (arch == ARCH_NOARCH || arch == ARCH_ALL || arch == ARCH_ANY)
165 color = ARCHCOLOR_ALL;
166 else if (!strcmp(s, "s390x") || strstr(s, "64"))
167 color = ARCHCOLOR_64;
169 color = ARCHCOLOR_32;
170 pool->id2color[arch] = color;