1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
From 3bf20a6116ae3e1a5a3a6907bee7e881b17efb2f Mon Sep 17 00:00:00 2001
From: Peter Kjellerstedt <pkj@axis.com>
Date: Mon, 15 May 2017 11:23:26 +0200
Subject: [PATCH 13/13] Add a new option --alldeps to rpmdeps
This will send the output from rpmfcPrint() to stdout. This is an
alternative to using the --rpmfcdebug option, which will send the same
output to stderr. The two options have totally different use cases
though. While --alldeps is used when the output from rpmfcPrint() is
what is wanted, --rpmfcdebug can be used together with the other
output options, e.g., --requires, without affecting their output.
Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/220]
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
build/rpmfc.c | 27 ++++++++++++++-------------
build/rpmfc.h | 1 -
tools/rpmdeps.c | 44 +++++++++++++++++++++++++-------------------
3 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index c8e2f876a..44f1cdc9a 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -732,7 +732,6 @@ static rpm_color_t rpmfcColor(const char * fmstr)
void rpmfcPrint(const char * msg, rpmfc fc, FILE * fp)
{
- rpm_color_t fcolor;
int ndx;
int dx;
int fx;
@@ -744,21 +743,23 @@ void rpmfcPrint(const char * msg, rpmfc fc, FILE * fp)
if (fc)
for (fx = 0; fx < fc->nfiles; fx++) {
- rpmsid cx = fc->fcdictx[fx] + 1; /* id's are one off */
- fcolor = fc->fcolor[fx];
- ARGV_t fattrs = fc->fattrs[fx];
-
fprintf(fp, "%3d %s", fx, fc->fn[fx]);
- if (fcolor != RPMFC_BLACK)
+ if (_rpmfc_debug) {
+ rpmsid cx = fc->fcdictx[fx] + 1; /* id's are one off */
+ rpm_color_t fcolor = fc->fcolor[fx];
+ ARGV_t fattrs = fc->fattrs[fx];
+
+ if (fcolor != RPMFC_BLACK)
fprintf(fp, "\t0x%x", fc->fcolor[fx]);
- else
+ else
fprintf(fp, "\t%s", rpmstrPoolStr(fc->cdict, cx));
- if (fattrs) {
- char *attrs = argvJoin(fattrs, ",");
- fprintf(fp, " [%s]", attrs);
- free(attrs);
- } else {
- fprintf(fp, " [none]");
+ if (fattrs) {
+ char *attrs = argvJoin(fattrs, ",");
+ fprintf(fp, " [%s]", attrs);
+ free(attrs);
+ } else {
+ fprintf(fp, " [none]");
+ }
}
fprintf(fp, "\n");
diff --git a/build/rpmfc.h b/build/rpmfc.h
index dae8ea5b1..3d87b31cf 100644
--- a/build/rpmfc.h
+++ b/build/rpmfc.h
@@ -45,7 +45,6 @@ typedef const struct rpmfcTokens_s * rpmfcToken;
/** \ingroup rpmfc
* Print results of file classification.
- * @todo Remove debugging routine.
* @param msg message prefix (NULL for none)
* @param fc file classifier
* @param fp output file handle (NULL for stderr)
diff --git a/tools/rpmdeps.c b/tools/rpmdeps.c
index a414b6343..f260a38c4 100644
--- a/tools/rpmdeps.c
+++ b/tools/rpmdeps.c
@@ -23,6 +23,8 @@ static int print_conflicts;
static int print_obsoletes;
+static int print_alldeps;
+
static void rpmdsPrint(const char * msg, rpmds ds, FILE * fp)
{
if (fp == NULL) fp = stderr;
@@ -57,6 +59,8 @@ static struct poptOption optionsTable[] = {
NULL, NULL },
{ "obsoletes", '\0', POPT_ARG_VAL, &print_obsoletes, -1,
NULL, NULL },
+ { "alldeps", '\0', POPT_ARG_VAL, &print_alldeps, -1,
+ NULL, NULL },
POPT_AUTOALIAS
POPT_AUTOHELP
@@ -100,25 +104,27 @@ main(int argc, char *argv[])
if (rpmfcClassify(fc, av, NULL) || rpmfcApply(fc))
goto exit;
- if (_rpmfc_debug)
- rpmfcPrint(buf, fc, NULL);
-
- if (print_provides)
- rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
- if (print_requires)
- rpmdsPrint(NULL, rpmfcRequires(fc), stdout);
- if (print_recommends)
- rpmdsPrint(NULL, rpmfcRecommends(fc), stdout);
- if (print_suggests)
- rpmdsPrint(NULL, rpmfcSuggests(fc), stdout);
- if (print_supplements)
- rpmdsPrint(NULL, rpmfcSupplements(fc), stdout);
- if (print_enhances)
- rpmdsPrint(NULL, rpmfcEnhances(fc), stdout);
- if (print_conflicts)
- rpmdsPrint(NULL, rpmfcConflicts(fc), stdout);
- if (print_obsoletes)
- rpmdsPrint(NULL, rpmfcObsoletes(fc), stdout);
+ if (print_alldeps || _rpmfc_debug)
+ rpmfcPrint(NULL, fc, print_alldeps ? stdout : NULL);
+
+ if (!print_alldeps) {
+ if (print_provides)
+ rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
+ if (print_requires)
+ rpmdsPrint(NULL, rpmfcRequires(fc), stdout);
+ if (print_recommends)
+ rpmdsPrint(NULL, rpmfcRecommends(fc), stdout);
+ if (print_suggests)
+ rpmdsPrint(NULL, rpmfcSuggests(fc), stdout);
+ if (print_supplements)
+ rpmdsPrint(NULL, rpmfcSupplements(fc), stdout);
+ if (print_enhances)
+ rpmdsPrint(NULL, rpmfcEnhances(fc), stdout);
+ if (print_conflicts)
+ rpmdsPrint(NULL, rpmfcConflicts(fc), stdout);
+ if (print_obsoletes)
+ rpmdsPrint(NULL, rpmfcObsoletes(fc), stdout);
+ }
ec = 0;
--
2.12.0
|