From: Michael Schroeder Date: Tue, 4 Mar 2008 18:12:08 +0000 (+0000) Subject: - fix susetags2solv -b bugs X-Git-Tag: BASE-SuSE-Code-12_1-Branch~846 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1434adcdfefe5e03ae1b8b781b379bf4c2bd2d8;p=platform%2Fupstream%2Flibsolv.git - fix susetags2solv -b bugs - do not hardcode dir 1 --- diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c index ef62056..8a35775 100644 --- a/tools/repo_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -708,13 +708,16 @@ endElement(void *userData, const char *name) id = str2id(pool, pd->content, 1); s->provides = repo_addid_dep(repo, s->provides, id, SOLVABLE_FILEMARKER); #endif - if ((p = strrchr(pd->content, '/')) != 0) { - *p++ = 0; - id = repodata_str2dir(pd->data, pd->content, 1); - } else { - id = 1; - p = pd->content; - } + if ((p = strrchr(pd->content, '/')) != 0) + { + *p++ = 0; + id = repodata_str2dir(pd->data, pd->content, 1); + } + else + { + p = pd->content; + id = repodata_str2dir(pd->data, "/", 1); + } repodata_add_dirstr(pd->data, entry, SOLVABLE_FILELIST, id, p); break; // xml store capabilities diff --git a/tools/repo_susetags.c b/tools/repo_susetags.c index e80b3b2..fb2cb49 100644 --- a/tools/repo_susetags.c +++ b/tools/repo_susetags.c @@ -851,7 +851,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla } } if (n != repo->end) - repodata_merge_attrs (data, i, last_found); + repodata_merge_attrs(data, i, last_found); } free (pd.share_with); } diff --git a/tools/susetags2solv.c b/tools/susetags2solv.c index aa9e069..05c6832 100644 --- a/tools/susetags2solv.c +++ b/tools/susetags2solv.c @@ -150,6 +150,26 @@ main(int argc, char **argv) perror(descrdir); exit(1); } + + /* bring packages to front */ + for (i = 0; i < ndirs; i++) + { + char *fn = files[i]->d_name; + if (!strcmp(fn, "packages") || !strcmp(fn, "packages.gz")) + break; + } + if (i == ndirs) + { + fprintf(stderr, "found no packages file\n"); + exit(1); + } + if (i) + { + struct dirent *de = files[i]; + memmove(files + 1, files, i * sizeof(de)); + files[0] = de; + } + fnp = sat_malloc(strlen(descrdir) + 128); for (i = 0; i < ndirs; i++) { @@ -184,11 +204,11 @@ main(int argc, char **argv) char lang[6]; char *p; sprintf(fnp, "%s/%s", descrdir, fn); - p = strrchr(fn, '.'); + p = strrchr(fnp, '.'); if (p && !strcmp(p, ".gz")) { *p = 0; - p = strrchr(fn, '.'); + p = strrchr(fnp, '.'); } if (!p || !p[1] || strlen(p + 1) > 5) continue; @@ -204,6 +224,8 @@ main(int argc, char **argv) fclose(fp); } } + for (i = 0; i < ndirs; i++) + free(files[i]); free(files); free(fnp); }