ref: refs/heads/master
commit f2f846e40b74860c2bd1c8a3c83ba43410b96c61
Author: Michael Schroeder
Date: Tue Jul 21 13:06:10 2009 +0200
- fix stub handling bugs
---
examples/solv.c | 11 ++++++-----
src/repo_solv.c | 13 ++++++++-----
src/repo_solv.h | 2 ++
src/repodata.c | 22 +++++++++++++++-------
4 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/examples/solv.c b/examples/solv.c
index ec00a84..0beefcd 100644
--- a/examples/solv.c
+++ b/examples/solv.c
@@ -436,7 +436,7 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign
fclose(fp);
if (!cinfo->baseurl)
return 0;
- if (!chksumtype && mlchksumtype)
+ if (!chksumtype && mlchksumtype && !strcmp(file, "repodata/repomd.xml"))
{
chksumtype = mlchksumtype;
chksum = mlchksum;
@@ -454,6 +454,7 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign
snprintf(url, sizeof(url), "%s/%s", baseurl, file);
}
fd = opentmpfile();
+ // printf("url: %s\n", url);
if ((pid = fork()) == (pid_t)-1)
{
perror("fork");
@@ -807,7 +808,7 @@ writecachedrepo(Repo *repo, Repodata *info, const char *repoext, unsigned char *
{
/* main repo */
repo_empty(repo, 1);
- if (repo_add_solv(repo, fp))
+ if (repo_add_solv_flags(repo, fp, SOLV_ADD_NO_STUBS))
{
/* oops, no way to recover from here */
fprintf(stderr, "internal error\n");
@@ -1084,7 +1085,7 @@ load_stub(Pool *pool, Repodata *data, void *dp)
printf(" loading]\n"); fflush(stdout);
filename = repodata_lookup_str(data, SOLVID_META, REPOSITORY_REPOMD_LOCATION);
filechksumtype = 0;
- filechksum = repodata_lookup_bin_checksum(data, SOLVID_META, SUSETAGS_FILE_CHECKSUM, &filechksumtype);
+ filechksum = repodata_lookup_bin_checksum(data, SOLVID_META, REPOSITORY_REPOMD_CHECKSUM, &filechksumtype);
if ((fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, 0)) == 0)
return 0;
if (!strcmp(ext, "FL"))
@@ -1241,7 +1242,7 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
repodata_internalize(data);
if (!badchecksum)
writecachedrepo(repo, data, 0, cinfo->cookie);
- repodata_create_stubs(data);
+ repodata_create_stubs(repo_last_repodata(repo));
break;
case TYPE_SUSETAGS:
@@ -1310,7 +1311,7 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
repodata_internalize(data);
if (!badchecksum)
writecachedrepo(repo, data, 0, cinfo->cookie);
- repodata_create_stubs(data);
+ repodata_create_stubs(repo_last_repodata(repo));
break;
default:
printf("unsupported repo '%s': skipped\n", cinfo->alias);
diff --git a/src/repo_solv.c b/src/repo_solv.c
index 848eb93..c3f0792 100644
--- a/src/repo_solv.c
+++ b/src/repo_solv.c
@@ -1286,11 +1286,14 @@ printf("=> %s %s %p\n", id2str(pool, keys[key].name), id2str(pool, keys[key].typ
}
/* create stub repodata entries for all external */
- for (key = 1 ; key < data.nkeys; key++)
- if (data.keys[key].name == REPOSITORY_EXTERNAL && data.keys[key].type == REPOKEY_TYPE_FLEXARRAY)
- break;
- if (key < data.nkeys && !parent)
- repodata_create_stubs(&data);
+ if (!(flags & SOLV_ADD_NO_STUBS) && !parent)
+ {
+ for (key = 1 ; key < data.nkeys; key++)
+ if (data.keys[key].name == REPOSITORY_EXTERNAL && data.keys[key].type == REPOKEY_TYPE_FLEXARRAY)
+ break;
+ if (key < data.nkeys)
+ repodata_create_stubs(repo->repodata + (repo->nrepodata - 1));
+ }
POOL_DEBUG(SAT_DEBUG_STATS, "repo_add_solv took %d ms\n", sat_timems(now));
POOL_DEBUG(SAT_DEBUG_STATS, "repo size: %d solvables\n", repo->nsolvables);
diff --git a/src/repo_solv.h b/src/repo_solv.h
index e3e63a5..dc4eb10 100644
--- a/src/repo_solv.h
+++ b/src/repo_solv.h
@@ -25,6 +25,8 @@ extern "C" {
extern int repo_add_solv(Repo *repo, FILE *fp);
extern int repo_add_solv_flags(Repo *repo, FILE *fp, int flags);
+#define SOLV_ADD_NO_STUBS (1 << 8)
+
#ifdef __cplusplus
}
#endif
diff --git a/src/repodata.c b/src/repodata.c
index 6a3194a..dce3e02 100644
--- a/src/repodata.c
+++ b/src/repodata.c
@@ -2677,10 +2677,19 @@ repodata_create_stubs(Repodata *data)
Dataiterator di;
Id xkeyname = 0;
int i, cnt = 0;
+ int repodataid;
+ int datastart, dataend;
+ repodataid = data - repo->repodata;
+ datastart = data->start;
+ dataend = data->end;
dataiterator_init(&di, pool, repo, SOLVID_META, REPOSITORY_EXTERNAL, 0, 0);
while (dataiterator_step(&di))
- cnt++;
+ {
+ if (di.data - repo->repodata != repodataid)
+ continue;
+ cnt++;
+ }
dataiterator_free(&di);
if (!cnt)
return;
@@ -2688,11 +2697,8 @@ repodata_create_stubs(Repodata *data)
for (i = 0; i < cnt; i++)
{
sdata = repo_add_repodata(repo, 0);
- if (data->end > data->start)
- {
- repodata_extend(sdata, data->start);
- repodata_extend(sdata, data->end - 1);
- }
+ if (dataend > datastart)
+ repodata_extend_block(sdata, datastart, dataend - datastart);
stubdataids[i] = sdata - repo->repodata;
sdata->state = REPODATA_STUB;
sdata->loadcallback = repodata_load_stub;
@@ -2702,6 +2708,8 @@ repodata_create_stubs(Repodata *data)
sdata = 0;
while (dataiterator_step(&di))
{
+ if (di.data - repo->repodata != repodataid)
+ continue;
if (di.key->name == REPOSITORY_EXTERNAL && !di.nparents)
{
dataiterator_entersub(&di);
@@ -2729,7 +2737,7 @@ repodata_create_stubs(Repodata *data)
case REPOKEY_TYPE_MD5:
case REPOKEY_TYPE_SHA1:
case REPOKEY_TYPE_SHA256:
- repodata_set_checksum(sdata, SOLVID_META, di.key->name, di.key->type, di.kv.str);
+ repodata_set_bin_checksum(sdata, SOLVID_META, di.key->name, di.key->type, (const unsigned char *)di.kv.str);
break;
case REPOKEY_TYPE_IDARRAY:
repodata_add_idarray(sdata, SOLVID_META, di.key->name, di.kv.id);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org