Author: kkaempf
Date: Wed Sep 24 10:54:34 2008
New Revision: 11139
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11139&view=rev
Log:
re-add parsing of /etc/<xyz>-release (got lost in transistion from
.ini to .xml), bnc#429177
Modified:
trunk/sat-solver/tools/repo_products.c
Modified: trunk/sat-solver/tools/repo_products.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_products.c?rev=11139&r1=11138&r2=11139&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_products.c (original)
+++ trunk/sat-solver/tools/repo_products.c Wed Sep 24 10:54:34 2008
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -423,26 +424,109 @@
pd->ctime = 0;
}
- XML_Parser parser = XML_ParserCreate(NULL);
- XML_SetUserData(parser, pd);
- XML_SetElementHandler(parser, startElement, endElement);
- XML_SetCharacterDataHandler(parser, characterData);
-
- for (;;)
+ if (code11)
{
- l = fread(buf, 1, sizeof(buf), fp);
- if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
+ XML_Parser parser = XML_ParserCreate(NULL);
+ XML_SetUserData(parser, pd);
+ XML_SetElementHandler(parser, startElement, endElement);
+ XML_SetCharacterDataHandler(parser, characterData);
+
+ for (;;)
{
- fprintf(stderr, "repo_products: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- exit(1);
+ l = fread(buf, 1, sizeof(buf), fp);
+ if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
+ {
+ fprintf(stderr, "repo_products: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ exit(1);
+ }
+ if (l == 0)
+ break;
}
- if (l == 0)
- break;
+ XML_ParserFree(parser);
}
- XML_ParserFree(parser);
+ else
+ {
+ Id name = 0;
+ Id arch = 0;
+ Id version = 0;
+ int lnum = 0; /* line number */
+ char *ptr, *ptr1;
+ /* parse /etc/<xyz>-release file */
+ while (fgets(buf, sizeof(buf), fp))
+ {
+ /* remove trailing \n */
+ int l = strlen(buf);
+ if (*(buf + l - 1) == '\n')
+ {
+ --l;
+ *(buf + l) = 0;
+ }
+ ++lnum;
+
+ if (lnum == 1)
+ {
+ /* 1st line, <name> [(<arch>)] */
+ ptr = strchr(buf, '(');
+ if (ptr)
+ {
+ ptr1 = ptr - 1;
+ *ptr++ = 0;
+ }
+ else
+ ptr1 = buf + l - 1;
+
+ /* track back until non-blank, non-digit */
+ while (ptr1 > buf
+ && (*ptr1 == ' ' || isdigit(*ptr1) || *ptr1 == '.'))
+ --ptr1;
+ *(++ptr1) = 0;
+ name = str2id(pd->pool, join2("product", ":", buf), 1);
+
+ if (ptr)
+ {
+ /* have arch */
+ char *ptr1 = strchr(ptr, ')');
+ if (ptr1)
+ {
+ *ptr1 = 0;
+ /* downcase arch */
+ ptr1 = ptr;
+ while (*ptr1)
+ {
+ if (isupper(*ptr1)) *ptr1 = tolower(*ptr1);
+ ++ptr1;
+ }
+ arch = str2id(pd->pool, ptr, 1);
+ }
+ }
+ }
+ else if (strncmp(buf, "VERSION", 7) == 0)
+ {
+ ptr = strchr(buf+7, '=');
+ if (ptr)
+ {
+ while (*++ptr == ' ');
+ version = makeevr(pd->pool, ptr);
+ }
+ }
+ }
+ if (name)
+ {
+ Solvable *s = pd->solvable = pool_id2solvable(pd->pool, repo_add_solvable(pd->repo));
+ s->name = name;
+ if (version)
+ s->evr = version;
+ if (arch)
+ s->arch = arch;
+ if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+ s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
+ }
+ }
+ return;
}
+
/*
* parse dir looking for files ending in suffix
*/
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org