struct repoinfo *cinfo;
const unsigned char *filechksum;
Id filechksumtype;
+ int r;
cinfo = repo->appdata;
repomdtype = repodata_lookup_str(data, SOLVID_META, REPOSITORY_REPOMD_TYPE);
if ((fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, 0)) == 0)
return 0;
if (!strcmp(ext, "FL"))
- repo_add_rpmmd(repo, fp, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
+ r = repo_add_rpmmd(repo, fp, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
else if (!strcmp(ext, "DL"))
- repo_add_deltainfoxml(repo, fp, REPO_USE_LOADING);
+ r = repo_add_deltainfoxml(repo, fp, REPO_USE_LOADING);
fclose(fp);
+ if (r)
+ {
+ printf("%s\n", pool_errstr(repo->pool));
+ return 0;
+ }
writecachedrepo(repo, data, ext, cinfo->extcookie);
return 1;
}
filechksum = repodata_lookup_bin_checksum(data, SOLVID_META, SUSETAGS_FILE_CHECKSUM, &filechksumtype);
if ((fp = curlfopen(cinfo, pool_tmpjoin(repo->pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, 0)) == 0)
return 0;
- repo_add_susetags(repo, fp, defvendor, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
+ if (repo_add_susetags(repo, fp, defvendor, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES))
+ {
+ fclose(fp);
+ printf("%s\n", pool_errstr(repo->pool));
+ return 0;
+ }
fclose(fp);
writecachedrepo(repo, data, ext, cinfo->extcookie);
return 1;
#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
# if defined(ENABLE_SUSEREPO) && defined(PRODUCTS_PATH)
- repo_add_products(repo, PRODUCTS_PATH, 0, REPO_NO_INTERNALIZE);
+ if (repo_add_products(repo, PRODUCTS_PATH, 0, REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "product reading failed: %s\n", pool_errstr(pool));
+ exit(1);
+ }
# endif
if ((ofp = fopen(calccachepath(repo, 0), "r")) != 0)
{
Repo *ref = repo_create(pool, "@System.old");
if (!repo_add_solv(ref, ofp, 0))
{
- repo_add_rpmdb(repo, ref, 0, REPO_REUSE_REPODATA);
+ if (repo_add_rpmdb(repo, ref, 0, REPO_REUSE_REPODATA))
+ {
+ fprintf(stderr, "installed db: %s\n", pool_errstr(pool));
+ exit(1);
+ }
done = 1;
}
fclose(ofp);
repo_free(ref, 1);
}
if (!done)
- repo_add_rpmdb(repo, 0, 0, REPO_REUSE_REPODATA);
+ {
+ if (repo_add_rpmdb(repo, 0, 0, REPO_REUSE_REPODATA))
+ {
+ fprintf(stderr, "installed db: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ }
#endif
#if defined(ENABLE_DEBIAN) && defined(DEBIAN)
- repo_add_debdb(repo, 0, REPO_REUSE_REPODATA);
+ if (repo_add_debdb(repo, 0, REPO_REUSE_REPODATA))
+ {
+ fprintf(stderr, "installed db: %s\n", pool_errstr(pool));
+ exit(1);
+ }
#endif
writecachedrepo(repo, 0, 0, installedcookie);
}
}
fclose(sigfp);
}
- repo_add_repomdxml(repo, fp, 0);
+ if (repo_add_repomdxml(repo, fp, 0))
+ {
+ printf("repomd.xml: %s\n", pool_errstr(pool));
+ fclose(fp);
+ break; /* hopeless */
+ }
fclose(fp);
printf(" fetching\n");
filename = repomd_find(repo, "primary", &filechksum, &filechksumtype);
if (filename && (fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
{
- repo_add_rpmmd(repo, fp, 0, 0);
+ if (repo_add_rpmmd(repo, fp, 0, 0))
+ {
+ printf("primary: %s\n", pool_errstr(pool));
+ badchecksum = 1;
+ }
fclose(fp);
}
if (badchecksum)
filename = repomd_find(repo, "updateinfo", &filechksum, &filechksumtype);
if (filename && (fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
{
- repo_add_updateinfoxml(repo, fp, 0);
+ if (repo_add_updateinfoxml(repo, fp, 0))
+ {
+ printf("updateinfo: %s\n", pool_errstr(pool));
+ badchecksum = 1;
+ }
fclose(fp);
}
fclose(sigfp);
}
}
- repo_add_content(repo, fp, 0);
+ if (repo_add_content(repo, fp, 0))
+ {
+ printf("content: %s\n", pool_errstr(pool));
+ fclose(fp);
+ break; /* hopeless */
+ }
fclose(fp);
defvendor = repo_lookup_id(repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR);
descrdir = repo_lookup_str(repo, SOLVID_META, SUSETAGS_DESCRDIR);
printf(" fetching\n");
if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, &badchecksum)) == 0)
break; /* hopeless */
- repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE|SUSETAGS_RECORD_SHARES);
+ if (repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE|SUSETAGS_RECORD_SHARES))
+ {
+ printf("packages: %s\n", pool_errstr(pool));
+ fclose(fp);
+ break; /* hopeless */
+ }
fclose(fp);
/* add default language */
filename = susetags_find(repo, "packages.en.gz", &filechksum, &filechksumtype);
{
if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
{
- repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE|REPO_REUSE_REPODATA|REPO_EXTEND_SOLVABLES);
+ if (repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE|REPO_REUSE_REPODATA|REPO_EXTEND_SOLVABLES))
+ {
+ printf("packages.en: %s\n", pool_errstr(pool));
+ badchecksum = 1;
+ }
fclose(fp);
}
}
filename = susetags_find(repo, pbuf, &filechksum, &filechksumtype);
if (filename && (fp2 = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
{
- repo_add_susetags(repo, fp2, defvendor, 0, REPO_NO_INTERNALIZE);
+ if (repo_add_susetags(repo, fp2, defvendor, 0, REPO_NO_INTERNALIZE))
+ {
+ printf("%s: %s\n", pbuf, pool_errstr(pool));
+ badchecksum = 1;
+ }
fclose(fp2);
}
}
}
if ((fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
{
- repo_add_debpackages(repo, fp, 0);
+ if (repo_add_debpackages(repo, fp, 0))
+ {
+ printf("component %s: %s\n", cinfo->components[j], pool_errstr(pool));
+ badchecksum = 1;
+ }
fclose(fp);
}
solv_free((char *)filechksum);
#include <string.h>
#include <unistd.h>
#include <zlib.h>
+#include <errno.h>
#include "pool.h"
#include "repo.h"
if (rootdir)
path = pool_tmpjoin(repo->pool, rootdir, path, 0);
if ((fp = fopen(path, "r")) == 0)
- {
- perror(path);
- exit(1);
- }
+ return pool_error(repo->pool, -1, "%s: %s", path, strerror(errno));
repo_add_debpackages(repo, fp, flags);
fclose(fp);
return 0;
};
struct parsedata {
+ int ret;
int depth;
enum state state;
int statedepth;
{
#if 0
fprintf(stderr, "into unknown: [%d]%s (from: %d)\n", sw->to, name, sw->from);
- exit( 1 );
#endif
return;
}
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pool, SOLV_FATAL, "repo_updateinfoxml: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- exit(1);
+ pd.ret = pool_error(pool, -1, "repo_updateinfoxml: %s at line %u:%u", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ break;
}
if (l == 0)
break;
solv_free(pd.content);
/* now commit all handles */
- for (i = 0; i < pd.nhandles; i++)
- repodata_add_flexarray(pd.data, SOLVID_META, REPOSITORY_DELTAINFO, pd.handles[i]);
+ if (!pd.ret)
+ for (i = 0; i < pd.nhandles; i++)
+ repodata_add_flexarray(pd.data, SOLVID_META, REPOSITORY_DELTAINFO, pd.handles[i]);
solv_free(pd.handles);
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
- return 0;
+ return pd.ret;
}
/* EOF */
*/
typedef struct _parsedata {
+ int ret;
/* XML parser data */
int depth;
enum state state; /* current state */
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pool, SOLV_FATAL, "%s at line %u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser));
- exit(1);
+ pd.ret = pool_error(pool, -1, "%s at line %u", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser));
+ break;
}
if (l == 0)
break;
POOL_DEBUG(SOLV_DEBUG_STATS, "repo_add_helix took %d ms\n", solv_timems(now));
POOL_DEBUG(SOLV_DEBUG_STATS, "repo size: %d solvables\n", repo->nsolvables);
POOL_DEBUG(SOLV_DEBUG_STATS, "repo memory used: %d K incore, %d K idarray\n", repodata_memused(data)/1024, repo->idarraysize / (int)(1024/sizeof(Id)));
- return 0;
+ return pd.ret;
}
struct parsedata {
+ int ret;
int depth;
enum state state;
int statedepth;
const char *type= find_attr("type", atts);
pd->chksumtype = type && *type ? solv_chksum_str2type(type) : 0;
if (!pd->chksumtype)
- {
- fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), type ? type : "NULL");
- exit(1);
- }
+ pd->ret = pool_error(pd->pool, -1, "line %d: unknown checksum type: %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), type ? type : "NULL");
break;
}
default:
case STATE_CHECKSUM:
case STATE_OPENCHECKSUM:
+ if (!pd->chksumtype)
+ break;
if (strlen(pd->content) != 2 * solv_chksum_len(pd->chksumtype))
- {
- fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
- exit(1);
- }
- repodata_set_checksum(pd->data, pd->rdhandle, pd->state == STATE_CHECKSUM ? REPOSITORY_REPOMD_CHECKSUM : REPOSITORY_REPOMD_OPENCHECKSUM, pd->chksumtype, pd->content);
+ pd->ret = pool_error(pd->pool, -1, "line %d: invalid checksum length for %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
+ else
+ repodata_set_checksum(pd->data, pd->rdhandle, pd->state == STATE_CHECKSUM ? REPOSITORY_REPOMD_CHECKSUM : REPOSITORY_REPOMD_OPENCHECKSUM, pd->chksumtype, pd->content);
break;
case STATE_TIMESTAMP:
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pool, SOLV_FATAL, "repo_repomdxml: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- exit(1);
+ pd.ret = pool_error(pool, -1, "repo_repomdxml: %s at line %u:%u", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ break;
}
if (l == 0)
break;
repodata_internalize(data);
free(pd.content);
- return 0;
+ return pd.ret;
}
/* EOF */
#include <unistd.h>
#include <assert.h>
#include <stdint.h>
+#include <errno.h>
#include <rpm/rpmio.h>
#include <rpm/rpmpgp.h>
if (!version || !release)
{
fprintf(stderr, "headtoevr: bad rpm header\n");
- exit(1);
+ return 0;
}
for (v = version; *v >= '0' && *v <= '9'; v++)
;
if (nc != vc || nc != fc)
{
fprintf(stderr, "bad dependency entries\n");
- exit(1);
+ return 0;
}
cc = nc;
if (bnc != dic)
{
fprintf(stderr, "bad filelist\n");
- exit(1);
+ return olddeps;
}
if (data)
if (!s->name)
{
fprintf(stderr, "package has no name\n");
- exit(1);
+ return 0;
}
sourcerpm = headstring(rpmhead, TAG_SOURCERPM);
if (sourcerpm)
if (db_create(&db, dbenv, 0))
{
perror("db_create");
- exit(1);
+ return 0;
}
if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
perror("db->open Name index");
- exit(1);
+ return 0;
}
if (db->cursor(db, NULL, &dbc, 0))
{
perror("db->cursor");
- exit(1);
+ return 0;
}
while (dbc->c_get(dbc, &dbkey, &dbdata, DB_NEXT) == 0)
count += dbdata.size / RPM_INDEX_SIZE;
ref = 0;
if (!(dbenv = opendbenv(rootdir)))
- exit(1);
+ {
+ return pool_error(pool, -1, "repo_add_rpmdb: opendbenv failed");
+ }
/* XXX: should get ro lock of Packages database! */
snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", rootdir);
if (stat(dbpath, &packagesstat))
{
- perror(dbpath);
- exit(1);
+ return pool_error(pool, -1, "repo_add_rpmdb: %s: %s", dbpath, strerror(errno));
}
mkrpmdbcookie(&packagesstat, newcookie);
repodata_set_bin_checksum(data, SOLVID_META, REPOSITORY_RPMDBCOOKIE, REPOKEY_TYPE_SHA256, newcookie);
count = count_headers(rootdir, dbenv);
if (db_create(&db, dbenv, 0))
{
- perror("db_create");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db_create: %s", strerror(errno));
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->open(db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open Packages index");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db->open Packages index failed: %s", strerror(errno));
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->get_byteswapped(db, &byteswapped))
{
- perror("db->get_byteswapped");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "repo_add_rpmdb: db->get_byteswapped failed");
}
if (db->cursor(db, NULL, &dbc, 0))
{
- perror("db->cursor");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "repo_add_rpmdb: db->cursor failed");
}
rpmheadsize = 0;
rpmhead = 0;
repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
if (dbkey.size != 4)
{
- fprintf(stderr, "corrupt Packages database (key size)\n");
- exit(1);
+ dbc->c_close(dbc);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "corrupt Packages database (key size)");
}
dbid = db2rpmdbid(dbkey.data, byteswapped);
if (dbid == 0) /* the join key */
continue;
if (dbdata.size < 8)
{
- fprintf(stderr, "corrupt rpm database (size %u)\n", dbdata.size);
- exit(1);
+ dbc->c_close(dbc);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "corrupt rpm database (size %u)\n", dbdata.size);
}
if (dbdata.size > rpmheadsize)
{
rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
if (8 + rpmhead->cnt * 16 + rpmhead->dcnt > dbdata.size)
{
- fprintf(stderr, "corrupt rpm database (data size)\n");
- exit(1);
+ dbc->c_close(dbc);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "corrupt rpm database (data size)\n");
}
memcpy(rpmhead->data, (unsigned char *)dbdata.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt);
rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
memset(dircache, 0, sizeof(dircache));
if (db_create(&db, dbenv, 0))
{
- perror("db_create");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db_create: %s", strerror(errno));
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open Name index");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db->open Name index failed: %s", strerror(errno));
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->get_byteswapped(db, &byteswapped))
{
- perror("db->get_byteswapped");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "repo_add_rpmdb: db->get_byteswapped failed");
}
if (db->cursor(db, NULL, &dbc, 0))
{
- perror("db->cursor");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "repo_add_rpmdb: db->cursor failed");
}
nrpmids = 0;
rpmids = 0;
{
if (db_create(&db, dbenv, 0))
{
- perror("db_create");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db_create: %s", strerror(errno));
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->open(db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open var/lib/rpm/Packages");
- exit(1);
+ pool_error(pool, -1, "repo_add_rpmdb: db->open Packages index failed: %s", strerror(errno));
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return -1;
}
if (db->get_byteswapped(db, &byteswapped))
{
- perror("db->get_byteswapped");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "repo_add_rpmdb: db->get_byteswapped failed");
}
}
rpmdbid2db(buf, rp->dbid, byteswapped);
dbdata.size = 0;
if (db->get(db, NULL, &dbkey, &dbdata, 0))
{
- perror("db->get");
- fprintf(stderr, "corrupt rpm database, key %d not found\n", dbid);
- fprintf(stderr, "please run 'rpm --rebuilddb' to recreate the database index files\n");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "inconsistent rpm database, key %d not found. run 'rpm --rebuilddb' to fix.", dbid);
}
if (dbdata.size < 8)
{
- fprintf(stderr, "corrupt rpm database (size)\n");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "corrupt Packages database (size)");
}
if (dbdata.size > rpmheadsize)
{
rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
if (8 + rpmhead->cnt * 16 + rpmhead->dcnt > dbdata.size)
{
- fprintf(stderr, "corrupt rpm database (data size)\n");
- exit(1);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return pool_error(pool, -1, "corrupt Packages database (data size)");
}
memcpy(rpmhead->data, (unsigned char *)dbdata.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt);
rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
if (!arch)
arch = "noarch";
evr = headtoevr(rpmhead);
+ if (!evr)
+ break;
l = strlen(name) + 1 + strlen(evr) + 1 + strlen(arch) + 1;
r = solv_malloc(l);
sprintf(r, "%s-%s.%s", name, evr, arch);
#define CSREALLOC_STEP 1024
struct parsedata {
+ int ret;
Pool *pool;
Repo *repo;
Repodata *data;
pd->statedepth = pd->depth;
pd->lcontent = 0;
*pd->content = 0;
+
+ if (!s && pd->state != STATE_SOLVABLE)
+ return;
+
switch(pd->state)
{
case STATE_SOLVABLE:
Id index = stringpool_str2id(&pd->cspool, pkgid, 0);
if (!index || index >= pd->ncscache || !pd->cscache[index])
{
- fprintf(stderr, "error, the repository specifies extra information about package with checksum '%s', which does not exist in the repository.\n", pkgid);
- exit(1);
+ pool_debug(pool, SOLV_WARN, "the repository specifies extra information about package with checksum '%s', which does not exist in the repository.\n", pkgid);
+ pd->solvable = 0;
+ pd->handle = 0;
+ break;
}
pd->solvable = pool_id2solvable(pool, pd->cscache[index]);
}
const char *tmp = find_attr("type", atts);
pd->chksumtype = tmp && *tmp ? solv_chksum_str2type(tmp) : 0;
if (!pd->chksumtype)
- {
- fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), tmp ? tmp: "NULL");
- exit(1);
- }
+ pd->ret = pool_error(pool, -1, "line %d: unknown checksum type: %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), tmp ? tmp: "NULL");
+ break;
}
- break;
case STATE_TIME:
{
unsigned int t;
str = find_attr("end", atts);
if (str && (end = atoi(str)) != 0)
repodata_set_num(pd->data, handle, SOLVABLE_HEADEREND, end);
+ break;
}
/*
<diskusage>
*/
case STATE_DISKUSAGE:
{
- /* Really, do nothing, wat for <dir> tag */
+ /* Really, do nothing, wait for <dir> tag */
break;
}
case STATE_DIR:
dirid = repodata_str2dir(pd->data, str, 1);
else
{
- fprintf( stderr, "<dir .../> tag without 'name' attribute, atts = %p, *atts = %p\n",
- (void *)atts, *atts);
+ pd->ret = pool_error(pool, -1, "<dir .../> tag without 'name' attribute");
break;
}
if ((str = find_attr("size", atts)) != 0)
pd->depth--;
pd->statedepth--;
+
+
+ if (!s)
+ {
+ pd->state = pd->sbtab[pd->state];
+ pd->docontent = 0;
+ return;
+ }
+
switch (pd->state)
{
case STATE_SOLVABLE:
s->conflicts = repo_fix_conflicts(repo, s->conflicts);
pd->freshens = 0;
pd->kind = 0;
+ pd->solvable = s = 0;
break;
case STATE_NAME:
if (pd->kind)
{
Id index;
+ if (!pd->chksumtype)
+ break;
if (strlen(pd->content) != 2 * solv_chksum_len(pd->chksumtype))
{
- fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
- exit(1);
+ pd->ret = pool_error(pool, -1, "line %d: invalid checksum length for %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
+ break;
}
repodata_set_checksum(pd->data, handle, SOLVABLE_CHECKSUM, pd->chksumtype, pd->content);
/* we save the checksum to solvable id relationship for extended
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pool, SOLV_FATAL, "repo_rpmmd: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- exit(1);
+ pd.ret = pool_error(pool, -1, "repo_rpmmd: %s at line %u:%u", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ break;
}
if (l == 0)
break;
POOL_DEBUG(SOLV_DEBUG_STATS, "repo_add_rpmmd took %d ms\n", solv_timems(now));
POOL_DEBUG(SOLV_DEBUG_STATS, "repo size: %d solvables\n", repo->nsolvables);
POOL_DEBUG(SOLV_DEBUG_STATS, "repo memory used: %d K incore, %d K idarray\n", repodata_memused(data)/1024, repo->idarraysize / (int)(1024/sizeof(Id)));
- return 0;
+ return pd.ret;
}
};
struct parsedata {
+ int ret;
Pool *pool;
Repo *repo;
Repodata *data;
i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad dependency line: %d: %s\n", pd->lineno, line);
- exit(1);
+ pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
+ return olddeps;
}
if (kind)
id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
flags = 4;
else
{
- pool_debug(pool, SOLV_FATAL, "susetags: unknown relation in %d: '%s'\n", pd->lineno, sp[1]);
- exit(1);
+ pd->ret = pool_error(pool, -1, "susetags: line %d: unknown relation: '%s'\n", pd->lineno, sp[1]);
+ return olddeps;
}
}
id = pool_rel2id(pool, id, evrid, flags + 1, 1);
if (split(line, sp, 5) != 4)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad source line: %d: %s\n", pd->lineno, line);
- exit(1);
+ pd->ret = pool_error(pool, -1, "susetags: line %d: bad source line '%s'\n", pd->lineno, line);
+ return;
}
name = pool_str2id(pool, sp[0], 1);
Id type;
if (split(line, sp, 3) != 2)
{
- pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum line: %d: %s\n", pd->lineno, line);
- exit(1);
+ pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum line '%s'\n", pd->lineno, line);
+ return;
}
type = solv_chksum_str2type(sp[0]);
if (!type)
{
- pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
- exit(1);
+ pd->ret = pool_error(pd->pool, -1, "susetags: line %d: unknown checksum type: '%s'\n", pd->lineno, sp[0]);
+ return;
}
if (strlen(sp[1]) != 2 * solv_chksum_len(type))
{
- pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
- exit(1);
+ pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum length for type %s: '%s'\n", pd->lineno, sp[0], sp[1]);
+ return;
}
repodata_set_checksum(data, handle, keyname, type, sp[1]);
}
char *olinep; /* old line pointer */
char line_lang[6];
int keylen = 3;
+
+ if (pd.ret)
+ break;
if (linep - line + 16 > aline) /* (re-)alloc buffer */
{
aline = linep - line;
char *tagend = strchr(line, ':');
if (!tagend)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
+ break;
}
intag = tagend - (line + 1);
cummulate = 0;
int i = split(line + 6, sp, 3);
if (i != 2 && i != 3)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
+ continue;
}
set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
continue;
pd.kind = 0;
if (split(line + 5, sp, 5) != 4)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
+ break;
}
handle = repodata_new_handle(data);
repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
if (split(line + 5, sp, 5) != 4)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
+ break;
}
s = 0;
freshens = 0;
int i = split(line + 6, sp, 3);
if (i != 2 && i != 3)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
+ continue;
}
repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
}
Id name, evr, arch;
if (split(line + 6, sp, 5) != 4)
{
- pool_debug(pool, SOLV_FATAL, "susetags: bad =Shr line: %s\n", line + 6);
- exit(1);
+ pd.ret = pool_error(pool, -1, "susetags: line %d: bad =Shr line '%s'\n", pd.lineno, line);
+ continue;
}
name = pool_str2id(pool, sp[0], 1);
evr = toevr(pool, &pd, sp[1], sp[2]);
break;
default:
- pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
+ pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
break;
}
solv_free(pd.language);
solv_free(line);
join_freemem(&pd.jd);
- return 0;
+ return pd.ret;
}
};
struct parsedata {
+ int ret;
int depth;
enum state state;
int statedepth;
{
#if 0
fprintf(stderr, "into unknown: %s (from: %d)\n", name, pd->state);
- exit( 1 );
#endif
return;
}
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pool, SOLV_FATAL, "repo_updateinfoxml: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- exit(1);
+ pd.ret = pool_error(pool, -1, "repo_updateinfoxml: %s at line %u:%u", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ break;
}
if (l == 0)
break;
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
- return 0;
+ return pd.ret;
}
pool_createwhatprovides;
pool_debug;
pool_dep2str;
+ pool_error;
+ pool_errstr;
pool_evrcmp;
pool_evrcmp_str;
pool_evrmatch;
free((char *)pool->languages[i]);
solv_free(pool->languages);
solv_free(pool->languagecache);
+ solv_free(pool->errstr);
solv_free(pool);
}
return;
}
vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
}
+int
+pool_error(Pool *pool, int ret, const char *format, ...)
+{
+ va_list args;
+ int l;
+ va_start(args, format);
+ if (!pool->errstr)
+ {
+ pool->errstra = 1024;
+ pool->errstr = solv_malloc(pool->errstra);
+ }
+ if (!*format)
+ {
+ *pool->errstr = 0;
+ l = 0;
+ }
+ else
+ l = vsnprintf(pool->errstr, pool->errstra, format, args);
+ va_end(args);
+ if (l >= 0 && l + 1 > pool->errstra)
+ {
+ pool->errstra = l + 256;
+ pool->errstr = solv_realloc(pool->errstr, pool->errstra);
+ va_start(args, format);
+ l = vsnprintf(pool->errstr, pool->errstra, format, args);
+ va_end(args);
+ }
+ if (l < 0)
+ strcpy(pool->errstr, "unknown error");
+ if (pool->debugmask & SOLV_ERROR)
+ pool_debug(pool, SOLV_ERROR, "%s\n", pool->errstr);
+ return ret;
+}
+
+char *
+pool_errstr(Pool *pool)
+{
+ return pool->errstr ? pool->errstr : "no error";
+}
+
void
pool_setdebuglevel(Pool *pool, int level)
{
int mask = SOLV_DEBUG_RESULT;
if (level > 0)
- mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION;
+ mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION|SOLV_ERROR;
if (level > 1)
mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
if (level > 2)
/* our tmp space string space */
struct _Pool_tmpspace tmpspace;
+
+ char *errstr; /* last error string */
+ int errstra; /* allocated space for errstr */
#endif
};
extern void pool_set_installed(Pool *pool, struct _Repo *repo);
+extern int pool_error(Pool *pool, int ret, const char *format, ...) __attribute__((format(printf, 3, 4)));
+extern char *pool_errstr(Pool *pool);
+
/**
* Solvable management
*/
c = getc(data->fp);
if (c == EOF)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "unexpected EOF\n");
- data->error = SOLV_ERROR_EOF;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
return 0;
}
x = (x << 8) | c;
c = getc(data->fp);
if (c == EOF)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "unexpected EOF\n");
- data->error = SOLV_ERROR_EOF;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
return 0;
}
return c;
c = getc(data->fp);
if (c == EOF)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "unexpected EOF\n");
- data->error = SOLV_ERROR_EOF;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
return 0;
}
if (!(c & 128))
x = (x << 7) | c;
if (max && x >= max)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "read_id: id too large (%u/%u)\n", x, max);
- data->error = SOLV_ERROR_ID_RANGE;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_id: id too large (%u/%u)", x, max);
return 0;
}
return x;
}
x = (x << 7) ^ c ^ 128;
}
- pool_debug(data->repo->pool, SOLV_ERROR, "read_id: id too long\n");
- data->error = SOLV_ERROR_CORRUPT;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_CORRUPT, "read_id: id too long");
return 0;
}
c = getc(data->fp);
if (c == EOF)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "unexpected EOF\n");
- data->error = SOLV_ERROR_EOF;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
return 0;
}
if ((c & 128) != 0)
x = (x << 6) | (c & 63);
if (max && x >= max)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "read_idarray: id too large (%u/%u)\n", x, max);
- data->error = SOLV_ERROR_ID_RANGE;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_idarray: id too large (%u/%u)", x, max);
return 0;
}
if (map)
x = map[x];
if (store == end)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "read_idarray: array overflow\n");
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_OVERFLOW, "read_idarray: array overflow");
return 0;
}
*store++ = x;
return store;
if (store == end)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "read_idarray: array overflow\n");
- data->error = SOLV_ERROR_OVERFLOW;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_OVERFLOW, "read_idarray: array overflow");
return 0;
}
*store++ = 0;
dp = data_read_id(dp, &x);
if (x < 0 || (max && x >= max))
{
- pool_debug(data->repo->pool, SOLV_ERROR, "data_read_id_max: id too large (%u/%u)\n", x, max);
- data->error = SOLV_ERROR_ID_RANGE;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_id_max: id too large (%u/%u)", x, max);
x = 0;
}
*ret = map ? map[x] : x;
x = (x << 6) | (c & 63);
if (max && x >= max)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "data_read_idarray: id too large (%u/%u)\n", x, max);
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_idarray: id too large (%u/%u)", x, max);
data->error = SOLV_ERROR_ID_RANGE;
break;
}
old = x;
if (max && x >= max)
{
- pool_debug(data->repo->pool, SOLV_ERROR, "data_read_rel_idarray: id too large (%u/%u)\n", x, max);
- data->error = SOLV_ERROR_ID_RANGE;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_rel_idarray: id too large (%u/%u)", x, max);
break;
}
*store++ = map ? map[x] : x;
dp = data_read_ideof(dp, &id, &eof);
if (id < 0 || (max && id >= max))
{
- pool_debug(data->repo->pool, SOLV_ERROR, "incore_map_idarray: id too large (%u/%u)\n", id, max);
- data->error = SOLV_ERROR_ID_RANGE;
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "incore_map_idarray: id too large (%u/%u)", id, max);
break;
}
id = map[id];
repopagestore_init(&data.store);
if (read_u32(&data) != ('S' << 24 | 'O' << 16 | 'L' << 8 | 'V'))
- {
- pool_debug(pool, SOLV_ERROR, "not a SOLV file\n");
- return SOLV_ERROR_NOT_SOLV;
- }
+ return pool_error(pool, SOLV_ERROR_NOT_SOLV, "not a SOLV file");
solvversion = read_u32(&data);
switch (solvversion)
{
case SOLV_VERSION_8:
break;
default:
- pool_debug(pool, SOLV_ERROR, "unsupported SOLV version\n");
- return SOLV_ERROR_UNSUPPORTED;
+ return pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported SOLV version");
}
numid = read_u32(&data);
solvflags = read_u32(&data);
if (numdir && numdir < 2)
- {
- pool_debug(pool, SOLV_ERROR, "bad number of dirs\n");
- return SOLV_ERROR_CORRUPT;
- }
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of dirs");
if (numrel && (flags & REPO_LOCALPOOL) != 0)
- {
- pool_debug(pool, SOLV_ERROR, "relations are forbidden in a local pool\n");
- return SOLV_ERROR_CORRUPT;
- }
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "relations are forbidden in a local pool");
if ((flags & REPO_EXTEND_SOLVABLES) && numsolv)
{
/* make sure that we exactly replace the stub repodata */
if (extendend - extendstart != numsolv)
- {
- pool_debug(pool, SOLV_ERROR, "sub-repository solvable number does not match main repository (%d - %d)\n", extendend - extendstart, numsolv);
- return SOLV_ERROR_CORRUPT;
- }
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "sub-repository solvable number does not match main repository (%d - %d)", extendend - extendstart, numsolv);
for (i = 0; i < numsolv; i++)
if (pool->solvables[extendstart + i].repo != repo)
- {
- pool_debug(pool, SOLV_ERROR, "main repository contains holes, cannot extend\n");
- return SOLV_ERROR_CORRUPT;
- }
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "main repository contains holes, cannot extend");
}
/******* Part 1: string IDs *****************************************/
if ((solvflags & SOLV_FLAG_PREFIX_POOL) == 0)
{
if (sizeid && fread(strsp, sizeid, 1, fp) != 1)
- {
- pool_debug(pool, SOLV_ERROR, "read error while reading strings\n");
- return SOLV_ERROR_EOF;
- }
+ return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
}
else
{
if (pfsize && fread(prefix, pfsize, 1, fp) != 1)
{
- pool_debug(pool, SOLV_ERROR, "read error while reading strings\n");
solv_free(prefix);
- return SOLV_ERROR_EOF;
+ return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
}
for (i = 1; i < numid; i++)
{
freesp -= same + len;
if (freesp < 0)
{
- pool_debug(pool, SOLV_ERROR, "overflow while expanding strings\n");
solv_free(prefix);
- return SOLV_ERROR_OVERFLOW;
+ return pool_error(pool, SOLV_ERROR_OVERFLOW, "overflow while expanding strings");
}
if (same)
memcpy(dest, old_str, same);
}
solv_free(prefix);
if (freesp != 0)
- {
- pool_debug(pool, SOLV_ERROR, "expanding strings size mismatch\n");
- return SOLV_ERROR_CORRUPT;
- }
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "expanding strings size mismatch");
}
strsp[sizeid] = 0; /* make string space \0 terminated */
sp = strsp;
if (*sp)
{
/* we need the '' for directories */
- pool_debug(pool, SOLV_ERROR, "store strings don't start with ''\n");
- return SOLV_ERROR_CORRUPT;
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "store strings don't start with an empty string");
}
for (i = 1; i < spool->nstrings; i++)
{
if (sp >= strsp + sizeid)
- {
- pool_debug(pool, SOLV_ERROR, "not enough strings\n");
- return SOLV_ERROR_OVERFLOW;
- }
+ return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings");
str[i] = sp - spool->stringspace;
sp += strlen(sp) + 1;
}
{
solv_free(hashtbl);
solv_free(idmap);
- pool_debug(pool, SOLV_ERROR, "not enough strings %d %d\n", i, numid);
- return SOLV_ERROR_OVERFLOW;
+ return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings %d %d", i, numid);
}
if (!*sp) /* empty string */
{
type = pool_str2id(pool, stringpool_id2str(spool, type), 1);
if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_FLEXARRAY)
{
- pool_debug(pool, SOLV_ERROR, "unsupported data type '%s'\n", pool_id2str(pool, type));
- data.error = SOLV_ERROR_UNSUPPORTED;
+ data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported data type '%s'", pool_id2str(pool, type));
type = REPOKEY_TYPE_VOID;
}
keys[i].name = id;
if (keys[i].storage == KEY_STORAGE_SOLVABLE)
keys[i].storage = KEY_STORAGE_INCORE;
if (keys[i].storage != KEY_STORAGE_INCORE && keys[i].storage != KEY_STORAGE_VERTICAL_OFFSET)
- {
- pool_debug(pool, SOLV_ERROR, "unsupported storage type %d\n", keys[i].storage);
- data.error = SOLV_ERROR_UNSUPPORTED;
- }
+ data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported storage type %d", keys[i].storage);
if (id >= SOLVABLE_NAME && id <= RPM_RPMDBID)
{
if (keys[i].storage != KEY_STORAGE_INCORE)
- {
- pool_debug(pool, SOLV_ERROR, "main solvable data must use incore storage%d\n", keys[i].storage);
- data.error = SOLV_ERROR_UNSUPPORTED;
- }
+ data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "main solvable data must use incore storage %d", keys[i].storage);
keys[i].storage = KEY_STORAGE_SOLVABLE;
}
/* cannot handle rel idarrays in incore/vertical */
if (type == REPOKEY_TYPE_REL_IDARRAY && keys[i].storage != KEY_STORAGE_SOLVABLE)
- {
- pool_debug(pool, SOLV_ERROR, "type REL_IDARRAY is only supported for STORAGE_SOLVABLE\n");
- data.error = SOLV_ERROR_UNSUPPORTED;
- }
+ data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "type REL_IDARRAY is only supported for STORAGE_SOLVABLE");
/* cannot handle mapped ids in vertical */
if (!(flags & REPO_LOCALPOOL) && keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET && (type == REPOKEY_TYPE_ID || type == REPOKEY_TYPE_IDARRAY))
- {
- pool_debug(pool, SOLV_ERROR, "mapped ids are not supported for STORAGE_VERTICAL_OFFSET\n");
- data.error = SOLV_ERROR_UNSUPPORTED;
- }
+ data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "mapped ids are not supported for STORAGE_VERTICAL_OFFSET");
if (keys[i].type == REPOKEY_TYPE_CONSTANTID && idmap)
keys[i].size = idmap[keys[i].size];
l = allsize;
if (!l || fread(buf, l, 1, data.fp) != 1)
{
- pool_debug(pool, SOLV_ERROR, "unexpected EOF\n");
- data.error = SOLV_ERROR_EOF;
+ data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF");
id = 0;
}
else
break;
if (left < 0)
{
- pool_debug(pool, SOLV_ERROR, "buffer overrun\n");
- data.error = SOLV_ERROR_EOF;
+ data.error = pool_error(pool, SOLV_ERROR_EOF, "buffer overrun");
break;
}
if (left < maxsize)
l = allsize;
if (l && fread(buf + left, l, 1, data.fp) != 1)
{
- pool_debug(pool, SOLV_ERROR, "unexpected EOF\n");
- data.error = SOLV_ERROR_EOF;
+ data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF");
break;
}
allsize -= l;
dp = data_read_rel_idarray(dp, &idarraydatap, idmap, numid + numrel, &data, 0);
if (idarraydatap > idarraydataend)
{
- pool_debug(pool, SOLV_ERROR, "idarray overflow\n");
- data.error = SOLV_ERROR_OVERFLOW;
+ data.error = pool_error(pool, SOLV_ERROR_OVERFLOW, "idarray overflow");
break;
}
if (id == SOLVABLE_PROVIDES)
needchunk = 1;
if (keydepth == sizeof(stack)/sizeof(*stack))
{
- pool_debug(pool, SOLV_ERROR, "array stack overflow\n");
- data.error = SOLV_ERROR_CORRUPT;
+ data.error = pool_error(pool, SOLV_ERROR_OVERFLOW, "array stack overflow");
break;
}
stack[keydepth++] = nentries;
/* horray! here come the solvables */
if (nentries != numsolv)
{
- pool_debug(pool, SOLV_ERROR, "inconsistent number of solvables: %d %d\n", nentries, numsolv);
- data.error = SOLV_ERROR_CORRUPT;
+ data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "inconsistent number of solvables: %d %d", nentries, numsolv);
break;
}
if (idarraydatap)
{
- pool_debug(pool, SOLV_ERROR, "more than one solvable block\n");
- data.error = SOLV_ERROR_CORRUPT;
+ data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "more than one solvable block");
break;
}
if ((flags & REPO_EXTEND_SOLVABLES) != 0)
if (keys[key].type == REPOKEY_TYPE_FIXARRAY)
{
if (!id)
- {
- pool_debug(pool, SOLV_ERROR, "illegal fixarray\n");
- data.error = SOLV_ERROR_CORRUPT;
- }
+ data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "illegal fixarray");
stack[keydepth - 1] = id;
}
keyp = schemadata + schemata[id];
/* should shrink idarraydata again */
if (keydepth)
- {
- pool_debug(pool, SOLV_ERROR, "unexpected EOF, depth = %d\n", keydepth);
- data.error = SOLV_ERROR_CORRUPT;
- }
+ data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF, depth = %d", keydepth);
if (!data.error)
{
if (dp > bufend)
- {
- pool_debug(pool, SOLV_ERROR, "buffer overrun\n");
- data.error = SOLV_ERROR_EOF;
- }
+ data.error = pool_error(pool, SOLV_ERROR_EOF, "buffer overrun");
}
solv_free(buf);
data.lastverticaloffset = fileoffset;
pagesize = read_u32(&data);
data.error = repopagestore_read_or_setup_pages(&data.store, data.fp, pagesize, fileoffset);
+ if (data.error == SOLV_ERROR_EOF)
+ pool_error(pool, data.error, "repopagestore setup: unexpected EOF");
+ else if (data.error)
+ pool_error(pool, data.error, "repopagestore setup failed");
}
else
{
repo = repo_create(pool, "archpkgs2solv");
repo_add_repodata(repo, 0);
for (i = 0; i < npkgs; i++)
- repo_add_arch_pkg(repo, pkgs[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|flags);
+ if (repo_add_arch_pkg(repo, pkgs[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|flags) != 0)
+ {
+ fprintf(stderr, "archpkgs2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
repo_internalize(repo);
tool_write(repo, basefile, 0);
pool_free(pool);
{
Pool *pool;
Repo *repo;
- int c;
+ int c, ret;
const char *localdb = 0;
while ((c = getopt(argc, argv, "hl:")) >= 0)
pool = pool_create();
repo = repo_create(pool, "<stdin>");
if (localdb)
- repo_add_arch_local(repo, localdb, 0);
+ ret = repo_add_arch_local(repo, localdb, 0);
else
- repo_add_arch_repo(repo, stdin, 0);
+ ret = repo_add_arch_repo(repo, stdin, 0);
+ if (ret)
+ {
+ fprintf(stderr, "archrepo2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
Queue keyq;
queue_init(&keyq);
- repo_write_filtered(repo, fp, keyfilter, kfdata, &keyq);
+ if (repo_write_filtered(repo, fp, keyfilter, kfdata, &keyq) != 0)
+ {
+ fprintf(stderr, "repo_write failed\n");
+ exit(1);
+ }
h = repodata_new_handle(info);
if (keyq.count)
repodata_set_idarray(info, h, REPOSITORY_KEYS, &keyq);
kd.languages = languages;
kd.nlanguages = nlanguages;
repodata_internalize(info);
- repo_write_filtered(repo, fp, keyfilter_other, &kd, 0);
- fclose(fp);
+ if (repo_write_filtered(repo, fp, keyfilter_other, &kd, 0) != 0)
+ {
+ fprintf(stderr, "repo_write failed\n");
+ exit(1);
+ }
+ if (fclose(fp) != 0)
+ {
+ perror("fclose");
+ exit(1);
+ }
for (i = 0; i < nlanguages; i++)
free(languages[i]);
solv_free(languages);
kd.haveexternal = 1;
}
repodata_internalize(info);
- repo_write_filtered(repo, stdout, keyfilter_solv, &kd, 0);
+ if (repo_write_filtered(repo, stdout, keyfilter_solv, &kd, 0) != 0)
+ {
+ fprintf(stderr, "repo_write failed\n");
+ exit(1);
+ }
repodata_free(info);
return 0;
}
{
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
- repo_add_comps(repo, stdin, 0);
+ if (repo_add_comps(repo, stdin, 0))
+ {
+ fprintf(stderr, "comps2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
break;
}
}
- repo_add_deltainfoxml(repo, stdin, flags);
+ if (repo_add_deltainfoxml(repo, stdin, flags))
+ {
+ fprintf(stderr, "deltainfoxml2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, attrname);
pool_free(pool);
exit(0);
break;
}
}
- repo_add_diskusagexml(repo, stdin, flags);
+ if (repo_add_diskusagexml(repo, stdin, flags))
+ {
+ fprintf(stderr, "diskusagexml2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, attrname);
pool_free(pool);
exit(0);
}
repo = repo_create(pool, argv[optind]);
if (repo_add_solv(repo, stdin, 0))
- printf("could not read repository\n");
+ printf("could not read repository: %s\n", pool_errstr(pool));
}
if (!pool->urepos)
{
repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
if (repo_add_solv(repo, stdin, 0))
- printf("could not read repository\n");
+ printf("could not read repository: %s\n", pool_errstr(pool));
}
printf("pool contains %d strings, %d rels, string size is %d\n", pool->ss.nstrings, pool->nrels, pool->ss.sstrings);
pool_setdebuglevel(pool, 1);
installed = repo_create(pool, "@System");
pool_set_installed(pool, installed);
- repo_add_rpmdb(installed, 0, 0, 0);
+ if (repo_add_rpmdb(installed, 0, 0, 0))
+ {
+ fprintf(stderr, "findfileconflicts: %s\n", pool_errstr(pool));
+ exit(1);
+ }
queue_init(&todo);
queue_init(&conflicts);
FOR_REPO_SOLVABLES(installed, p, s)
{
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
- repo_add_helix(repo, stdin, 0);
+ if (repo_add_helix(repo, stdin, 0))
+ {
+ fprintf(stderr, "helix2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
for (i = 2; i < argc; i++)
{
FILE *fp;
- int l;
+ int r, l;
if (!strcmp(argv[i], "--withsrc"))
{
exit(1);
}
repo = repo_create(pool, argv[i]);
+ r = 0;
if (0)
{
}
#ifdef ENABLE_SUSEREPO
else if (l >= 8 && !strcmp(argv[i] + l - 8, "packages"))
{
- repo_add_susetags(repo, fp, 0, 0, 0);
+ r = repo_add_susetags(repo, fp, 0, 0, 0);
}
else if (l >= 11 && !strcmp(argv[i] + l - 11, "packages.gz"))
{
- repo_add_susetags(repo, fp, 0, 0, 0);
+ r = repo_add_susetags(repo, fp, 0, 0, 0);
}
#endif
#ifdef ENABLE_RPMMD
else if (l >= 14 && !strcmp(argv[i] + l - 14, "primary.xml.gz"))
{
- repo_add_rpmmd(repo, fp, 0, 0);
+ r = repo_add_rpmmd(repo, fp, 0, 0);
}
#endif
#ifdef ENABLE_DEBIAN
else if (l >= 8 && !strcmp(argv[i] + l - 8, "Packages"))
{
- repo_add_debpackages(repo, fp, 0);
+ r = repo_add_debpackages(repo, fp, 0);
}
else if (l >= 11 && !strcmp(argv[i] + l - 11, "Packages.gz"))
{
- repo_add_debpackages(repo, fp, 0);
+ r = repo_add_debpackages(repo, fp, 0);
}
#endif
- else if (repo_add_solv(repo, fp, 0))
+ else
+ r = repo_add_solv(repo, fp, 0);
+ if (r)
{
- fprintf(stderr, "could not add repo %s\n", argv[i]);
+ fprintf(stderr, "could not add repo %s: %s\n", argv[i], pool_errstr(pool));
exit(1);
}
if (fp != stdin)
}
pool = pool_create();
repo = repo_create(pool, "<stdin>");
- repo_add_mdk(repo, stdin, REPO_NO_INTERNALIZE);
+ if (repo_add_mdk(repo, stdin, REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "mdk2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
if (infofile)
{
FILE *fp = solv_xfopen(infofile, "r");
perror(infofile);
exit(1);
}
- repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "mdk2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
if (filesfile)
perror(filesfile);
exit(1);
}
- repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "mdk2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
repo_internalize(repo);
perror(argv[optind]);
exit(1);
}
- repo_add_solv(repo, fp, 0);
+ if (repo_add_solv(repo, fp, 0))
+ {
+ fprintf(stderr, "repo %s: %s\n", argv[optind], pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
tool_write(repo, basefile, 0);
{
char *arch, *mypatch;
const char *pname;
- int l;
+ int l, r;
FILE *fp;
int i;
Id pid, p, pp;
perror(argv[i]);
exit(1);
}
+ r = 0;
if (0)
{
}
#ifdef ENABLE_SUSEREPO
else if (l >= 8 && !strcmp(argv[i] + l - 8, "packages"))
{
- repo_add_susetags(c.repo, fp, 0, 0, 0);
+ r = repo_add_susetags(c.repo, fp, 0, 0, 0);
}
else if (l >= 11 && !strcmp(argv[i] + l - 11, "packages.gz"))
{
- repo_add_susetags(c.repo, fp, 0, 0, 0);
+ r = repo_add_susetags(c.repo, fp, 0, 0, 0);
}
#endif
#ifdef ENABLE_RPMMD
else if (l >= 14 && !strcmp(argv[i] + l - 14, "primary.xml.gz"))
{
- repo_add_rpmmd(c.repo, fp, 0, 0);
+ r = repo_add_rpmmd(c.repo, fp, 0, 0);
}
else if (l >= 17 && !strcmp(argv[i] + l - 17, "updateinfo.xml.gz"))
{
- repo_add_updateinfoxml(c.repo, fp, 0);
+ r = repo_add_updateinfoxml(c.repo, fp, 0);
}
#endif
- else if (repo_add_solv(c.repo, fp, 0))
+ else
+ r = repo_add_solv(c.repo, fp, 0);
+ if (r)
{
- fprintf(stderr, "could not add repo %s\n", argv[i]);
+ fprintf(stderr, "could not add repo %s: %s\n", argv[i], pool_errstr(pool));
exit(1);
}
if (fp != stdin)
break;
}
}
- repo_add_repomdxml(repo, stdin, flags);
+ if (repo_add_repomdxml(repo, stdin, flags))
+ {
+ fprintf(stderr, "repomdxml2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
if (query)
doquery(pool, repo, query);
else
Pool *pool = pool_create();
Repo *repo, *ref = 0;
Repodata *data;
- Pool *refpool;
int c, percent = 0;
int extrapool = 0;
int nopacks = 0;
}
else
{
- if (extrapool)
- refpool = pool_create();
+ Pool *refpool = extrapool ? pool_create() : 0;
+ ref = repo_create(refpool ? refpool : pool, "ref");
+ if (repo_add_solv(ref, fp, 0) != 0)
+ {
+ fprintf(stderr, "%s: %s\n", refname, pool_errstr(ref->pool));
+ if (ref->pool != pool)
+ pool_free(ref->pool);
+ else
+ repo_free(ref, 1);
+ ref = 0;
+ }
else
- refpool = pool;
- ref = repo_create(refpool, "ref");
- repo_add_solv(ref, fp, 0);
- repo_disable_paging(ref);
+ repo_disable_paging(ref);
fclose(fp);
}
}
data = repo_add_repodata(repo, 0);
if (!nopacks)
- repo_add_rpmdb(repo, ref, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | (percent ? RPMDB_REPORT_PROGRESS : 0));
+ {
+ if (repo_add_rpmdb(repo, ref, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | (percent ? RPMDB_REPORT_PROGRESS : 0)))
+ {
+ fprintf(stderr, "rpmdb2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ }
#ifdef ENABLE_SUSEREPO
if (proddir && *proddir)
strcpy(buf + rootlen, proddir);
}
}
- repo_add_products(repo, buf, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_products(repo, buf, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "rpmdb2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
if (buf != proddir)
solv_free(buf);
}
perror(fnp);
exit(1);
}
- repo_add_rpmmd(repo, fp, 0, flags);
+ if (repo_add_rpmmd(repo, fp, 0, flags))
+ {
+ fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
snprintf(fnp, l, "%s/diskusagedata.xml.gz", dir);
if ((fp = solv_xfopen(fnp, 0)))
{
- repo_add_rpmmd(repo, fp, 0, flags);
+ if (repo_add_rpmmd(repo, fp, 0, flags))
+ {
+ fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
if (locale)
exit(1);
}
fprintf(stderr, "opened %s\n", fnp);
- repo_add_rpmmd(repo, fp, 0, flags);
+ if (repo_add_rpmmd(repo, fp, 0, flags))
+ {
+ fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
solv_free(fnp);
}
else
- repo_add_rpmmd(repo, stdin, 0, flags);
+ {
+ if (repo_add_rpmmd(repo, stdin, 0, flags))
+ {
+ fprintf(stderr, "rpmmd2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ }
tool_write(repo, basefile, attrname);
pool_free(pool);
exit(0);
rpms[nrpms++] = strdup(argv[optind++]);
}
repo = repo_create(pool, "rpms2solv");
- repo_add_rpms(repo, rpms, nrpms, 0);
+ if (repo_add_rpms(repo, rpms, nrpms, 0))
+ {
+ fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, basefile, 0);
pool_free(pool);
for (c = 0; c < nrpms; c++)
perror(contentfile);
exit(1);
}
- repo_add_content(repo, fp, REPO_REUSE_REPODATA);
+ if (repo_add_content(repo, fp, REPO_REUSE_REPODATA))
+ {
+ fprintf(stderr, "susetags2solv: %s: %s\n", contentfile, pool_errstr(pool));
+ exit(1);
+ }
defvendor = repo_lookup_id(repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR);
fclose(fp);
}
perror(fn);
exit(1);
}
- repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
else if (!strcmp(fn, "packages.DU") || !strcmp(fn, "packages.DU.gz"))
perror(fn);
exit(1);
}
- repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
else if (!strcmp(fn, "packages.FL") || !strcmp(fn, "packages.FL.gz"))
perror(fn);
exit(1);
}
- repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
#else
/* ignore for now. reactivate when filters work */
perror(fn);
exit(1);
}
- repo_add_susetags(repo, fp, defvendor, lang, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ if (repo_add_susetags(repo, fp, defvendor, lang, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool));
+ exit(1);
+ }
fclose(fp);
}
}
repo_internalize(repo);
}
else
- /* read data from stdin */
- repo_add_susetags(repo, stdin, defvendor, 0, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ {
+ /* read data from stdin */
+ if (repo_add_susetags(repo, stdin, defvendor, 0, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE))
+ {
+ fprintf(stderr, "susetags2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ }
repo_internalize(repo);
if (query)
break;
}
}
- repo_add_updateinfoxml(repo, stdin, flags);
+ if (repo_add_updateinfoxml(repo, stdin, flags))
+ {
+ fprintf(stderr, "updateinfoxml2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
tool_write(repo, 0, attrname);
pool_free(pool);
exit(0);