SOURCES: poldek-op-ldalldesc.patch (NEW) - API addition: new internal optio...
megabajt
megabajt at pld-linux.org
Wed Aug 20 23:39:17 CEST 2008
Author: megabajt Date: Wed Aug 20 21:39:17 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- API addition: new internal option (POLDEK_OP_LDALLDESC) required by PackageKit
to get localized summaries and descriptions
---- Files affected:
SOURCES:
poldek-op-ldalldesc.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/poldek-op-ldalldesc.patch
diff -u /dev/null SOURCES/poldek-op-ldalldesc.patch:1.1
--- /dev/null Wed Aug 20 23:39:18 2008
+++ SOURCES/poldek-op-ldalldesc.patch Wed Aug 20 23:39:11 2008
@@ -0,0 +1,276 @@
+commit c9bfac52591027f6f87de0663d120ce26fe6b56a
+Author: Marcin Banasiak <megabajt at pld-linux.org>
+Date: Thu Aug 7 10:47:03 2008 +0200
+
+ - added POLDEK_OP_LDALLDESC; loading of all i18n descriptions can be forced now.
+
+diff --git a/lib_pkgset.c b/lib_pkgset.c
+index ef7ecb4..bea738a 100644
+--- a/lib_pkgset.c
++++ b/lib_pkgset.c
+@@ -63,6 +63,9 @@ int poldek__load_sources_internal(struct poldek_ctx *ctx)
+
+ if (ctx->ts->getop(ctx->ts, POLDEK_OP_LDFULLFILELIST))
+ ldflags |= PKGDIR_LD_FULLFLIST;
++
++ if (ctx->ts->getop(ctx->ts, POLDEK_OP_LDALLDESC))
++ ldflags |= PKGDIR_LD_ALLDESC;
+
+ #if 0 /* XXX now files are loaded on demand */
+ if (strcmp(pm_get_name(ctx->pmctx), "pset") == 0)
+diff --git a/pkgdir/dir/dir.c b/pkgdir/dir/dir.c
+index 2aa7e65..0b720c1 100644
+--- a/pkgdir/dir/dir.c
++++ b/pkgdir/dir/dir.c
+@@ -159,7 +159,6 @@ struct pkguinf *load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+ Header h;
+
+ ptr = ptr; /* unused pkgdir_data */
+- langs = langs; /* ignored, selective retrieving no supported */
+
+ snprintf(path, sizeof(path), "%s/%s", pkg->pkgdir->idxpath,
+ pkg_filename_s(pkg));
+@@ -172,7 +171,7 @@ struct pkguinf *load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+ return NULL;
+ }
+
+- pkgu = pkguinf_ldrpmhdr(na, h);
++ pkgu = pkguinf_ldrpmhdr(na, h, langs);
+
+ pm_rpmhdr_free(h);
+ return pkgu;
+@@ -269,7 +268,7 @@ int load_dir(struct pkgdir *pkgdir,
+ pkg->groupid = pkgroup_idx_update_rpmhdr(pkgroups, h);
+
+ if (ldflags & PKGDIR_LD_DESC) {
+- pkg->pkg_pkguinf = pkguinf_ldrpmhdr(na, h);
++ pkg->pkg_pkguinf = pkguinf_ldrpmhdr(na, h, NULL);
+ pkg_set_ldpkguinf(pkg);
+ }
+ }
+diff --git a/pkgdir/hdrl/hdrl.c b/pkgdir/hdrl/hdrl.c
+index 495e363..5d7a1b8 100644
+--- a/pkgdir/hdrl/hdrl.c
++++ b/pkgdir/hdrl/hdrl.c
+@@ -106,7 +106,7 @@ static int do_load(struct pkgdir *pkgdir, unsigned ldflags)
+
+ if ((pkg = pm_rpm_ldhdr(pkgdir->na, h, NULL, 0, PKG_LDWHOLE))) {
+ if (ldflags & PKGDIR_LD_DESC) {
+- pkg->pkg_pkguinf = pkguinf_ldrpmhdr(pkgdir->na, h);
++ pkg->pkg_pkguinf = pkguinf_ldrpmhdr(pkgdir->na, h, NULL);
+ pkg_set_ldpkguinf(pkg);
+ }
+
+diff --git a/pkgdir/pkgdir.c b/pkgdir/pkgdir.c
+index 634a2a4..ca2d7a8 100644
+--- a/pkgdir/pkgdir.c
++++ b/pkgdir/pkgdir.c
+@@ -496,7 +496,6 @@ struct pkgdir *pkgdir_open_ext(const char *path, const char *pkg_prefix,
+ n_array_sort(pkgdir->depdirs);
+ }
+
+- pkgdir->flags |= flags;
+ return pkgdir;
+ }
+
+diff --git a/pkgdir/pkgdir.h b/pkgdir/pkgdir.h
+index e1c88d0..7535d16 100644
+--- a/pkgdir/pkgdir.h
++++ b/pkgdir/pkgdir.h
+@@ -108,6 +108,9 @@ struct pkgdir *pkgdir_open(const char *path, const char *pkg_prefix,
+ #define PKGDIR_LD_NOUNIQ (1 << 3) /* don't perform pkgdir_uniq() */
+ #define PKGDIR_LD_DOIGNORE (1 << 4) /* honour src->ign_patterns */
+ #define PKGDIR_LD_DIRINDEX (1 << 5) /* handle rpm 4.4.6 auto deps */
++#define PKGDIR_LD_ALLDESC (1 << 6) /* load all i18n descriptions
++ (see PKGDIR_OPEN_ALLDESC)
++ */
+
+ int pkgdir_load(struct pkgdir *pkgdir, tn_array *depdirs, unsigned ldflags);
+
+diff --git a/pkgdir/rpmdb/rpmdb.c b/pkgdir/rpmdb/rpmdb.c
+index 635e354..b602a07 100644
+--- a/pkgdir/rpmdb/rpmdb.c
++++ b/pkgdir/rpmdb/rpmdb.c
+@@ -110,9 +110,8 @@ struct pkguinf *load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+ struct pkguinf *pkgu = NULL;
+ Header h;
+
+- langs = langs; /* ignored, no support */
+ if ((h = ldhdr(pkg, ptr))) {
+- pkgu = pkguinf_ldrpmhdr(na, h);
++ pkgu = pkguinf_ldrpmhdr(na, h, langs);
+ pm_rpmhdr_free(h);
+ }
+
+diff --git a/pkgdir/rpmdb/rpmdbcache.c b/pkgdir/rpmdb/rpmdbcache.c
+index 224b4b3..70a25ce 100644
+--- a/pkgdir/rpmdb/rpmdbcache.c
++++ b/pkgdir/rpmdb/rpmdbcache.c
+@@ -134,11 +134,9 @@ struct pkguinf *dbcache_load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+ {
+ struct pkguinf *pkgu = NULL;
+ Header h;
+-
+- langs = langs; /* ignored, no support */
+
+ if ((h = ldhdr(pkg, ptr))) {
+- pkgu = pkguinf_ldrpmhdr(na, h);
++ pkgu = pkguinf_ldrpmhdr(na, h, langs);
+ pm_rpmhdr_free(h);
+ }
+
+diff --git a/pkgdir/yum/yum.c b/pkgdir/yum/yum.c
+index a7e48d7..f3e5c36 100644
+--- a/pkgdir/yum/yum.c
++++ b/pkgdir/yum/yum.c
+@@ -269,7 +269,7 @@ struct pkg *do_loadpkg(tn_alloc *na, Header h, int ldflags, const char *pkgfn)
+ struct pkg *pkg;
+ if ((pkg = pm_rpm_ldhdr(na, h, pkgfn, 0, PKG_LDWHOLE))) {
+ if (ldflags & PKGDIR_LD_DESC) {
+- pkg->pkg_pkguinf = pkguinf_ldrpmhdr(na, h);
++ pkg->pkg_pkguinf = pkguinf_ldrpmhdr(na, h, NULL);
+ pkg_set_ldpkguinf(pkg);
+ }
+ }
+@@ -287,7 +287,6 @@ struct pkguinf *load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+ char path[PATH_MAX], *hdrpath;
+ Header h;
+
+- langs = langs; /* ignored, no support */
+ if (!pkg->pkgdir)
+ return NULL;
+
+@@ -297,7 +296,7 @@ struct pkguinf *load_pkguinf(tn_alloc *na, const struct pkg *pkg,
+
+ pkg = pkg;
+ if ((h = do_loadrpmhdr(path, vfmode, n_basenam(path)))) {
+- pkgu = pkguinf_ldrpmhdr(na, h);
++ pkgu = pkguinf_ldrpmhdr(na, h, langs);
+ headerFree(h);
+ }
+
+diff --git a/pkgset-load.c b/pkgset-load.c
+index f2f0d3c..7ac3762 100644
+--- a/pkgset-load.c
++++ b/pkgset-load.c
+@@ -32,9 +32,13 @@
+ int pkgset_load(struct pkgset *ps, int ldflags, tn_array *sources)
+ {
+ int i, j, iserr = 0;
++ unsigned openflags = 0;
+
+ n_array_isort_ex(sources, (tn_fn_cmp)source_cmp_pri);
+
++ if (ldflags & PKGDIR_LD_ALLDESC)
++ openflags |= PKGDIR_OPEN_ALLDESC;
++
+ for (i=0; i < n_array_size(sources); i++) {
+ struct source *src = n_array_nth(sources, i);
+ struct pkgdir *pkgdir = NULL;
+@@ -47,7 +51,7 @@ int pkgset_load(struct pkgset *ps, int ldflags, tn_array *sources)
+ source_set_type(src, poldek_conf_PKGDIR_DEFAULT_TYPE);
+
+
+- pkgdir = pkgdir_srcopen(src, 0);
++ pkgdir = pkgdir_srcopen(src, openflags);
+
+ /* trying dir */
+ if (pkgdir == NULL && !source_is_type(src, "dir") &&
+@@ -56,7 +60,7 @@ int pkgset_load(struct pkgset *ps, int ldflags, tn_array *sources)
+ logn(LOGNOTICE, _("trying to scan directory %s..."), src->path);
+
+ source_set_type(src, "dir");
+- pkgdir = pkgdir_srcopen(src, 0);
++ pkgdir = pkgdir_srcopen(src, openflags);
+ }
+
+ if (pkgdir == NULL) {
+diff --git a/pkgu.c b/pkgu.c
+index 6ea077e..26bb647 100644
+--- a/pkgu.c
++++ b/pkgu.c
+@@ -639,7 +639,7 @@ char *load_changelog_from_rpmhdr(tn_alloc *na, void *hdr)
+ return changelog;
+ }
+
+-struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr)
++struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr, tn_array *loadlangs)
+ {
+ tn_array *langs;
+ char **summs, **descrs;
+@@ -653,7 +653,7 @@ struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr)
+
+ if ((langs = pm_rpmhdr_langs(h))) {
+ tn_array *sl_langs = NULL;
+- char *sl_lang;
++ char *lc_lang, *sl_lang;
+
+ pm_rpmhdr_get_raw_entry(h, RPMTAG_SUMMARY, (void*)&summs, &nsumms);
+ pm_rpmhdr_get_raw_entry(h, RPMTAG_DESCRIPTION, (void*)&descrs, &ndescrs);
+@@ -685,7 +685,23 @@ struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr)
+ langs = n_array_remove_nth(langs, i - 1);
+ }
+
+- sl_langs = lc_lang_select(langs, lc_messages_lang());
++ if (loadlangs) {
++ for (i = 0; i < n_array_size(loadlangs); i++) {
++ const char *loadlang = n_array_nth(loadlangs, i);
++
++ if (loadlang == NULL)
++ continue;
++
++ if (lc_lang == NULL)
++ lc_lang = n_strdup(loadlang);
++ else {
++ lc_lang = n_str_concat(lc_lang, ":", loadlang, NULL);
++ }
++ }
++ } else
++ lc_lang = n_strdup(lc_messages_lang());
++
++ sl_langs = lc_lang_select(langs, lc_lang);
+ if (sl_langs == NULL)
+ sl_lang = "C";
+ else
+@@ -703,6 +719,7 @@ struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr)
+ n_array_free(langs);
+ n_array_cfree(&sl_langs);
+
++ free(lc_lang);
+ free(summs);
+ free(descrs);
+ }
+@@ -1160,7 +1177,7 @@ struct pkguinf *pkguinf_restore_rpmhdr_st(tn_alloc *na,
+ }
+
+ if ((hdr = headerLoad(rawhdr)) != NULL) {
+- pkgu = pkguinf_ldrpmhdr(na, hdr);
++ pkgu = pkguinf_ldrpmhdr(na, hdr, NULL);
+ headerFree(hdr); //rpm's memleak
+ }
+
+diff --git a/pkgu.h b/pkgu.h
+index 9a7bb86..2ced69a 100644
+--- a/pkgu.h
++++ b/pkgu.h
+@@ -41,7 +41,7 @@ int pkguinf_skip_rpmhdr(tn_stream *st);
+ struct pkguinf *pkguinf_restore_rpmhdr_st(tn_alloc *na,
+ tn_stream *st, off_t offset);
+
+-struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr);
++struct pkguinf *pkguinf_ldrpmhdr(tn_alloc *na, void *hdr, tn_array *loadlangs);
+
+ tn_buf *pkguinf_store(const struct pkguinf *pkgu, tn_buf *nbuf,
+ const char *lang);
+diff --git a/poldek_ts.h b/poldek_ts.h
+index ab43ccf..b98cfe8 100644
+--- a/poldek_ts.h
++++ b/poldek_ts.h
+@@ -41,6 +41,7 @@ enum poldek_ts_opt {
+ POLDEK_OP_VRFY_FILEMISSDEPS, /* --verify=file-missing-deps */
+ POLDEK_OP_DEPGRAPH, /* --dependency-graph */
+
++ POLDEK_OP_LDALLDESC, /* internal, load all i18n descriptions */
+ POLDEK_OP_LDFULLFILELIST, /* internal, load whole file database */
+
+ POLDEK_OP_VRFYMERCY, /* --mercy */
================================================================
More information about the pld-cvs-commit
mailing list