X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Frepodata.c;h=a812ba84dda0d13202164aaf4a5994c937bf0e40;hb=7b272a2e7df10744df1b7224b1abebeba64f88d6;hp=41b7b8dbeabb35fefb7d91e6b883033d95a1c049;hpb=c36ef29531924b0a2ec37cdac57211dac32837b1;p=platform%2Fupstream%2Flibsolv.git diff --git a/src/repodata.c b/src/repodata.c index 41b7b8d..a812ba8 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -682,22 +682,28 @@ repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned long long *v { unsigned char *dp; Repokey *key; - KeyValue kv; + unsigned int high, low; *value = 0; dp = find_key_data(data, solvid, keyname, &key); if (!dp) return 0; - if (key->type == REPOKEY_TYPE_NUM - || key->type == REPOKEY_TYPE_U32 - || key->type == REPOKEY_TYPE_CONSTANT) + switch (key->type) { - kv.num = kv.num2 = 0; - dp = data_fetch(dp, &kv, key); - *value = SOLV_KV_NUM64(&kv); + case REPOKEY_TYPE_NUM: + data_read_num64(dp, &low, &high); + *value = (unsigned long long)high << 32 | low; + return 1; + case REPOKEY_TYPE_U32: + data_read_u32(dp, &low); + *value = low; + return 1; + case REPOKEY_TYPE_CONSTANT: + *value = key->size; return 1; + default: + return 0; } - return 0; } int @@ -728,6 +734,8 @@ repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep) dp = find_key_data(data, solvid, keyname, &key); if (!dp) return 0; + if (!(key->type == REPOKEY_TYPE_MD5 || key->type == REPOKEY_TYPE_SHA1 || key->type == REPOKEY_TYPE_SHA256)) + return 0; *typep = key->type; return dp; } @@ -1585,6 +1593,11 @@ dataiterator_step(Dataiterator *di) if (!datamatcher_match(&di->matcher, di->kv.str)) continue; } + else + { + if (di->keyname == SOLVABLE_FILELIST && di->key->type == REPOKEY_TYPE_DIRSTRARRAY && (di->flags & SEARCH_FILES) != 0) + repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags); + } /* found something! */ return 1; } @@ -2219,7 +2232,7 @@ evrid2vrstr(Pool *pool, Id evrid) return evr; for (p = evr; *p >= '0' && *p <= '9'; p++) ; - return p != evr && *p == ':' ? p + 1 : evr; + return p != evr && *p == ':' && p[1] ? p + 1 : evr; } void @@ -2291,6 +2304,138 @@ repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, c repodata_set_str(data, solvid, SOLVABLE_MEDIAFILE, file); } +static inline void repodata_set_poolstrn(Repodata *data, Id solvid, Id keyname, const char *str, int l) +{ + Id id; + if (data->localpool) + id = stringpool_strn2id(&data->spool, str, l, 1); + else + id = pool_strn2id(data->repo->pool, str, l, 1); + repodata_set_id(data, solvid, keyname, id); +} + +/* XXX: medianr is currently not stored */ +void +repodata_set_deltalocation(Repodata *data, Id handle, int medianr, const char *dir, const char *file) +{ + int l = 0; + const char *evr, *suf, *s; + + if (!dir) + { + if ((dir = strrchr(file, '/')) != 0) + { + l = dir - file; + dir = file; + file = dir + l + 1; + if (!l) + l++; + } + } + else + l = strlen(dir); + if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/')) + { + dir += 2; + l -= 2; + } + if (l == 1 && dir[0] == '.') + l = 0; + if (dir && l) + repodata_set_poolstrn(data, handle, DELTA_LOCATION_DIR, dir, l); + evr = strchr(file, '-'); + if (evr) + { + for (s = evr - 1; s > file; s--) + if (*s == '-') + { + evr = s; + break; + } + } + suf = strrchr(file, '.'); + if (suf) + { + for (s = suf - 1; s > file; s--) + if (*s == '.') + { + suf = s; + break; + } + if (!strcmp(suf, ".delta.rpm") || !strcmp(suf, ".patch.rpm")) + { + /* We accept one more item as suffix. */ + for (s = suf - 1; s > file; s--) + if (*s == '.') + { + suf = s; + break; + } + } + } + if (!evr) + suf = 0; + if (suf && evr && suf < evr) + suf = 0; + repodata_set_poolstrn(data, handle, DELTA_LOCATION_NAME, file, evr ? evr - file : strlen(file)); + if (evr) + repodata_set_poolstrn(data, handle, DELTA_LOCATION_EVR, evr + 1, suf ? suf - evr - 1: strlen(evr + 1)); + if (suf) + repodata_set_poolstr(data, handle, DELTA_LOCATION_SUFFIX, suf + 1); +} + +void +repodata_set_sourcepkg(Repodata *data, Id solvid, const char *sourcepkg) +{ + Pool *pool = data->repo->pool; + Solvable *s = pool->solvables + solvid; + const char *p, *sevr, *sarch, *name, *evr; + + p = strrchr(sourcepkg, '.'); + if (!p || strcmp(p, ".rpm") != 0) + { + if (*sourcepkg) + repodata_set_str(data, solvid, SOLVABLE_SOURCENAME, sourcepkg); + return; + } + p--; + while (p > sourcepkg && *p != '.') + p--; + if (*p != '.' || p == sourcepkg) + return; + sarch = p-- + 1; + while (p > sourcepkg && *p != '-') + p--; + if (*p != '-' || p == sourcepkg) + return; + p--; + while (p > sourcepkg && *p != '-') + p--; + if (*p != '-' || p == sourcepkg) + return; + sevr = p + 1; + pool = s->repo->pool; + + name = pool_id2str(pool, s->name); + if (name && !strncmp(sourcepkg, name, sevr - sourcepkg - 1) && name[sevr - sourcepkg - 1] == 0) + repodata_set_void(data, solvid, SOLVABLE_SOURCENAME); + else + repodata_set_id(data, solvid, SOLVABLE_SOURCENAME, pool_strn2id(pool, sourcepkg, sevr - sourcepkg - 1, 1)); + + evr = evrid2vrstr(pool, s->evr); + if (evr && !strncmp(sevr, evr, sarch - sevr - 1) && evr[sarch - sevr - 1] == 0) + repodata_set_void(data, solvid, SOLVABLE_SOURCEEVR); + else + repodata_set_id(data, solvid, SOLVABLE_SOURCEEVR, pool_strn2id(pool, sevr, sarch - sevr - 1, 1)); + + if (!strcmp(sarch, "src.rpm")) + repodata_set_constantid(data, solvid, SOLVABLE_SOURCEARCH, ARCH_SRC); + else if (!strcmp(sarch, "nosrc.rpm")) + repodata_set_constantid(data, solvid, SOLVABLE_SOURCEARCH, ARCH_NOSRC); + else + repodata_set_constantid(data, solvid, SOLVABLE_SOURCEARCH, pool_strn2id(pool, sarch, strlen(sarch) - 4, 1)); +} + void repodata_set_idarray(Repodata *data, Id solvid, Id keyname, Queue *q) { @@ -2384,7 +2529,7 @@ repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle) } void -repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname) +repodata_set_deleted_uninternalized(Repodata *data, Id solvid, Id keyname) { Id *pp, *ap, **app; app = repodata_get_attrp(data, solvid); @@ -2410,7 +2555,7 @@ repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname) /* XXX: does not work correctly, needs fix in iterators! */ void -repodata_delete(Repodata *data, Id solvid, Id keyname) +repodata_set_deleted(Repodata *data, Id solvid, Id keyname) { Repokey key; key.name = keyname; @@ -2425,7 +2570,7 @@ void repodata_merge_attrs(Repodata *data, Id dest, Id src) { Id *keyp; - if (dest == src || data->attrs || !(keyp = data->attrs[src - data->start])) + if (dest == src || !data->attrs || !(keyp = data->attrs[src - data->start])) return; for (; *keyp; keyp += 2) repodata_insert_keyid(data, dest, keyp[0], keyp[1], 0);