From 20ad566d609bccdadf871dab1bc31a0e243f8710 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 23 Jul 2012 07:59:11 +0100 Subject: buildhistory: improve performance of image info collection Reduce the number of calls to the packaging tool, especially in the case of rpm, using helper utilities to gather the required information more efficiently where possible. (From OE-Core rev: d0b8a98c5b46c305afd389fc862b3bf0c6f1eaab) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c | 117 ++++++++++++++++++++-- 1 file changed, 110 insertions(+), 7 deletions(-) (limited to 'meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c') diff --git a/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c b/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c index 9f6cdf28b8..2d9ed141f4 100644 --- a/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c +++ b/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c @@ -204,10 +204,104 @@ int processPackages(rpmts *ts, int tscount, const char *packagelistfn, int ignor return rc; } +int lookupProvider(rpmts ts, const char *req, char **provider) +{ + int rc = 0; + rpmmi provmi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, req, 0); + if(provmi) { + Header h; + if ((h = rpmmiNext(provmi)) != NULL) { + HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he)); + he->tag = RPMTAG_NAME; + rc = (headerGet(h, he, 0) != 1); + if(rc==0) + *provider = strdup((char *)he->p.ptr); + } + (void)rpmmiFree(provmi); + } + else { + rc = -1; + } + return rc; +} + +int printDepList(rpmts *ts, int tscount) +{ + int rc = 0; + + if( tscount > 1 ) + printf(">1 database specified with dependency list, using first only\n"); + + /* Get list of names */ + rpmdb db = rpmtsGetRdb(ts[0]); + ARGV_t names = NULL; + rc = rpmdbMireApply(db, RPMTAG_NAME, + RPMMIRE_STRCMP, NULL, &names); + int nnames = argvCount(names); + + /* Get list of NVRAs */ + ARGV_t keys = NULL; + rc = rpmdbMireApply(db, RPMTAG_NVRA, + RPMMIRE_STRCMP, NULL, &keys); + if (keys) { + int i, j; + HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he)); + int nkeys = argvCount(keys); + for(i=0; itag = RPMTAG_NAME; + rc = (headerGet(h, he, 0) != 1); + char *name = strdup((char *)he->p.ptr); + /* Get its requires */ + he->tag = RPMTAG_REQUIRENAME; + rc = (headerGet(h, he, 0) != 1); + ARGV_t reqs = (ARGV_t)he->p.ptr; + /* Get its requireflags */ + he->tag = RPMTAG_REQUIREFLAGS; + rc = (headerGet(h, he, 0) != 1); + rpmuint32_t *reqflags = (rpmuint32_t *)he->p.ui32p; + for(j=0; jc; j++) { + int k; + char *prov = NULL; + for(k=0; k \n"); + fprintf(stderr, "syntax: rpmresolve [-i] [-d] \n"); } int main(int argc, char **argv) @@ -218,13 +312,17 @@ int main(int argc, char **argv) int i; int c; int ignoremissing = 0; + int deplistmode = 0; opterr = 0; - while ((c = getopt (argc, argv, "i")) != -1) { + while ((c = getopt (argc, argv, "id")) != -1) { switch (c) { case 'i': ignoremissing = 1; break; + case 'd': + deplistmode = 1; + break; case '?': if(isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt); @@ -258,12 +356,17 @@ int main(int argc, char **argv) return 1; } - if( argc - optind < 2 ) { - fprintf(stderr, "Please specify package list file\n"); - return 1; + if(deplistmode) { + rc = printDepList(ts, tscount); + } + else { + if( argc - optind < 2 ) { + fprintf(stderr, "Please specify package list file\n"); + return 1; + } + const char *pkglistfn = argv[optind+1]; + rc = processPackages(ts, tscount, pkglistfn, ignoremissing); } - const char *pkglistfn = argv[optind+1]; - rc = processPackages(ts, tscount, pkglistfn, ignoremissing); for(i=0; i