/*
* repo_content.c
- *
+ *
* Parses 'content' file into .solv
* See http://en.opensuse.org/Standards/YaST2_Repository_Metadata/content for a description
* of the syntax
- *
- *
+ *
+ *
* Copyright (c) 2007, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
Repodata *data;
Id handle = 0;
int contentstyle = 0;
-
+
memset(&pd, 0, sizeof(pd));
line = sat_malloc(1024);
aline = 1024;
continue;
*--linep = 0;
linep = line;
-
+
/* expect "key value" lines */
if (split (line, fields, 2) == 2)
{
#define istag(x) (!strcmp (key, x))
#define code10 (contentstyle == 10)
#define code11 (contentstyle == 11)
-
- if (contentstyle == 0)
+
+ if (contentstyle == 0)
{
if (istag ("CONTENTSTYLE"))
{
repodata_add_poolstr_array(data, handle, PRODUCT_RELNOTESURL, value);
else if (istag ("VENDOR"))
s->vendor = str2id(pool, value, 1);
- else if (istag ("PATTERNS"))
- { /* ignore this tag, but accept it */ }
/*
* Every tag below is Code10 only
- *
+ *
*/
-
+
else if (code10 && istag ("DISTPRODUCT"))
/* DISTPRODUCT is for registration and Yast, not for the solver. */
repo_set_str(repo, s - pool->solvables, PRODUCT_DISTPRODUCT, value);
if (code10)
s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0);
}
-
+
if (pd.tmp)
sat_free(pd.tmp);
sat_free(line);
/*
* repo_products.c
- *
+ *
* Parses all files below 'proddir'
* See http://en.opensuse.org/Product_Management/Code11
- *
- *
+ *
+ *
* Copyright (c) 2007, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
static ino_t baseproduct = 0;
static ino_t currentproduct = 0;
+static int productscheme = -1;
+
//#define DUMPOUT 0
enum state {
Repo *repo;
Repodata *data;
int datanum;
-
+
struct stateswitch *swtab[NUMSTATES];
enum state sbtab[NUMSTATES];
* I: atts, list of key/value attributes
* I: dup, strdup it
* O: pointer to value of matching key, or NULL
- *
+ *
*/
static inline const char *
Pool *pool = pd->pool;
struct stateswitch *sw;
-#if 0
+#if 1
fprintf(stderr, "start: [%d]%s\n", pd->state, name);
#endif
if (pd->depth != pd->statedepth)
}
pd->depth++;
- for (sw = pd->swtab[pd->state]; sw->from == pd->state; sw++) /* find name in statetable */
+ if ( !(sw = pd->swtab[pd->state]) ) /* no statetable -> no substates */
+ {
+#if 0
+ fprintf(stderr, "into unknown: [?]%s (from: ?, state %d)\n", name, pd->state);
+#endif
+ return;
+ }
+ for (; sw->from == pd->state; sw++) /* find name in statetable */
if (!strcmp(sw->ename, name))
break;
-
+
if (sw->from != pd->state)
{
#if 0
switch(pd->state)
{
case STATE_PRODUCT:
- /* FIXME: parse 'schemeversion' and store in global variable */
+ /* parse 'schemeversion' and store in global variable */
+ {
+ const char * scheme = find_attr("schemeversion", atts, 0);
+ productscheme = (scheme && *scheme) ? atoi(scheme) : -1;
+ }
if (!pd->s)
{
-
pd->s = pool_id2solvable(pool, repo_add_solvable(pd->repo));
repodata_extend(pd->data, pd->s - pool->solvables);
pd->handle = repodata_get_handle(pd->data, pd->s - pool->solvables - pd->repo->start);
pd->s->arch = str2id(pd->pool, pd->content, 1);
break;
case STATE_UPDATEREPOKEY:
- /* FIXME: Define PRODUCT_UPDATEREPOKEY in src/knownids.h
repodata_set_str(pd->data, pd->handle, langtag(pd, PRODUCT_UPDATEREPOKEY, pd->tmplang), pd->content);
- */
break;
case STATE_SUMMARY:
repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
- if (pd->tmplang)
+ if (pd->tmplang)
{
free( (char *)pd->tmplang );
pd->tmplang = 0;
break;
case STATE_DESCRIPTION:
repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), pd->content );
- if (pd->tmplang)
+ if (pd->tmplang)
{
free( (char *)pd->tmplang );
pd->tmplang = 0;
{
printf("%s\n", pd->content);
}
- break;
+ break;
case STATE_FLAVOR:
+ repodata_set_str(pd->data, pd->handle, PRODUCT_FLAVOR, pd->content );
if (currentproduct == baseproduct
&& pd->attribute
&& !strcmp(pd->attribute, "register.flavor"))
{
printf("%s\n", pd->content);
}
- break;
+ break;
case STATE_REGRELEASE:
if (currentproduct == baseproduct
&& pd->attribute
{
printf("%s\n", pd->content);
}
- break;
+ break;
default:
break;
}
-
+
pd->state = pd->sbtab[pd->state];
pd->docontent = 0;
-
+
#if 0
fprintf(stderr, "end: [%s] -> %d\n", name, pd->state);
#endif
int i, l;
struct stateswitch *sw;
struct stat st;
-
+
pd->s = NULL; /* enforce new solvable when coming here again */
-
+
if (!fstat(fileno(fp), &st))
currentproduct = st.st_ino;
- else
+ else
{
currentproduct = baseproduct+1; /* make it != baseproduct if stat fails */
st.st_ctime = 0;
perror("Can't stat()");
}
-
+
for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
{
if (!pd->swtab[sw->from])
XML_SetUserData(parser, pd);
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
-
+
for (;;)
{
l = fread(buf, 1, sizeof(buf), fp);
break;
}
XML_ParserFree(parser);
-
+
if (pd->s)
{
Solvable *s = pd->s;
/* this is where <productsdir>/baseproduct points to */
if (currentproduct == baseproduct)
repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, "base");
-
+
if (pd->tmprel)
{
if (pd->tmpvers)
char *suffix = code11 ? ".prod" : "-release";
int slen = code11 ? 5 : 8; /* strlen(".prod") : strlen("-release") */
struct stat st;
-
+
/* check for <productsdir>/baseproduct on code11 and remember its target inode */
if (code11
&& stat(join2(path, "/", "baseproduct"), &st) == 0) /* follow symlink */
{
continue;
}
-
+
if (len > slen
&& strcmp(entry->d_name+len-slen, suffix) == 0)
{
/*
* read all installed products
- *
+ *
* try proddir (reading all .xml files from this directory) first
* if not available, assume non-code11 layout and parse /etc/xyz-release
*
int code11 = 1;
DIR *dir = opendir(fullpath);
struct parsedata pd;
-
+
memset(&pd, 0, sizeof(pd));
pd.repo = repo;
pd.pool = repo->pool;