summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2011-03-23 15:56:11 +0100
committerMichael Schroeder <mls@suse.de>2011-03-23 15:56:11 +0100
commita119ec98998a658242b9b7f15ce813a498615164 (patch)
tree6e3d8cadbc7d89572a13211a5d9d849ab3e6c00c
parent18579bb4c39283c45f3a323652d763097f0186de (diff)
downloadlibsolv-a119ec98998a658242b9b7f15ce813a498615164.tar.gz
libsolv-a119ec98998a658242b9b7f15ce813a498615164.tar.bz2
libsolv-a119ec98998a658242b9b7f15ce813a498615164.zip
- add pool_setarchpolicy() method
-rw-r--r--src/poolarch.c52
-rw-r--r--src/poolarch.h1
2 files changed, 37 insertions, 16 deletions
diff --git a/src/poolarch.c b/src/poolarch.c
index 34a14a3..fdb8175 100644
--- a/src/poolarch.c
+++ b/src/poolarch.c
@@ -20,7 +20,7 @@
#include "poolarch.h"
#include "util.h"
-const char *archpolicies[] = {
+static const char *archpolicies[] = {
"x86_64", "x86_64:i686:i586:i486:i386",
"i686", "i686:i586:i486:i386",
"i586", "i586:i486:i386",
@@ -56,11 +56,37 @@ const char *archpolicies[] = {
void
pool_setarch(Pool *pool, const char *arch)
{
- const char *a;
+ if (arch)
+ {
+ int i;
+
+ /* convert arch to known policy */
+ for (i = 0; archpolicies[i]; i += 2)
+ if (!strcmp(archpolicies[i], arch))
+ break;
+ if (archpolicies[i])
+ arch = archpolicies[i + 1];
+ else
+ arch = "";
+ }
+ pool_setarchpolicy(pool, arch);
+}
+
+/*
+ * we support three relations:
+ *
+ * a = b both architectures a and b are treated as equivalent
+ * a > b a is considered a "better" architecture, the solver
+ * should change from a to b, but must not change from b to a
+ * a : b a is considered a "better" architecture, the solver
+ * must not change the architecture from a to b or b to a
+ */
+void
+pool_setarchpolicy(Pool *pool, const char *arch)
+{
unsigned int score = 0x10001;
size_t l;
char d;
- int i;
Id *id2arch;
Id id, lastarch;
@@ -78,24 +104,18 @@ pool_setarch(Pool *pool, const char *arch)
#endif
lastarch = id + 255;
id2arch = sat_calloc(lastarch + 1, sizeof(Id));
- id2arch[id] = 1;
+ id2arch[id] = 1; /* the "noarch" class */
- a = "";
- for (i = 0; archpolicies[i]; i += 2)
- if (!strcmp(archpolicies[i], arch))
- break;
- if (archpolicies[i])
- a = archpolicies[i + 1];
d = 0;
- while (*a)
+ while (*arch)
{
- l = strcspn(a, ":=>");
+ l = strcspn(arch, ":=>");
if (l)
{
- id = strn2id(pool, a, l, 1);
+ id = strn2id(pool, arch, l, 1);
if (id > lastarch)
{
- id2arch = sat_realloc(id2arch, (id + 255 + 1) * sizeof(Id));
+ id2arch = sat_realloc2(id2arch, (id + 255 + 1), sizeof(Id));
memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id));
lastarch = id + 255;
}
@@ -108,8 +128,8 @@ pool_setarch(Pool *pool, const char *arch)
id2arch[id] = score;
}
}
- a += l;
- if ((d = *a++) == 0)
+ arch += l;
+ if ((d = *arch++) == 0)
break;
}
pool->id2arch = id2arch;
diff --git a/src/poolarch.h b/src/poolarch.h
index 5ace54f..e9ae99b 100644
--- a/src/poolarch.h
+++ b/src/poolarch.h
@@ -11,6 +11,7 @@
#include "pool.h"
extern void pool_setarch(Pool *, const char *);
+extern void pool_setarchpolicy(Pool *, const char *);
extern unsigned char pool_arch2color_slow(Pool *pool, Id arch);
#define ARCHCOLOR_32 1