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 "x86_64", "x86_64:i686:i586:i486:i386",
25 "i686", "i686:i586:i486:i386",
26 "i586", "i586:i486:i386",
29 "s390x", "s390x:s390",
31 "ia64", "ia64:i686:i586:i486:i386",
34 "ppc64p7", "ppc64p7:ppc64:ppc",
38 "armv7hnl", "armv7hnl:armv7hl:armv6hl",
39 "armv7hl", "armv7hl:armv6hl",
40 "armv7l", "armv7l:armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
41 "armv6l", "armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
42 "armv5tejl", "armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
43 "armv5tel", "armv5tel:armv5l:armv4tl:armv4l:armv3l",
44 "armv5tl", "armv5l:armv4tl:armv4l:armv3l",
45 "armv5l", "armv5l:armv4tl:armv4l:armv3l",
46 "armv4tl", "armv4tl:armv4l:armv3l",
47 "armv4l", "armv4l:armv3l",
52 "sparc64v", "sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc",
53 "sparc64", "sparc64:sparcv9:sparcv8:sparc",
54 "sparcv9v", "sparcv9v:sparcv9:sparcv8:sparc",
55 "sparcv9", "sparcv9:sparcv8:sparc",
56 "sparcv8", "sparcv8:sparc",
64 pool_setarch(Pool *pool, const char *arch)
70 /* convert arch to known policy */
71 for (i = 0; archpolicies[i]; i += 2)
72 if (!strcmp(archpolicies[i], arch))
75 arch = archpolicies[i + 1];
79 pool_setarchpolicy(pool, arch);
83 * we support three relations:
85 * a = b both architectures a and b are treated as equivalent
86 * a > b a is considered a "better" architecture, the solver
87 * should change from a to b, but must not change from b to a
88 * a : b a is considered a "better" architecture, the solver
89 * must not change the architecture from a to b or b to a
92 pool_setarchpolicy(Pool *pool, const char *arch)
94 unsigned int score = 0x10001;
100 pool->id2arch = solv_free(pool->id2arch);
101 pool->id2color = solv_free(pool->id2color);
109 id2arch = solv_calloc(lastarch + 1, sizeof(Id));
110 id2arch[id] = 1; /* the "noarch" class */
115 l = strcspn(arch, ":=>");
118 id = pool_strn2id(pool, arch, l, 1);
121 id2arch = solv_realloc2(id2arch, (id + 255 + 1), sizeof(Id));
122 memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id));
125 if (id2arch[id] == 0)
135 if ((d = *arch++) == 0)
138 pool->id2arch = id2arch;
139 pool->lastarch = lastarch;
143 pool_arch2color_slow(Pool *pool, Id arch)
148 if (arch > pool->lastarch)
149 return ARCHCOLOR_ALL;
151 pool->id2color = solv_calloc(pool->lastarch + 1, 1);
152 s = pool_id2str(pool, arch);
153 if (arch == ARCH_NOARCH || arch == ARCH_ALL || arch == ARCH_ANY)
154 color = ARCHCOLOR_ALL;
155 else if (!strcmp(s, "s390x") || strstr(s, "64"))
156 color = ARCHCOLOR_64;
158 color = ARCHCOLOR_32;
159 pool->id2color[arch] = color;