Repo *repo;
char *tmp;
int tmpl;
+ Id langcache[ID_NUM_INTERNAL];
};
}
+/*
+ * create epoch:version-release as Id
+ */
+
static Id
makeevr(Pool *pool, char *s)
{
}
+/*
+ * 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
};
*/
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;
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;
*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);
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 == '='))
while (*ptr && (*ptr == ' ' || *ptr == '\t'))
++ptr;
value = ptr;
- while (*ptr && !(*ptr == ' ' || *ptr == '\t'))
- ++ptr;
- *ptr++ = 0;
+ /*
+ * [product]
+ */
+
if (current_section == SECTION_PRODUCT)
{
if (!s)
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);
*/
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;
perror(fullpath);
break;
}
- repo_add_product(&pd, fp);
+ repo_add_product(&pd, repodata, fp);
fclose(fp);
}
}
*/
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];
Id id, *refhash;
unsigned int refmask, h;
int asolv;
- Repodata *repodata;
char dbpath[PATH_MAX];
DB_ENV *dbenv = 0;
DBT dbkey;
if (!rootdir)
rootdir = "";
- repodata = repo_add_repodata(repo, 0);
-
if (ref && !(ref->nsolvables && ref->rpmdbid))
ref = 0;
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)
{
}
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;
if (nrpms <= 0)
return;
- repodata = repo_add_repodata(repo, 0);
+
for (i = 0; i < nrpms; i++)
{
if ((fp = fopen(rpms[i], "r")) == 0)
}
if (rpmhead)
sat_free(rpmhead);
- if (repodata)
- repodata_internalize(repodata);
}
{
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;
* parse arguments
*/
- while ((c = getopt (argc, argv, "xb:r:p:")) >= 0)
+ while ((c = getopt (argc, argv, "nxb:r:p:")) >= 0)
switch (c)
{
case 'r':
case 'b':
basefile = optarg;
break;
+ case 'n':
+ nopacks = 1;
+ break;
case 'p':
proddir = optarg;
break;
*/
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)