Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : - repo_content: store DESCRDIR
  • From: Michael Schroeder <mls@xxxxxxx>
  • Date: Wed, 24 Jun 2009 11:26:18 +0200
  • Message-id: <E1MJOki-0007Ia-Tf@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 5a479c355bf11fa3e0ed482e29ef943c1a2a4760
Author: Michael Schroeder <mls@xxxxxxx>
Date: Wed Jun 24 11:26:18 2009 +0200

- repo_content: store DESCRDIR
- susetags2solv: add query option
---
ext/repo_content.c | 58 ++++++++++++++++++++++++++++++++++++++++--------
src/knownid.h | 9 +++++--
tools/susetags2solv.c | 29 ++++++++++++++++++++++-
3 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/ext/repo_content.c b/ext/repo_content.c
index 4c71c42..b398297 100644
--- a/ext/repo_content.c
+++ b/ext/repo_content.c
@@ -203,6 +203,8 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
Repodata *data;
Id handle = 0;
int contentstyle = 0;
+ char *descrdir = 0;
+ char *datadir = 0;

int i = 0;

@@ -270,17 +272,45 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
#define code10 (contentstyle == 10)
#define code11 (contentstyle == 11)

- if (contentstyle == 0)
+ if (istag ("CONTENTSTYLE"))
{
- if (istag ("CONTENTSTYLE"))
- {
- contentstyle = atoi(value);
- continue;
- }
+ contentstyle = atoi(value);
+ continue;
+ }
+ if (!contentstyle)
+ contentstyle = 10;
+
+ if (istag ("DESCRDIR"))
+ {
+ if (descrdir)
+ free(descrdir);
+ else
+ repo_set_str(repo, SOLVID_META, SUSETAGS_DESCRDIR, value);
+ if (s)
+ repo_set_str(repo, s - pool->solvables, SUSETAGS_DESCRDIR,
value);
+ descrdir = strdup(value);
+ continue;
+ }
+ if (istag ("DATADIR"))
+ {
+ if (datadir)
+ free(datadir);
else
- contentstyle = 10;
+ repo_set_str(repo, SOLVID_META, SUSETAGS_DATADIR, value);
+ if (s)
+ repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR,
value);
+ datadir = strdup(value);
+ continue;
}

+ /* XXX: add those to SOLVID_META, too */
+ if (istag ("META"))
+ continue;
+ if (istag ("HASH"))
+ continue;
+ if (istag ("KEY"))
+ continue;
+
if ((code10 && istag ("PRODUCT"))
|| (code11 && istag ("NAME")))
{
@@ -306,6 +336,10 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
repodata_extend(data, s - pool->solvables);
handle = s - pool->solvables;
s->name = str2id(pool, join(&pd, "product", ":", value), 1);
+ if (datadir)
+ repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR,
datadir);
+ if (descrdir)
+ repo_set_str(repo, s - pool->solvables, SUSETAGS_DESCRDIR,
descrdir);
continue;
}

@@ -324,8 +358,6 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
pd.tmprel = strdup(value);
else if (code11 && istag ("DISTRIBUTION"))
repo_set_str(repo, s - pool->solvables, SOLVABLE_DISTRIBUTION,
value);
- else if (istag ("DATADIR"))
- repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR, value);
else if (istag ("UPDATEURLS"))
add_multiple_urls(data, handle, value, str2id(pool, "update", 1));
else if (istag ("EXTRAURLS"))
@@ -409,9 +441,14 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
pool_debug(pool, SAT_ERROR, "repo_content: malformed line: %s\n", line);
}

+ if (datadir)
+ free(datadir);
+ if (descrdir)
+ free(descrdir);
+
if (!s || !s->name)
{
- pool_debug(pool, SAT_FATAL, "repo_content: 'content' incomplete, no
product solvable created !\n");
+ pool_debug(pool, SAT_FATAL, "repo_content: 'content' incomplete, no
product solvable created!\n");
exit(1);
}

@@ -460,6 +497,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
sat_free(pd.tmp);
sat_free(line);
sat_free(otherarchs);
+ join_freemem();
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
}
diff --git a/src/knownid.h b/src/knownid.h
index 723af5d..62be3ce 100644
--- a/src/knownid.h
+++ b/src/knownid.h
@@ -139,10 +139,11 @@ KNOWNID(SOLVABLE_ORDER,
"solvable:order"),

KNOWNID(UPDATE_REBOOT, "update:reboot"), /* reboot
suggested (kernel update) */
KNOWNID(UPDATE_RESTART, "update:restart"), /*
restart suggested (update stack update) */
-KNOWNID(UPDATE_RELOGIN, "update:relogin"), /*
restart suggested (update stack update) */
+KNOWNID(UPDATE_RELOGIN, "update:relogin"), /*
relogin suggested */

-KNOWNID(UPDATE_MESSAGE, "update:message"), /*
restart suggested (update stack update) */
- /*
'content' of patch, usually list of packages */
+KNOWNID(UPDATE_MESSAGE, "update:message"), /*
informative message */
+
+/* 'content' of patch, usually list of packages */
KNOWNID(UPDATE_COLLECTION, "update:collection"), /*
"name evr arch" */
KNOWNID(UPDATE_COLLECTION_NAME, "update:collection:name"),
/* name */
KNOWNID(UPDATE_COLLECTION_EVR, "update:collection:evr"), /*
epoch:version-release */
@@ -171,6 +172,7 @@ KNOWNID(PRODUCT_REGISTER_RELEASE, "product:regrelease"),

/* argh */
KNOWNID(SUSETAGS_DATADIR, "susetags:datadir"),
+KNOWNID(SUSETAGS_DESCRDIR, "susetags:descrdir"),

/* timestamp then the repository was generated */
KNOWNID(REPOSITORY_TIMESTAMP, "repository:timestamp"),
@@ -207,6 +209,7 @@ KNOWNID(DELTA_SEQ_NAME,
"delta:seqname"),
KNOWNID(DELTA_SEQ_EVR, "delta:seqevr"),
KNOWNID(DELTA_SEQ_NUM, "delta:seqnum"),

+/* XXX: shouldn't use a real ID */
KNOWNID(NAMESPACE_PRODUCTBUDDY, "namespace:productbuddy"),

KNOWNID(REPOSITORY_REPOMD, "repository:repomd"),
diff --git a/tools/susetags2solv.c b/tools/susetags2solv.c
index 9a0325b..8393ba6 100644
--- a/tools/susetags2solv.c
+++ b/tools/susetags2solv.c
@@ -72,6 +72,23 @@ myfopen(const char *fn)
return fopencookie(gzf, "r", cio);
}

+/* content file query */
+static void
+doquery(Pool *pool, Repo *repo, const char *arg)
+{
+ char qbuf[256];
+ const char *str;
+ Id id;
+
+ snprintf(qbuf, sizeof(qbuf), "susetags:%s", arg);
+ id = str2id(pool, qbuf, 0);
+ if (!id)
+ return;
+ str = repo_lookup_str(repo, SOLVID_META, id);
+ if (str)
+ printf("%s\n", str);
+}
+
int
main(int argc, char **argv)
{
@@ -79,11 +96,12 @@ main(int argc, char **argv)
const char *attrname = 0;
const char *descrdir = 0;
const char *basefile = 0;
+ const char *query = 0;
Id product = 0;
int flags = 0;
int c;

- while ((c = getopt(argc, argv, "hkn:c:d:b:")) >= 0)
+ while ((c = getopt(argc, argv, "hkn:c:d:b:q:")) >= 0)
{
switch (c)
{
@@ -105,6 +123,9 @@ main(int argc, char **argv)
case 'b':
basefile = optarg;
break;
+ case 'q':
+ query = optarg;
+ break;
default:
usage(1);
break;
@@ -259,7 +280,11 @@ main(int argc, char **argv)
/* read data from stdin */
repo_add_susetags(repo, stdin, product, 0, REPO_REUSE_REPODATA |
REPO_NO_INTERNALIZE);
repo_internalize(repo);
- tool_write(repo, basefile, attrname);
+
+ if (query)
+ doquery(pool, repo, query);
+ else
+ tool_write(repo, basefile, attrname);
pool_free(pool);
exit(0);
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages