From a2116dee6e417ff1ed41d25ec08f9a36a5f5c550 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 1 Feb 2008 09:11:41 +0000 Subject: [PATCH] trying to get a translated attribute working --- tools/TODO | 2 +- tools/repo_rpmmd.c | 58 ++++++++++++++++++++------ tools/repo_susetags.c | 39 +----------------- tools/tools_util.h | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+), 51 deletions(-) diff --git a/tools/TODO b/tools/TODO index fccbe72..f2e3395 100644 --- a/tools/TODO +++ b/tools/TODO @@ -1,4 +1,4 @@ dmacvicar TODO - xml metadata: prereq for store - +- what do do with capability kind=atom? need to transform it diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c index 8ea5f31..619861b 100644 --- a/tools/repo_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -30,12 +30,40 @@ enum state { STATE_ARCH, STATE_VERSION, + /* resobject attributes */ STATE_SUMMARY, STATE_DESCRIPTION, - - STATE_FORMAT, + STATE_INSNOTIFY, + STATE_DELNOTIFY, STATE_VENDOR, + STATE_SIZE, + STATE_DOWNLOADSIZE, + STATE_INSTALLTIME, + STATE_INSTALLONLY, + + /* patch */ + STATE_ID, + STATE_TIMESTAMP, + STATE_AFFECTSPKG, + STATE_REBOOTNEEDED, + + // xml store pattern attributes + STATE_CATEGORY, /* pattern and patches */ + STATE_SCRIPT, + STATE_ICON, + STATE_USERVISIBLE, + STATE_DEFAULT, + STATE_INSTALL_TIME, + + /* product */ + STATE_SHORTNAME, + STATE_DISTNAME, + STATE_DISTEDITION, + STATE_SOURCE, + STATE_RELNOTESURL, + STATE_FORMAT, + /* rpm-md dependencies inside the format tag */ STATE_PROVIDES, @@ -81,18 +109,11 @@ enum state { STATE_CAP_ENHANCES, STATE_FILE, - // xml store pattern attributes - STATE_SCRIPT, - STATE_ICON, - STATE_USERVISIBLE, - STATE_CATEGORY, - STATE_DEFAULT, - STATE_INSTALL_TIME, + // general NUMSTATES }; - struct stateswitch { enum state from; char *ename; @@ -112,11 +133,19 @@ static struct stateswitch stateswitches[] = { { STATE_SOLVABLE, "name", STATE_NAME, 1 }, { STATE_SOLVABLE, "arch", STATE_ARCH, 1 }, { STATE_SOLVABLE, "version", STATE_VERSION, 0 }, - { STATE_SOLVABLE, "vendor", STATE_VENDOR, 1 }, + + /* resobject attributes */ { STATE_SOLVABLE, "summary", STATE_SUMMARY, 1 }, { STATE_SOLVABLE, "description", STATE_DESCRIPTION, 1 }, - + //{ STATE_SOLVABLE, "???", STATE_INSNOTIFY, 1 }, + //{ STATE_SOLVABLE, "??", STATE_DELNOTIFY, 1 }, + { STATE_SOLVABLE, "vendor", STATE_VENDOR, 1 }, + { STATE_SOLVABLE, "size", STATE_SIZE, 1 }, + { STATE_SOLVABLE, "archive-size", STATE_DOWNLOADSIZE, 1 }, + { STATE_SOLVABLE, "install-time", STATE_INSTALLTIME, 1 }, + { STATE_SOLVABLE, "install-only", STATE_INSTALLONLY, 1 }, + // xml store pattern attributes { STATE_SOLVABLE, "script", STATE_SCRIPT, 1 }, { STATE_SOLVABLE, "icon", STATE_ICON, 1 }, @@ -531,6 +560,7 @@ startElement(void *userData, const char *name, const char **atts) case STATE_SUMMARY: case STATE_DESCRIPTION: pd->lang = find_attr("lang", atts); + //repodata_set_tstr( pd->data, pd- break; default: break; @@ -673,6 +703,10 @@ repo_add_rpmmd(Repo *repo, FILE *fp) } pd.common.pool = pool; pd.common.repo = repo; + + pd.data = repo_add_repodata(repo); + init_attr_ids(pool); + pd.content = sat_malloc(256); pd.acontent = 256; pd.lcontent = 0; diff --git a/tools/repo_susetags.c b/tools/repo_susetags.c index 2eea198..a89e964 100644 --- a/tools/repo_susetags.c +++ b/tools/repo_susetags.c @@ -79,25 +79,6 @@ adddep(Pool *pool, struct parsedata_common *pd, unsigned int olddeps, char *line #if 0 Attrstore *attr; #endif -static Id id_authors; -static Id id_description; -static Id id_diskusage; -static Id id_downloadsize; -static Id id_eula; -static Id id_group; -static Id id_installsize; -static Id id_keywords; -static Id id_license; -static Id id_messagedel; -static Id id_messageins; -static Id id_mediadir; -static Id id_mediafile; -static Id id_medianr; -static Id id_nosource; -static Id id_source; -static Id id_sourceid; -static Id id_summary; -static Id id_time; static void add_location(struct parsedata *pd, char *line, Solvable *s, unsigned entry) @@ -388,25 +369,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, int with_attr) attr = new_store(pool); #endif data = repo_add_repodata(repo); - id_authors = str2id (pool, "authors", 1); - id_description = str2id (pool, "description", 1); - id_diskusage = str2id (pool, "diskusage", 1); - id_downloadsize = str2id (pool, "downloadsize", 1); - id_eula = str2id (pool, "eula", 1); - id_group = str2id (pool, "group", 1); - id_installsize = str2id (pool, "installsize", 1); - id_keywords = str2id (pool, "keywords", 1); - id_license = str2id (pool, "license", 1); - id_messagedel = str2id (pool, "messagedel", 1); - id_messageins = str2id (pool, "messageins", 1); - id_mediadir = str2id (pool, "mediadir", 1); - id_mediafile = str2id (pool, "mediafile", 1); - id_medianr = str2id (pool, "medianr", 1); - id_nosource = str2id (pool, "nosource", 1); - id_source = str2id (pool, "source", 1); - id_sourceid = str2id (pool, "sourceid", 1); - id_summary = str2id (pool, "summary", 1); - id_time = str2id (pool, "time", 1); + init_attr_ids(pool); } #endif diff --git a/tools/tools_util.h b/tools/tools_util.h index e4a5d17..0a55070 100644 --- a/tools/tools_util.h +++ b/tools/tools_util.h @@ -14,6 +14,9 @@ #ifndef SATSOLVER_TOOLS_UTIL_H #define SATSOLVER_TOOLS_UTIL_H +static char *_join_tmp; +static int _join_tmpl; + struct parsedata_common { char *tmp; int tmpl; @@ -52,6 +55,46 @@ split(char *l, char **sp, int m) return i; } +/* this join does not depend on parsedata */ +static char * +join2(const char *s1, const char *s2, const char *s3) +{ + int l = 1; + char *p; + + if (s1) + l += strlen(s1); + if (s2) + l += strlen(s2); + if (s3) + l += strlen(s3); + if (l > _join_tmpl) + { + _join_tmpl = l + 256; + if (!_join_tmp) + _join_tmp = malloc(_join_tmpl); + else + _join_tmp = realloc(_join_tmp, _join_tmpl); + } + p = _join_tmp; + if (s1) + { + strcpy(p, s1); + p += strlen(s1); + } + if (s2) + { + strcpy(p, s2); + p += strlen(s2); + } + if (s3) + { + strcpy(p, s3); + p += strlen(s3); + } + return _join_tmp; +} + static char * join(struct parsedata_common *pd, const char *s1, const char *s2, const char *s3) { @@ -91,5 +134,72 @@ join(struct parsedata_common *pd, const char *s1, const char *s2, const char *s3 return pd->tmp; } +// packages +static Id id_authors; +static Id id_description; +static Id id_diskusage; +static Id id_eula; +static Id id_group; +static Id id_installsize; +static Id id_keywords; +static Id id_license; +static Id id_messagedel; +static Id id_messageins; +static Id id_mediadir; +static Id id_mediafile; +static Id id_medianr; +static Id id_nosource; +static Id id_source; +static Id id_sourceid; +static Id id_time; + +/* resobject */ +static Id id_summary; +static Id id_description; +// static Id id_insnotify; +// static Id id_delnotify; +static Id id_size; +static Id id_downloadsize; +static Id id_installtime; +static Id id_installonly; + +static void init_attr_ids(Pool *pool) +{ + id_size = str2id(pool, "size", 1);; + id_downloadsize = str2id(pool, "downloadsize", 1);; + id_installtime = str2id(pool, "installtime", 1);; + id_installonly = str2id(pool, "installonly", 1);; + id_summary = str2id(pool, "summary", 1); + + // package + id_authors = str2id(pool, "authors", 1); + id_summary = str2id(pool, "summary", 1); + id_description = str2id(pool, "description", 1); + id_diskusage = str2id(pool, "diskusage", 1); + id_downloadsize = str2id(pool, "downloadsize", 1); + id_eula = str2id(pool, "eula", 1); + id_group = str2id(pool, "group", 1); + id_installsize = str2id(pool, "installsize", 1); + id_keywords = str2id(pool, "keywords", 1); + id_license = str2id(pool, "license", 1); + id_messagedel = str2id(pool, "messagedel", 1); + id_messageins = str2id(pool, "messageins", 1); + id_mediadir = str2id(pool, "mediadir", 1); + id_mediafile = str2id(pool, "mediafile", 1); + id_medianr = str2id(pool, "medianr", 1); + id_nosource = str2id(pool, "nosource", 1); + id_source = str2id(pool, "source", 1); + id_sourceid = str2id(pool, "sourceid", 1); + id_time = str2id(pool, "time", 1); +} + +/* util function to set a translated string */ +void repodata_set_tstr(Repodata *data, Id rid, const char *attrname, const char *lang, const char *str) +{ + Id attrid; + attrid = str2id(data->repo->pool, join2( attrname, ":", lang), 1); + repodata_set_str(data, rid, attrid, str); +} + #endif -- 2.7.4