From: Michael Schroeder Date: Fri, 2 Oct 2009 10:14:08 +0000 (+0200) Subject: - add repodata_delete_uninternalized X-Git-Tag: BASE-SuSE-Code-12_1-Branch~161^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=910ad3a912011d4f0414cc92b2666e18428f0ace;p=platform%2Fupstream%2Flibsolv.git - add repodata_delete_uninternalized - fix bugs in deb handling - add support for MULTI_SEMANTICS needed for the build service - add --withsrc option for installcheck --- diff --git a/ext/repo_deb.c b/ext/repo_deb.c index 9aaa3c1..8b18f45 100644 --- a/ext/repo_deb.c +++ b/ext/repo_deb.c @@ -63,88 +63,94 @@ decompress(unsigned char *in, int inl, int *outlp) return out; } -static unsigned int -makedeps(Repo *repo, char *deps, unsigned int olddeps, Id marker) +static Id +parseonedep(Pool *pool, char *p) { - Pool *pool = repo->pool; - char *p, *n, *ne, *e, *ee; - Id id, name, evr; + char *n, *ne, *e, *ee; + Id name, evr; int flags; - while ((p = strchr(deps, ',')) != 0) + while (*p == ' ' || *p == '\t' || *p == '\n') + p++; + if (!*p || *p == '(') + return 0; + n = p; + /* find end of name */ + while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '(' && *p != '|') + p++; + ne = p; + while (*p == ' ' || *p == '\t' || *p == '\n') + p++; + evr = 0; + flags = 0; + e = ee = 0; + if (*p == '(') { - *p++ = 0; - olddeps = makedeps(repo, deps, olddeps, marker); - deps = p; - } - id = 0; - p = deps; - for (;;) - { - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; - if (!*p || *p == '(') - break; - n = p; - while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '(' && *p != '|') - p++; - ne = p; + p++; while (*p == ' ' || *p == '\t' || *p == '\n') p++; - evr = 0; - flags = 0; - e = ee = 0; - if (*p == '(') + if (*p == '>') + flags |= REL_GT; + else if (*p == '=') + flags |= REL_EQ; + else if (*p == '<') + flags |= REL_LT; + if (flags) { p++; - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; if (*p == '>') flags |= REL_GT; else if (*p == '=') flags |= REL_EQ; else if (*p == '<') flags |= REL_LT; - if (flags) - { - p++; - if (*p == '>') - flags |= REL_GT; - else if (*p == '=') - flags |= REL_EQ; - else if (*p == '<') - flags |= REL_LT; - else - p--; - p++; - } - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; - e = p; - while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != ')') - p++; - ee = p; - while (*p && *p != ')') - p++; - if (*p) - p++; - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; - } - name = strn2id(pool, n, ne - n, 1); - if (e) - { - evr = strn2id(pool, e, ee - e, 1); - name = rel2id(pool, name, evr, flags, 1); + else + p--; + p++; } - if (!id) - id = name; - else - id = rel2id(pool, id, name, REL_OR, 1); - if (*p != '|') - break; - p++; + while (*p == ' ' || *p == '\t' || *p == '\n') + p++; + e = p; + while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != ')') + p++; + ee = p; + while (*p && *p != ')') + p++; + if (*p) + p++; + while (*p == ' ' || *p == '\t' || *p == '\n') + p++; + } + name = strn2id(pool, n, ne - n, 1); + if (e) + { + evr = strn2id(pool, e, ee - e, 1); + name = rel2id(pool, name, evr, flags, 1); + } + if (*p == '|') + { + Id id = parseonedep(pool, p + 1); + if (id) + name = rel2id(pool, name, id, REL_OR, 1); + } + return name; +} + +static unsigned int +makedeps(Repo *repo, char *deps, unsigned int olddeps, Id marker) +{ + Pool *pool = repo->pool; + char *p; + Id id; + + while ((p = strchr(deps, ',')) != 0) + { + *p = 0; + olddeps = makedeps(repo, deps, olddeps, marker); + *p = ','; + deps = p + 1; } + id = parseonedep(pool, deps); if (!id) return olddeps; return repo_addid_dep(repo, olddeps, id, marker); @@ -160,6 +166,7 @@ control2solvable(Solvable *s, Repodata *data, char *control) Pool *pool = repo->pool; char *p, *q, *end, *tag; int x, l; + int havesource = 0; p = control; while (*p) @@ -256,6 +263,16 @@ control2solvable(Solvable *s, Repodata *data, char *control) else if (!strcasecmp(tag, "recommends")) s->recommends = makedeps(repo, q, s->recommends, 0); break; + case 'S' << 8 | 'O': + if (!strcasecmp(tag, "source")) + { + if (s->name && !strcmp(q, id2str(pool, s->name))) + repodata_set_void(data, s - pool->solvables, SOLVABLE_SOURCENAME); + else + repodata_set_id(data, s - pool->solvables, SOLVABLE_SOURCENAME, str2id(pool, q, 1)); + havesource = 1; + } + break; case 'S' << 8 | 'U': if (!strcasecmp(tag, "suggests")) s->suggests = makedeps(repo, q, s->suggests, 0); @@ -272,6 +289,8 @@ control2solvable(Solvable *s, Repodata *data, char *control) s->evr = ID_EMPTY; if (s->name) s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + if (s->name && !havesource) + repodata_set_void(data, s - pool->solvables, SOLVABLE_SOURCENAME); } void diff --git a/src/evr.c b/src/evr.c index 4cd3e81..4d6318f 100644 --- a/src/evr.c +++ b/src/evr.c @@ -17,8 +17,14 @@ #include "pool.h" -#ifdef DEBIAN_SEMANTICS +#if defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS) + +#ifdef MULTI_SEMANTICS +# define vercmp vercmp_deb +#endif + +/* debian type version compare */ int vercmp(const char *s1, const char *q1, const char *s2, const char *q2) { @@ -58,8 +64,15 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2) } } -#else +#ifdef MULTI_SEMANTICS +# undef vercmp +#endif + +#endif + +#if !defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS) +/* rpm type version compare */ int vercmp(const char *s1, const char *q1, const char *s2, const char *q2) { @@ -119,6 +132,9 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2) #endif +#if defined(MULTI_SEMANTICS) +# define vercmp (*(pool->disttype == DISTTYPE_DEB ? &vercmp_deb : &ver##cmp)) +#endif /* edition (e:v-r) compare */ int diff --git a/src/pool.c b/src/pool.c index 0b0648e..19a8225 100644 --- a/src/pool.c +++ b/src/pool.c @@ -88,6 +88,14 @@ pool_free(Pool *pool) sat_free(pool); } +#ifdef MULTI_SEMANTICS +void +pool_setdisttype(Pool *pool, int disttype) +{ + pool->disttype = disttype; +} +#endif + Id pool_add_solvable(Pool *pool) { @@ -416,6 +424,14 @@ pool_queuetowhatprovides(Pool *pool, Queue *q) /*************************************************************************/ +#if defined(MULTI_SEMANTICS) +# define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE) +#elif defined(DEBIAN_SEMANTICS) +# define EVRCMP_DEPCMP EVRCMP_COMPARE +#else +# define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE +#endif + /* check if a package's nevr matches a dependency */ int @@ -457,13 +473,8 @@ pool_match_nevr_rel(Pool *pool, Solvable *s, Id d) return 1; if (flags != 2 && flags != 5) flags ^= 5; -#ifdef DEBIAN_SEMANTICS - if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_COMPARE)))) != 0) - return 1; -#else - if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_MATCH_RELEASE)))) != 0) + if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP)))) != 0) return 1; -#endif return 0; } @@ -508,13 +519,8 @@ pool_match_dep(Pool *pool, Id d1, Id d2) else { int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5); -#ifdef DEBIAN_SEMANTICS - if ((f & (1 << (1 + evrcmp(pool, rd1->evr, rd2->evr, EVRCMP_COMPARE)))) != 0) + if ((f & (1 << (1 + evrcmp(pool, rd1->evr, rd2->evr, EVRCMP_DEPCMP)))) != 0) return 1; -#else - if ((f & (1 << (1 + evrcmp(pool, rd1->evr, rd2->evr, EVRCMP_MATCH_RELEASE)))) != 0) - return 1; -#endif } return 0; } @@ -679,7 +685,12 @@ pool_addrelproviders(Pool *pool, Id d) if (pid == name) { -#ifdef DEBIAN_SEMANTICS +#if defined(MULTI_SEMANTICS) + if (pool->disttype == DISTTYPE_DEB) + continue; + else + break; +#elif defined(DEBIAN_SEMANTICS) continue; /* unversioned provides can * never match versioned deps */ #else @@ -708,13 +719,8 @@ pool_addrelproviders(Pool *pool, Id d) else { int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5); -#ifdef DEBIAN_SEMANTICS - if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_COMPARE)))) != 0) - break; -#else - if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_MATCH_RELEASE)))) != 0) + if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_DEPCMP)))) != 0) break; -#endif } } if (!pid) diff --git a/src/pool.h b/src/pool.h index d82a64d..d82a0d1 100644 --- a/src/pool.h +++ b/src/pool.h @@ -82,6 +82,9 @@ struct _Pool { int obsoleteusescolors; /* true: obsoletes check arch color */ int novirtualconflicts; /* true: conflicts on names, not on provides */ int allowselfconflicts; /* true: packages which conflict with itself are installable */ +#ifdef MULTI_SEMANTICS + int disttype; +#endif Id *id2arch; /* map arch ids to scores */ unsigned char *id2color; /* map arch ids to colors */ @@ -125,6 +128,11 @@ struct _Pool { Repopos pos; }; +#ifdef MULTI_SEMANTICS +# define DISTTYPE_RPM 0 +# define DISTTYPE_DEB 1 +#endif + #define SAT_FATAL (1<<0) #define SAT_ERROR (1<<1) #define SAT_WARN (1<<2) @@ -177,6 +185,11 @@ extern Pool *pool_create(void); */ extern void pool_free(Pool *pool); +extern void pool_setdebuglevel(Pool *pool, int level); +#ifdef MULTI_SEMANTICS +extern void pool_setdisttype(Pool *pool, int disttype); +#endif + extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4))); extern char *pool_alloctmpspace(Pool *pool, int len); @@ -265,8 +278,6 @@ static inline Id *pool_whatprovides_ptr(Pool *pool, Id d) return pool->whatprovidesdata + off; } -extern void pool_setdebuglevel(Pool *pool, int level); - static inline void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata) { pool->debugcallback = debugcallback; diff --git a/src/repodata.c b/src/repodata.c index e0072e6..551d83a 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -2263,6 +2263,31 @@ repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle) data->attriddata[data->attriddatalen++] = 0; } +void +repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname) +{ + Id *pp, *ap, **app; + app = repodata_get_attrp(data, solvid); + ap = *app; + if (!ap) + return; + for (; *ap; ap += 2) + if (data->keys[*ap].name == keyname) + break; + if (!*ap) + return; + pp = ap; + ap += 2; + for (; *ap; ap += 2) + { + if (data->keys[*ap].name == keyname) + continue; + *pp++ = ap[0]; + *pp++ = ap[1]; + } + *pp = 0; +} + /* add all attrs from src to dest */ void repodata_merge_attrs(Repodata *data, Id dest, Id src) diff --git a/src/repodata.h b/src/repodata.h index 1f9fa6e..feac731 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -240,6 +240,8 @@ void repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname, const cha void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle); void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle); +void repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname); + /* merge attributes from one solvable to another works only if the data is not yet internalized diff --git a/tools/installcheck.c b/tools/installcheck.c index 9701ae0..bab686c 100644 --- a/tools/installcheck.c +++ b/tools/installcheck.c @@ -80,6 +80,7 @@ main(int argc, char **argv) Id rpmid, rpmarch, rpmrel, archlock; int status = 0; int nocheck = 0; + int withsrc = 0; exclude_pat = 0; archlock = 0; @@ -94,6 +95,11 @@ main(int argc, char **argv) FILE *fp; int l; + if (!strcmp(argv[i], "--withsrc")) + { + withsrc++; + continue; + } if (!strcmp(argv[i], "--nocheck")) { if (!nocheck) @@ -166,6 +172,11 @@ main(int argc, char **argv) Solvable *s = pool->solvables + p; if (!s->repo) continue; + if (withsrc && (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)) + { + queue_push(&cand, p); + continue; + } if (!pool_installable(pool, s)) continue; if (rpmrel && s->arch != rpmarch)