Mailinglist Archive: zypp-commit (185 mails)

< Previous Next >
[zypp-commit] r10815 - in /trunk/sat-solver/tools: repo_products.c repo_products.h repo_rpmdb.c repo_rpmdb.h rpmdb2solv.c rpms2solv.c
  • From: kkaempf@xxxxxxxxxxxxxxxx
  • Date: Tue, 12 Aug 2008 12:20:43 -0000
  • Message-id: <20080812122043.4F0742DA1E@xxxxxxxxxxxxxxxx>
Author: kkaempf
Date: Tue Aug 12 14:20:42 2008
New Revision: 10815

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10815&view=rev
Log:
adapt repo_products (/etc/products.d/*.prod parsing) to current definition
fix repodata handling in repo_products
move repodata handling to main()

Modified:
trunk/sat-solver/tools/repo_products.c
trunk/sat-solver/tools/repo_products.h
trunk/sat-solver/tools/repo_rpmdb.c
trunk/sat-solver/tools/repo_rpmdb.h
trunk/sat-solver/tools/rpmdb2solv.c
trunk/sat-solver/tools/rpms2solv.c

Modified: trunk/sat-solver/tools/repo_products.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_products.c?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_products.c (original)
+++ trunk/sat-solver/tools/repo_products.c Tue Aug 12 14:20:42 2008
@@ -29,6 +29,7 @@
Repo *repo;
char *tmp;
int tmpl;
+ Id langcache[ID_NUM_INTERNAL];
};


@@ -73,6 +74,10 @@
}


+/*
+ * create epoch:version-release as Id
+ */
+
static Id
makeevr(Pool *pool, char *s)
{
@@ -82,10 +87,32 @@
}


+/*
+ * create localized tag
+ */
+
+static Id
+langtag(struct parsedata *pd, Id tag, const char *language)
+{
+ if (language && !language[0])
+ language = 0;
+ if (!language || tag >= ID_NUM_INTERNAL)
+ return pool_id2langid(pd->repo->pool, tag, language, 1);
+ return pool_id2langid(pd->repo->pool, tag, language, 1);
+ if (!pd->langcache[tag])
+ pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
+ return pd->langcache[tag];
+}
+
+
+
+
enum sections
{
SECTION_UNKNOWN,
- SECTION_PRODUCT
+ SECTION_PRODUCT,
+ SECTION_TRANSLATED,
+ SECTION_UPDATE
};


@@ -95,7 +122,7 @@
*/

static void
-repo_add_product(struct parsedata *pd, FILE *fp)
+repo_add_product(struct parsedata *pd, Repodata *data, FILE *fp)
{
Repo *repo = pd->repo;
Pool *pool = repo->pool;
@@ -103,15 +130,8 @@
int aline;
Solvable *s = 0;
Id handle = 0;
- Repodata *data;

enum sections current_section = SECTION_UNKNOWN;
-
- if (repo->nrepodata)
- /* use last repodata */
- data = repo->repodata + repo->nrepodata - 1;
- else
- data = repo_add_repodata(repo, 0);

line = sat_malloc(1024);
aline = 1024;
@@ -162,6 +182,10 @@
*endp = 0;
if (!strcmp(secp, "product"))
current_section = SECTION_PRODUCT;
+ else if (!strcmp(secp, "translated"))
+ current_section = SECTION_TRANSLATED;
+ else if (!strcmp(secp, "update"))
+ current_section = SECTION_UPDATE;
else
{
fprintf(stderr, "Skipping unknown section '%s'\n", secp);
@@ -172,14 +196,24 @@
else if (current_section != SECTION_UNKNOWN)
{
char *ptr = linep;
- char *key, *value;
+ char *key, *value, *lang;

- /* split line into '<key> = <value>' */
+ lang = 0;
+
+ /* split line into '<key>[<lang>] = <value>' */
while (*ptr && (*ptr == ' ' || *ptr == '\t'))
++ptr;
key = ptr;
- while (*ptr && !(*ptr == ' ' || *ptr == '\t' || *ptr == '='))
+ while (*ptr && !(*ptr == ' ' || *ptr == '\t' || *ptr == '=' || *ptr
== '['))
++ptr;
+ if (*ptr == '[')
+ {
+ *ptr++ = 0;
+ lang = ptr;
+ while (*ptr && !(*ptr == ']'))
+ ++ptr;
+ *ptr++ = 0;
+ }
if (*ptr != '=')
*ptr++ = 0;
while (*ptr && !(*ptr == '='))
@@ -189,10 +223,11 @@
while (*ptr && (*ptr == ' ' || *ptr == '\t'))
++ptr;
value = ptr;
- while (*ptr && !(*ptr == ' ' || *ptr == '\t'))
- ++ptr;
- *ptr++ = 0;

+ /*
+ * [product]
+ */
+
if (current_section == SECTION_PRODUCT)
{
if (!s)
@@ -205,9 +240,31 @@
s->name = str2id(pool, join(pd, "product", ":", value), 1);
else if (!strcmp(key, "version"))
s->evr = makeevr(pool, value);
+ else if (!strcmp(key, "vendor"))
+ s->vendor = str2id(pool, value, 1);
+ else if (!strcmp(key, "distribution"))
+ repo_set_str(repo, s - pool->solvables, SOLVABLE_DISTRIBUTION,
value);
else if (!strcmp (key, "flavor"))
repo_set_str(repo, s - pool->solvables, PRODUCT_FLAVOR, value);

}
+ /*
+ * [translated]
+ */
+ else if (current_section == SECTION_TRANSLATED)
+ {
+ if (!strcmp(key, "summary"))
+ {
+ repodata_set_str(data, handle, langtag(pd, SOLVABLE_SUMMARY,
lang), value );
+ }
+ else if (!strcmp(key, "description"))
+ repodata_set_str(data, handle, langtag(pd,
SOLVABLE_DESCRIPTION, lang), value );
+ }
+ /*
+ * [update]
+ */
+ else if (current_section == SECTION_UPDATE)
+ {
+ }
}
else
fprintf (stderr, "malformed line: %s\n", line);
@@ -236,7 +293,7 @@
*/

void
-repo_add_products(Repo *repo, const char *proddir)
+repo_add_products(Repo *repo, Repodata *repodata, const char *proddir)
{
DIR *dir = opendir(proddir);
struct dirent *entry;
@@ -264,7 +321,7 @@
perror(fullpath);
break;
}
- repo_add_product(&pd, fp);
+ repo_add_product(&pd, repodata, fp);
fclose(fp);
}
}

Modified: trunk/sat-solver/tools/repo_products.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_products.h?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_products.h (original)
+++ trunk/sat-solver/tools/repo_products.h Tue Aug 12 14:20:42 2008
@@ -5,4 +5,4 @@
* for further information
*/

-void repo_add_products(Repo *repo, const char *proddir);
+void repo_add_products(Repo *repo, Repodata *repodata, const char *proddir);

Modified: trunk/sat-solver/tools/repo_rpmdb.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmdb.c?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmdb.c (original)
+++ trunk/sat-solver/tools/repo_rpmdb.c Tue Aug 12 14:20:42 2008
@@ -1184,7 +1184,7 @@
*/

void
-repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir)
+repo_add_rpmdb(Repo *repo, Repodata *repodata, Repo *ref, const char *rootdir)
{
Pool *pool = repo->pool;
unsigned char buf[16];
@@ -1202,7 +1202,6 @@
Id id, *refhash;
unsigned int refmask, h;
int asolv;
- Repodata *repodata;
char dbpath[PATH_MAX];
DB_ENV *dbenv = 0;
DBT dbkey;
@@ -1218,8 +1217,6 @@
if (!rootdir)
rootdir = "";

- repodata = repo_add_repodata(repo, 0);
-
if (ref && !(ref->nsolvables && ref->rpmdbid))
ref = 0;

@@ -1531,16 +1528,16 @@
if (db)
db->close(db, 0);
dbenv->close(dbenv, 0);
- if (repodata)
- repodata_internalize(repodata);
}

+
static inline unsigned int
getu32(unsigned char *dp)
{
return dp[0] << 24 | dp[1] << 16 | dp[2] << 8 | dp[3];
}

+
static void
add_location(Repodata *data, Solvable *s, Id handle, const char *location)
{
@@ -1600,12 +1597,11 @@
}

void
-repo_add_rpms(Repo *repo, const char **rpms, int nrpms)
+repo_add_rpms(Repo *repo, Repodata *repodata, const char **rpms, int nrpms)
{
int i, sigdsize, sigcnt, l;
Pool *pool = repo->pool;
Solvable *s;
- Repodata *repodata;
RpmHead *rpmhead = 0;
int rpmheadsize = 0;
char *payloadformat;
@@ -1616,7 +1612,7 @@

if (nrpms <= 0)
return;
- repodata = repo_add_repodata(repo, 0);
+
for (i = 0; i < nrpms; i++)
{
if ((fp = fopen(rpms[i], "r")) == 0)
@@ -1729,6 +1725,4 @@
}
if (rpmhead)
sat_free(rpmhead);
- if (repodata)
- repodata_internalize(repodata);
}

Modified: trunk/sat-solver/tools/repo_rpmdb.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmdb.h?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmdb.h (original)
+++ trunk/sat-solver/tools/repo_rpmdb.h Tue Aug 12 14:20:42 2008
@@ -5,5 +5,5 @@
* for further information
*/

-extern void repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir);
-extern void repo_add_rpms(Repo *repo, const char **rpms, int nrpms);
+extern void repo_add_rpmdb(Repo *repo, Repodata *repodata, Repo *ref, const
char *rootdir);
+extern void repo_add_rpms(Repo *repo, Repodata *repodata, const char **rpms,
int nrpms);

Modified: trunk/sat-solver/tools/rpmdb2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpmdb2solv.c?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpmdb2solv.c (original)
+++ trunk/sat-solver/tools/rpmdb2solv.c Tue Aug 12 14:20:42 2008
@@ -33,10 +33,12 @@
{
Pool *pool = pool_create();
Repo *repo, *ref = 0;
+ Repodata *repodata;
FILE *fp;
Pool *refpool;
int c;
int extrapool = 0;
+ int nopacks = 0;
const char *root = 0;
const char *basefile = 0;
const char *proddir = 0;
@@ -45,7 +47,7 @@
* parse arguments
*/

- while ((c = getopt (argc, argv, "xb:r:p:")) >= 0)
+ while ((c = getopt (argc, argv, "nxb:r:p:")) >= 0)
switch (c)
{
case 'r':
@@ -54,6 +56,9 @@
case 'b':
basefile = optarg;
break;
+ case 'n':
+ nopacks = 1;
+ break;
case 'p':
proddir = optarg;
break;
@@ -93,13 +98,17 @@
*/

repo = repo_create(pool, "installed");
+ repodata = repo_add_repodata(repo, 0);

- repo_add_rpmdb(repo, ref, root);
+ if (!nopacks)
+ repo_add_rpmdb(repo, repodata, ref, root);

if (proddir)
- {
- repo_add_products(repo, proddir);
- }
+ repo_add_products(repo, repodata, proddir);
+
+ if (repodata)
+ repodata_internalize(repodata);
+
if (ref)
{
if (ref->pool != pool)

Modified: trunk/sat-solver/tools/rpms2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpms2solv.c?rev=10815&r1=10814&r2=10815&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpms2solv.c (original)
+++ trunk/sat-solver/tools/rpms2solv.c Tue Aug 12 14:20:42 2008
@@ -31,6 +31,7 @@
int c, nrpms = 0;
Pool *pool = pool_create();
Repo *repo;
+ Repodata *repodata;
FILE *fp;
char buf[4096], *p;
const char *basefile = 0;
@@ -74,8 +75,11 @@
rpms[nrpms++] = strdup(argv[optind++]);
}
repo = repo_create(pool, "rpms2solv");
- repo_add_rpms(repo, rpms, nrpms);
+ repodata = repo_add_repodata(repo, 0);
+ repo_add_rpms(repo, repodata, rpms, nrpms);
tool_write(repo, basefile, 0);
+ if (repodata)
+ repodata_internalize(repodata);
pool_free(pool);
for (c = 0; c < nrpms; c++)
free((char *)rpms[c]);

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages