summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/pool_fileconflicts.c1
-rw-r--r--ext/repo_appdata.c2
-rw-r--r--ext/repo_autopattern.c4
-rw-r--r--ext/repo_comps.c2
-rw-r--r--ext/repo_repomdxml.c2
-rw-r--r--ext/repo_rpmdb.c16
-rw-r--r--ext/solv_zchunk.c20
-rw-r--r--ext/testcase.c256
8 files changed, 165 insertions, 138 deletions
diff --git a/ext/pool_fileconflicts.c b/ext/pool_fileconflicts.c
index eaeb52b..2fd3d54 100644
--- a/ext/pool_fileconflicts.c
+++ b/ext/pool_fileconflicts.c
@@ -590,7 +590,6 @@ findfileconflicts_alias_cb(void *cbdatav, const char *fn, struct filelistinfo *i
if (!info->dirlen)
return;
- dp = fn + info->dirlen;
if (info->diridx != cbdata->lastdiridx)
{
cbdata->lastdiridx = info->diridx;
diff --git a/ext/repo_appdata.c b/ext/repo_appdata.c
index 3174968..b798af4 100644
--- a/ext/repo_appdata.c
+++ b/ext/repo_appdata.c
@@ -103,7 +103,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
{
struct parsedata *pd = xmlp->userdata;
Pool *pool = pd->pool;
- Solvable *s = pd->solvable;
+ Solvable *s;
const char *type;
/* ignore all language tags */
diff --git a/ext/repo_autopattern.c b/ext/repo_autopattern.c
index 4c09e79..bbc90cb 100644
--- a/ext/repo_autopattern.c
+++ b/ext/repo_autopattern.c
@@ -131,8 +131,8 @@ repo_add_autopattern(Repo *repo, int flags)
if (repo == pool->installed)
flags |= ADD_NO_AUTOPRODUCTS; /* no auto products for installed repos */
- pattern_id = pool_str2id(pool, "pattern()", 9);
- product_id = pool_str2id(pool, "product()", 9);
+ pattern_id = pool_str2id(pool, "pattern()", 1);
+ product_id = pool_str2id(pool, "product()", 1);
queue_init(&categorykeys);
FOR_REPO_SOLVABLES(repo, p, s)
diff --git a/ext/repo_comps.c b/ext/repo_comps.c
index 9400e1e..6991656 100644
--- a/ext/repo_comps.c
+++ b/ext/repo_comps.c
@@ -107,7 +107,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
{
struct parsedata *pd = xmlp->userdata;
Pool *pool = pd->pool;
- Solvable *s = pd->solvable;
+ Solvable *s;
switch(state)
{
diff --git a/ext/repo_repomdxml.c b/ext/repo_repomdxml.c
index fd46272..46d8361 100644
--- a/ext/repo_repomdxml.c
+++ b/ext/repo_repomdxml.c
@@ -181,7 +181,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
while (value)
{
char *p = strchr(value, ',');
- if (*p)
+ if (p)
*p++ = 0;
if (*value)
repodata_add_poolstr_array(pd->data, SOLVID_META, REPOSITORY_UPDATES, value);
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c
index 9acb400..326c5aa 100644
--- a/ext/repo_rpmdb.c
+++ b/ext/repo_rpmdb.c
@@ -1896,6 +1896,8 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (fread(lead, 96 + 16, 1, fp) != 1 || getu32(lead) != 0xedabeedb)
{
pool_error(pool, -1, "%s: not a rpm", rpm);
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1908,12 +1910,16 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (lead[78] != 0 || lead[79] != 5)
{
pool_error(pool, -1, "%s: not a rpm v5 header", rpm);
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
if (getu32(lead + 96) != 0x8eade801)
{
pool_error(pool, -1, "%s: bad signature header", rpm);
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1922,6 +1928,8 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (sigcnt >= MAX_SIG_CNT || sigdsize >= MAX_SIG_DSIZE)
{
pool_error(pool, -1, "%s: bad signature header", rpm);
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1932,6 +1940,8 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
{
if (!headfromfp(&state, rpm, fp, lead + 96, sigcnt, sigdsize, sigpad, chksumh, leadsigchksumh))
{
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1971,6 +1981,8 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (fread(lead, l, 1, fp) != 1)
{
pool_error(pool, -1, "%s: unexpected EOF", rpm);
+ solv_chksum_free(leadsigchksumh, 0);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1991,6 +2003,7 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (fread(lead, 16, 1, fp) != 1)
{
pool_error(pool, -1, "%s: unexpected EOF", rpm);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -1999,6 +2012,7 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (getu32(lead) != 0x8eade801)
{
pool_error(pool, -1, "%s: bad header", rpm);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -2007,6 +2021,7 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (sigcnt >= MAX_HDR_CNT || sigdsize >= MAX_HDR_DSIZE)
{
pool_error(pool, -1, "%s: bad header", rpm);
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
@@ -2014,6 +2029,7 @@ repo_add_rpm(Repo *repo, const char *rpm, int flags)
if (!headfromfp(&state, rpm, fp, lead, sigcnt, sigdsize, 0, chksumh, 0))
{
+ solv_chksum_free(chksumh, 0);
fclose(fp);
return 0;
}
diff --git a/ext/solv_zchunk.c b/ext/solv_zchunk.c
index 0833445..664b739 100644
--- a/ext/solv_zchunk.c
+++ b/ext/solv_zchunk.c
@@ -300,10 +300,28 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
#endif
if ((p = getuint(p, zck->hdr_end, &zck->flags)) == 0)
return open_error(zck);
- if ((zck->flags & ~(1)) != 0)
+ if ((zck->flags & ~(3)) != 0)
return open_error(zck);
if ((p = getuint(p, zck->hdr_end, &zck->comp)) == 0 || (zck->comp != 0 && zck->comp != 2))
return open_error(zck); /* only uncompressed + zstd supported */
+ /* skip all optional elements if present */
+ if ((zck->flags & 2) != 0)
+ {
+ unsigned int nopt, lopt;
+ if ((p = getuint(p, zck->hdr_end, &nopt)) == 0)
+ return open_error(zck);
+ for (; nopt != 0; nopt--)
+ {
+ if ((p = getuint(p, zck->hdr_end, &lopt)) == 0)
+ return open_error(zck);
+ if ((p = getuint(p, zck->hdr_end, &lopt)) == 0)
+ return open_error(zck);
+ if (p + lopt > zck->hdr_end)
+ return open_error(zck);
+ p += lopt;
+ }
+ }
+
preface_size = p - (zck->hdr + lead_size);
/* parse index: index size, index chksum type, num chunks, chunk data */
diff --git a/ext/testcase.c b/ext/testcase.c
index b815c56..dad6503 100644
--- a/ext/testcase.c
+++ b/ext/testcase.c
@@ -576,6 +576,8 @@ testcase_str2dep_complex(Pool *pool, const char **sp, int relop)
Id flags, id, id2, namespaceid = 0;
struct oplist *op;
+ if (!s)
+ return 0;
while (*s == ' ' || *s == '\t')
s++;
if (!strncmp(s, "namespace:", 10))
@@ -964,11 +966,101 @@ str2jobflags(Pool *pool, char *s) /* modifies the string */
return jobflags;
}
+static Id
+testcase_str2jobsel(Pool *pool, const char *caller, char **pieces, int npieces, Id *whatp)
+{
+ Id job, what;
+ if (!strcmp(pieces[0], "pkg") && npieces == 2)
+ {
+ job = SOLVER_SOLVABLE;
+ what = testcase_str2solvid(pool, pieces[1]);
+ if (!what)
+ return pool_error(pool, -1, "%s: unknown package '%s'", caller, pieces[1]);
+ }
+ else if (!strcmp(pieces[0], "name") || !strcmp(pieces[0], "provides"))
+ {
+ /* join em again for dep2str... */
+ char *sp;
+ for (sp = pieces[1]; sp < pieces[npieces - 1]; sp++)
+ if (*sp == 0)
+ *sp = ' ';
+ what = 0;
+ if (pieces[0][0] == 'p' && strncmp(pieces[1], "namespace:", 10) == 0)
+ {
+ char *spe = strchr(pieces[1], '(');
+ int l = strlen(pieces[1]);
+ if (spe && pieces[1][l - 1] == ')')
+ {
+ /* special namespace provides */
+ if (strcmp(spe, "(<NULL>)") != 0)
+ {
+ pieces[1][l - 1] = 0;
+ what = testcase_str2dep(pool, spe + 1);
+ pieces[1][l - 1] = ')';
+ }
+ what = pool_rel2id(pool, pool_strn2id(pool, pieces[1], spe - pieces[1], 1), what, REL_NAMESPACE, 1);
+ }
+ }
+ if (!what)
+ what = testcase_str2dep(pool, pieces[1]);
+ if (pieces[0][0] == 'n')
+ job = SOLVER_SOLVABLE_NAME;
+ else
+ job = SOLVER_SOLVABLE_PROVIDES;
+ }
+ else if (!strcmp(pieces[0], "oneof"))
+ {
+ Queue q;
+ job = SOLVER_SOLVABLE_ONE_OF;
+ queue_init(&q);
+ if (npieces > 1 && strcmp(pieces[1], "nothing") != 0)
+ {
+ int i;
+ for (i = 1; i < npieces; i++)
+ {
+ Id p = testcase_str2solvid(pool, pieces[i]);
+ if (!p)
+ {
+ queue_free(&q);
+ return pool_error(pool, -1, "%s: unknown package '%s'", caller, pieces[i]);
+ }
+ queue_push(&q, p);
+ }
+ }
+ what = pool_queuetowhatprovides(pool, &q);
+ queue_free(&q);
+ }
+ else if (!strcmp(pieces[0], "repo") && npieces == 2)
+ {
+ Repo *repo = testcase_str2repo(pool, pieces[1]);
+ if (!repo)
+ return pool_error(pool, -1, "%s: unknown repo '%s'", caller, pieces[1]);
+ job = SOLVER_SOLVABLE_REPO;
+ what = repo->repoid;
+ }
+ else if (!strcmp(pieces[0], "all") && npieces == 2 && !strcmp(pieces[1], "packages"))
+ {
+ job = SOLVER_SOLVABLE_ALL;
+ what = 0;
+ }
+ else
+ {
+ /* join em again for the error message... */
+ char *sp;
+ for (sp = pieces[0]; sp < pieces[npieces - 1]; sp++)
+ if (*sp == 0)
+ *sp = ' ';
+ return pool_error(pool, -1, "%s: bad line '%s'", caller, pieces[0]);
+ }
+ *whatp = what;
+ return job;
+}
+
Id
testcase_str2job(Pool *pool, const char *str, Id *whatp)
{
int i;
- Id job;
+ Id job, jobsel;
Id what;
char *s;
char **pieces = 0;
@@ -1020,116 +1112,12 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
job |= str2jobflags(pool, flags);
}
}
- if (!strcmp(pieces[1], "pkg"))
- {
- if (npieces != 3)
- {
- pool_error(pool, -1, "str2job: bad pkg selector in '%s'", str);
- solv_free(pieces);
- return -1;
- }
- job |= SOLVER_SOLVABLE;
- what = testcase_str2solvid(pool, pieces[2]);
- if (!what)
- {
- pool_error(pool, -1, "str2job: unknown package '%s'", pieces[2]);
- solv_free(pieces);
- return -1;
- }
- }
- else if (!strcmp(pieces[1], "name") || !strcmp(pieces[1], "provides"))
- {
- /* join em again for dep2str... */
- char *sp;
- for (sp = pieces[2]; sp < pieces[npieces - 1]; sp++)
- if (*sp == 0)
- *sp = ' ';
- what = 0;
- if (pieces[1][0] == 'p' && strncmp(pieces[2], "namespace:", 10) == 0)
- {
- char *spe = strchr(pieces[2], '(');
- int l = strlen(pieces[2]);
- if (spe && pieces[2][l - 1] == ')')
- {
- /* special namespace provides */
- if (strcmp(spe, "(<NULL>)") != 0)
- {
- pieces[2][l - 1] = 0;
- what = testcase_str2dep(pool, spe + 1);
- pieces[2][l - 1] = ')';
- }
- what = pool_rel2id(pool, pool_strn2id(pool, pieces[2], spe - pieces[2], 1), what, REL_NAMESPACE, 1);
- }
- }
- if (!what)
- what = testcase_str2dep(pool, pieces[2]);
- if (pieces[1][0] == 'n')
- job |= SOLVER_SOLVABLE_NAME;
- else
- job |= SOLVER_SOLVABLE_PROVIDES;
- }
- else if (!strcmp(pieces[1], "oneof"))
- {
- Queue q;
- job |= SOLVER_SOLVABLE_ONE_OF;
- queue_init(&q);
- if (npieces > 2 && strcmp(pieces[2], "nothing") != 0)
- {
- for (i = 2; i < npieces; i++)
- {
- Id p = testcase_str2solvid(pool, pieces[i]);
- if (!p)
- {
- pool_error(pool, -1, "str2job: unknown package '%s'", pieces[i]);
- queue_free(&q);
- solv_free(pieces);
- return -1;
- }
- queue_push(&q, p);
- }
- }
- what = pool_queuetowhatprovides(pool, &q);
- queue_free(&q);
- }
- else if (!strcmp(pieces[1], "repo"))
- {
- Repo *repo;
- if (npieces != 3)
- {
- pool_error(pool, -1, "str2job: bad line '%s'", str);
- solv_free(pieces);
- return -1;
- }
- repo = testcase_str2repo(pool, pieces[2]);
- if (!repo)
- {
- pool_error(pool, -1, "str2job: unknown repo '%s'", pieces[2]);
- solv_free(pieces);
- return -1;
- }
- job |= SOLVER_SOLVABLE_REPO;
- what = repo->repoid;
- }
- else if (!strcmp(pieces[1], "all"))
- {
- if (npieces != 3 && strcmp(pieces[2], "packages") != 0)
- {
- pool_error(pool, -1, "str2job: bad line '%s'", str);
- solv_free(pieces);
- return -1;
- }
- job |= SOLVER_SOLVABLE_ALL;
- what = 0;
- }
- else
- {
- pool_error(pool, -1, "str2job: unknown selection in '%s'", str);
- solv_free(pieces);
- return -1;
- }
- *whatp = what;
+ jobsel = testcase_str2jobsel(pool, "str2job", pieces + 1, npieces - 1, &what);
solv_free(pieces);
- return job;
+ if (jobsel == -1)
+ return -1;
+ *whatp = what;
+ return job | jobsel;
}
#define SELECTIONJOB_MATCHDEPS 1
@@ -1816,6 +1804,7 @@ static struct rclass2str {
{ SOLVER_RULE_LEARNT, "learnt" },
{ SOLVER_RULE_BEST, "best" },
{ SOLVER_RULE_YUMOBS, "yumobs" },
+ { SOLVER_RULE_RECOMMENDS, "recommends" },
{ 0, 0 }
};
@@ -2023,6 +2012,8 @@ testcase_solverresult(Solver *solv, int resultflags)
/* map choice rules back to pkg rules */
if (solver_ruleclass(solv, id) == SOLVER_RULE_CHOICE)
id = solver_rule2pkgrule(solv, id);
+ if (solver_ruleclass(solv, id) == SOLVER_RULE_RECOMMENDS)
+ id = solver_rule2pkgrule(solv, id);
solver_allruleinfos(solv, id, &rq);
for (i = 0; i < rq.count; i += 4)
{
@@ -2187,7 +2178,7 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
Id lowscore;
FILE *fp;
Strqueue sq;
- char *cmd, *out;
+ char *cmd, *out, *result;
const char *s;
if (!testcasename)
@@ -2322,7 +2313,6 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
if ((resultflags & ~TESTCASE_RESULT_REUSE_SOLVER) != 0)
{
- char *result;
cmd = 0;
for (i = 0; resultflags2str[i].str; i++)
if ((resultflags & resultflags2str[i].flag) != 0)
@@ -2333,7 +2323,6 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
result = testcase_solverresult(solv, resultflags);
if (!strcmp(resultname, "<inline>"))
{
- int i;
Strqueue rsq;
strqueue_init(&rsq);
strqueue_split(&rsq, result);
@@ -2365,6 +2354,7 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
if (fclose(fp))
{
pool_error(solv->pool, 0, "testcase_write: write error");
+ solv_free(result);
strqueue_free(&sq);
return 0;
}
@@ -2372,29 +2362,29 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
solv_free(result);
}
- cmd = strqueue_join(&sq);
+ result = strqueue_join(&sq);
+ strqueue_free(&sq);
out = pool_tmpjoin(pool, dir, "/", testcasename);
if (!(fp = fopen(out, "w")))
{
pool_error(solv->pool, 0, "testcase_write: could not open '%s' for writing", out);
- strqueue_free(&sq);
+ solv_free(result);
return 0;
}
- if (*cmd && fwrite(cmd, strlen(cmd), 1, fp) != 1)
+ if (*result && fwrite(result, strlen(result), 1, fp) != 1)
{
pool_error(solv->pool, 0, "testcase_write: write error");
- strqueue_free(&sq);
+ solv_free(result);
fclose(fp);
return 0;
}
if (fclose(fp))
{
pool_error(solv->pool, 0, "testcase_write: write error");
- strqueue_free(&sq);
+ solv_free(result);
return 0;
}
- solv_free(cmd);
- strqueue_free(&sq);
+ solv_free(result);
return 1;
}
@@ -2789,7 +2779,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
{
int i = strlen(pieces[1]);
s = strchr(pieces[1], '(');
- if (!s && pieces[1][i - 1] != ')')
+ if (!s || pieces[1][i - 1] != ')')
{
pool_error(pool, 0, "testcase_read: bad namespace '%s'", pieces[1]);
}
@@ -2877,12 +2867,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
}
else if (!strcmp(pieces[0], "disable") && npieces == 3)
{
- Id p;
- if (strcmp(pieces[1], "pkg"))
- {
- pool_error(pool, 0, "testcase_read: bad disable type '%s'", pieces[1]);
- continue;
- }
+ Id p, pp, jobsel, what = 0;
if (!prepared)
pool_createwhatprovides(pool);
prepared = -1;
@@ -2892,11 +2877,20 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
map_init(pool->considered, pool->nsolvables);
map_setall(pool->considered);
}
- p = testcase_str2solvid(pool, pieces[2]);
- if (p)
+ jobsel = testcase_str2jobsel(pool, "disable", pieces + 1, npieces - 1, &what);
+ if (jobsel < 0)
+ continue;
+ if (jobsel == SOLVER_SOLVABLE_ALL)
+ map_empty(pool->considered);
+ else if (jobsel == SOLVER_SOLVABLE_REPO)
+ {
+ Repo *repo = pool_id2repo(pool, what);
+ Solvable *s;
+ FOR_REPO_SOLVABLES(repo, p, s)
+ MAPCLR(pool->considered, p);
+ }
+ FOR_JOB_SELECT(p, pp, jobsel, what)
MAPCLR(pool->considered, p);
- else
- pool_error(pool, 0, "disable: unknown package '%s'", pieces[2]);
}
else if (!strcmp(pieces[0], "feature"))
{