#include <assert.h>
#include <dirent.h>
#include <expat.h>
+#include <errno.h>
#include "pool.h"
#include "repo.h"
#include "util.h"
#define DISABLE_SPLIT
#include "tools_util.h"
-#include "repo_content.h"
+#include "repo_zyppdb.h"
-//#define DUMPOUT 0
-
enum state {
- STATE_START, // 0
- STATE_PRODUCT, // 1
- STATE_NAME, // 2
- STATE_VERSION, // 3
- STATE_ARCH, // 4
- STATE_SUMMARY, // 5
- STATE_VENDOR, // 6
- STATE_INSTALLTIME, // 7
- NUMSTATES // 0
+ STATE_START,
+ STATE_PRODUCT,
+ STATE_NAME,
+ STATE_VERSION,
+ STATE_ARCH,
+ STATE_SUMMARY,
+ STATE_VENDOR,
+ STATE_INSTALLTIME,
+ NUMSTATES
};
struct stateswitch {
/* parse 'type' */
const char *type = find_attr("type", atts);
s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
- repodata_extend(pd->data, s - pool->solvables);
pd->handle = s - pool->solvables;
if (type)
repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
pool_debug(pd->pool, SOLV_ERROR, "repo_zyppdb: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ if (pd->solvable)
+ {
+ repo_free_solvable(pd->repo, pd->solvable - pd->pool->solvables, 1);
+ pd->solvable = 0;
+ }
return;
}
if (l == 0)
* parse each one as a product
*/
-void
+int
repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
{
int i;
DIR *dir;
FILE *fp;
Repodata *data;
-
+
data = repo_add_repodata(repo, flags);
memset(&pd, 0, sizeof(pd));
pd.repo = repo;
pd.sbtab[sw->to] = sw->from;
}
+ if (flags & REPO_USE_ROOTDIR)
+ dirpath = pool_prepend_rootdir(repo->pool, dirpath);
dir = opendir(dirpath);
if (dir)
{
fullpath = join2(&pd.jd, dirpath, "/", entry->d_name);
if ((fp = fopen(fullpath, "r")) == 0)
{
- perror(fullpath);
+ pool_error(repo->pool, 0, "%s: %s", fullpath, strerror(errno));
continue;
}
add_zyppdb_product(&pd, fp);
free(pd.content);
join_freemem(&pd.jd);
+ if (flags & REPO_USE_ROOTDIR)
+ solv_free((char *)dirpath);
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
+ return 0;
}
/* EOF */