summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-08-13 10:14:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-08-15 14:26:43 +0100
commit1ce0f3f867dad58dad7744f4180975dd42205fcf (patch)
tree107334a5e8269723646373b2f856f26b0531227b /meta/recipes-devtools
parent5c23b3cc9fb6a43d256be3be0b036da752f38164 (diff)
downloadpoky-1ce0f3f867dad58dad7744f4180975dd42205fcf.tar.gz
rpmresolve: improve debug output
Rename rpmresolve's -d option to -t and make -d enable debug output; add a -o option to specify the output file (so rpm debug output doesn't go to the output file) and also add a little more detail to some of the error messages. (From OE-Core rev: 163dd734d79fd7040b48b10bca6fde28460ac20c) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c69
1 files changed, 55 insertions, 14 deletions
diff --git a/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c b/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c
index 568b6891f4..3613ee5a8d 100644
--- a/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c
+++ b/meta/recipes-devtools/rpm/rpmresolve/rpmresolve.c
@@ -36,6 +36,9 @@
36#include <argv.h> 36#include <argv.h>
37#include <mire.h> 37#include <mire.h>
38 38
39int debugmode;
40FILE *outf;
41
39int getPackageStr(rpmts ts, const char *NVRA, rpmTag tag, char **value) 42int getPackageStr(rpmts ts, const char *NVRA, rpmTag tag, char **value)
40{ 43{
41 int rc = -1; 44 int rc = -1;
@@ -69,6 +72,8 @@ int loadTs(rpmts **ts, int *tsct, const char *dblistfn)
69 listfile = 0; 72 listfile = 0;
70 73
71 if(listfile) { 74 if(listfile) {
75 if(debugmode)
76 printf("DEBUG: reading database list file '%s'\n", dblistfn);
72 *ts = malloc(sz * sizeof(rpmts)); 77 *ts = malloc(sz * sizeof(rpmts));
73 FILE *f = fopen(dblistfn, "r" ); 78 FILE *f = fopen(dblistfn, "r" );
74 if(f) { 79 if(f) {
@@ -87,6 +92,8 @@ int loadTs(rpmts **ts, int *tsct, const char *dblistfn)
87 *ts = (rpmts *)realloc(*ts, sz); 92 *ts = (rpmts *)realloc(*ts, sz);
88 } 93 }
89 94
95 if(debugmode)
96 printf("DEBUG: opening database '%s'\n", line);
90 char *dbpathm = malloc(strlen(line) + 10); 97 char *dbpathm = malloc(strlen(line) + 10);
91 sprintf(dbpathm, "_dbpath %s", line); 98 sprintf(dbpathm, "_dbpath %s", line);
92 rpmDefineMacro(NULL, dbpathm, RMIL_CMDLINE); 99 rpmDefineMacro(NULL, dbpathm, RMIL_CMDLINE);
@@ -113,6 +120,8 @@ int loadTs(rpmts **ts, int *tsct, const char *dblistfn)
113 } 120 }
114 } 121 }
115 else { 122 else {
123 if(debugmode)
124 printf("DEBUG: opening database '%s'\n", dblistfn);
116 // Load from single database 125 // Load from single database
117 *ts = malloc(sizeof(rpmts)); 126 *ts = malloc(sizeof(rpmts));
118 char *dbpathm = malloc(strlen(dblistfn) + 10); 127 char *dbpathm = malloc(strlen(dblistfn) + 10);
@@ -164,13 +173,22 @@ int processPackages(rpmts *ts, int tscount, const char *packagelistfn, int ignor
164 char *value = NULL; 173 char *value = NULL;
165 rc = getPackageStr(ts[i], keys[0], RPMTAG_PACKAGEORIGIN, &value); 174 rc = getPackageStr(ts[i], keys[0], RPMTAG_PACKAGEORIGIN, &value);
166 if(rc == 0) 175 if(rc == 0)
167 printf("%s\n", value); 176 fprintf(outf, "%s\n", value);
168 else 177 else
169 fprintf(stderr, "Failed to get package origin for %s\n", line); 178 fprintf(stderr, "Failed to get package origin for %s\n", line);
170 found = 1; 179 found = 1;
171 } 180 }
172 else if( nkeys > 1 ) { 181 else if( nkeys > 1 ) {
173 fprintf(stderr, "Multiple matches for %s!\n", line); 182 int keyindex = 0;
183 fprintf(stderr, "Multiple matches for %s:\n", line);
184 for( keyindex=0; keyindex<nkeys; keyindex++) {
185 char *value = NULL;
186 rc = getPackageStr(ts[i], keys[keyindex], RPMTAG_PACKAGEORIGIN, &value);
187 if(rc == 0)
188 fprintf(outf, " %s\n", value);
189 else
190 fprintf(stderr, " (%s)\n", keys[keyindex]);
191 }
174 } 192 }
175 } 193 }
176 if(found) 194 if(found)
@@ -230,7 +248,7 @@ int printDepList(rpmts *ts, int tscount)
230 int rc = 0; 248 int rc = 0;
231 249
232 if( tscount > 1 ) 250 if( tscount > 1 )
233 printf(">1 database specified with dependency list, using first only\n"); 251 fprintf(stderr, ">1 database specified with dependency list, using first only\n");
234 252
235 /* Get list of names */ 253 /* Get list of names */
236 rpmdb db = rpmtsGetRdb(ts[0]); 254 rpmdb db = rpmtsGetRdb(ts[0]);
@@ -274,17 +292,17 @@ int printDepList(rpmts *ts, int tscount)
274 } 292 }
275 if(prov) { 293 if(prov) {
276 if((int)reqflags[j] & 0x80000) 294 if((int)reqflags[j] & 0x80000)
277 printf("%s|%s [REC]\n", name, prov); 295 fprintf(outf, "%s|%s [REC]\n", name, prov);
278 else 296 else
279 printf("%s|%s\n", name, prov); 297 fprintf(outf, "%s|%s\n", name, prov);
280 } 298 }
281 else { 299 else {
282 rc = lookupProvider(ts[0], reqs[j], &prov); 300 rc = lookupProvider(ts[0], reqs[j], &prov);
283 if(rc==0 && prov) { 301 if(rc==0 && prov) {
284 if((int)reqflags[j] & 0x80000) 302 if((int)reqflags[j] & 0x80000)
285 printf("%s|%s [REC]\n", name, prov); 303 fprintf(outf, "%s|%s [REC]\n", name, prov);
286 else 304 else
287 printf("%s|%s\n", name, prov); 305 fprintf(outf, "%s|%s\n", name, prov);
288 free(prov); 306 free(prov);
289 } 307 }
290 } 308 }
@@ -301,7 +319,7 @@ int printDepList(rpmts *ts, int tscount)
301void usage() 319void usage()
302{ 320{
303 fprintf(stderr, "OpenEmbedded rpm resolver utility\n"); 321 fprintf(stderr, "OpenEmbedded rpm resolver utility\n");
304 fprintf(stderr, "syntax: rpmresolve [-i] [-d] <dblistfile> <packagelistfile>\n"); 322 fprintf(stderr, "syntax: rpmresolve [-i] [-d] [-t] <dblistfile> <packagelistfile>\n");
305} 323}
306 324
307int main(int argc, char **argv) 325int main(int argc, char **argv)
@@ -313,16 +331,26 @@ int main(int argc, char **argv)
313 int c; 331 int c;
314 int ignoremissing = 0; 332 int ignoremissing = 0;
315 int deplistmode = 0; 333 int deplistmode = 0;
334 char *outfile = NULL;
335
336 debugmode = 0;
337 outf = stdout;
316 338
317 opterr = 0; 339 opterr = 0;
318 while ((c = getopt (argc, argv, "id")) != -1) { 340 while ((c = getopt (argc, argv, "itdo:")) != -1) {
319 switch (c) { 341 switch (c) {
320 case 'i': 342 case 'i':
321 ignoremissing = 1; 343 ignoremissing = 1;
322 break; 344 break;
323 case 'd': 345 case 't':
324 deplistmode = 1; 346 deplistmode = 1;
325 break; 347 break;
348 case 'd':
349 debugmode = 1;
350 break;
351 case 'o':
352 outfile = strdup(optarg);
353 break;
326 case '?': 354 case '?':
327 if(isprint(optopt)) 355 if(isprint(optopt))
328 fprintf(stderr, "Unknown option `-%c'.\n", optopt); 356 fprintf(stderr, "Unknown option `-%c'.\n", optopt);
@@ -341,11 +369,18 @@ int main(int argc, char **argv)
341 return 1; 369 return 1;
342 } 370 }
343 371
372 if( outfile ) {
373 if(debugmode)
374 printf("DEBUG: Using output file %s\n", outfile);
375 outf = fopen(outfile, "w");
376 }
377
344 const char *dblistfn = argv[optind]; 378 const char *dblistfn = argv[optind];
345 379
346 rpmcliInit(argc, argv, NULL); 380 rpmcliInit(argc, argv, NULL);
347 381
348 //rpmSetVerbosity(RPMLOG_DEBUG); 382 if(debugmode)
383 rpmSetVerbosity(RPMLOG_DEBUG);
349 384
350 rpmDefineMacro(NULL, "__dbi_txn create nofsync", RMIL_CMDLINE); 385 rpmDefineMacro(NULL, "__dbi_txn create nofsync", RMIL_CMDLINE);
351 386
@@ -363,15 +398,21 @@ int main(int argc, char **argv)
363 else { 398 else {
364 if( argc - optind < 2 ) { 399 if( argc - optind < 2 ) {
365 fprintf(stderr, "Please specify package list file\n"); 400 fprintf(stderr, "Please specify package list file\n");
366 return 1;
367 } 401 }
368 const char *pkglistfn = argv[optind+1]; 402 else {
369 rc = processPackages(ts, tscount, pkglistfn, ignoremissing); 403 const char *pkglistfn = argv[optind+1];
404 rc = processPackages(ts, tscount, pkglistfn, ignoremissing);
405 }
370 } 406 }
371 407
372 for(i=0; i<tscount; i++) 408 for(i=0; i<tscount; i++)
373 (void) rpmtsCloseDB(ts[i]); 409 (void) rpmtsCloseDB(ts[i]);
374 free(ts); 410 free(ts);
375 411
412 if( outfile ) {
413 fclose(outf);
414 free(outfile);
415 }
416
376 return rc; 417 return rc;
377} 418}