summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpmdeps-oecore.patch
blob: 1667901b63c825a41a469f505f3a99c49e6d471e (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
Add an "rpmdeps-oecore" binary which allows batch processing of individual file
dependencies in a similar manner to rpmdeps --provides --requires -v, prefixing
each line of output with the filename that has the dependency.

This is much faster than individually calling rpmdeps on each file.

This binary is used by package.bbclass.

Upstream-Status: Inappropriate [OE Specific]

RP 2012/2/7

---
 tools/Makefile.am      |    6 ++-
 tools/rpmdeps-oecore.c |  147 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+), 1 deletions(-)
 create mode 100644 tools/rpmdeps-oecore.c

diff --git a/tools/Makefile.am b/tools/Makefile.am
index f520843..2eba9bf 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -58,7 +58,7 @@ pkgbin_PROGRAMS =	\
 	@WITH_AUGEAS_AUGTOOL@ chroot cp @WITH_CUDF_CUDFTOOL@ find mtree \
 	@WITH_SEMANAGE_SEMODULE@ wget \
 	rpmcache rpmdigest rpmrepo rpmspecdump \
-	rpmcmp rpmdeps sqlite3 @WITH_KEYUTILS_RPMKEY@ @WITH_LIBELF_DEBUGEDIT@
+	rpmcmp rpmdeps rpmdeps-oecore sqlite3 @WITH_KEYUTILS_RPMKEY@ @WITH_LIBELF_DEBUGEDIT@
 dist_man_MANS =		rpmgrep.1
 
 augtool_SOURCES =	augtool.c
@@ -155,6 +155,10 @@ rpmdeps_SOURCES =	rpmdeps.c
 rpmdeps_LDFLAGS =	@LDFLAGS_STATIC@ $(LDFLAGS)
 rpmdeps_LDADD =		$(RPM_LDADD_COMMON)
 
+rpmdeps_oecore_SOURCES =  rpmdeps-oecore.c
+rpmdeps_oecore_LDFLAGS =  @LDFLAGS_STATIC@ $(LDFLAGS)
+rpmdeps_oecore_LDADD =    $(RPM_LDADD_COMMON)
+
 rpmdigest_SOURCES =	rpmdigest.c
 rpmdigest_LDFLAGS =	@LDFLAGS_STATIC@ $(LDFLAGS)
 rpmdigest_LDADD =	$(RPMIO_LDADD_COMMON)
diff --git a/tools/rpmdeps-oecore.c b/tools/rpmdeps-oecore.c
new file mode 100644
index 0000000..e646da9
--- /dev/null
+++ b/tools/rpmdeps-oecore.c
@@ -0,0 +1,147 @@
+#include "system.h"
+const char *__progname;
+
+#include <rpmio.h>
+#include <rpmiotypes.h>
+#include <rpmcb.h>
+#include <argv.h>
+#include <rpmtypes.h>
+#include <rpmtag.h>
+
+#include <rpmds.h>
+#define   _RPMFC_INTERNAL     /* XXX for debugging */
+#include <rpmfc.h>
+
+#include <rpmcli.h>
+
+#include "debug.h"
+
+/*@unchecked@*/
+char *progname;
+
+#define   RPMDEP_RPMFC        1
+
+static int rpmdepPrint(char *filename, rpmds ds, FILE * fp)
+{
+    if (fp == NULL) fp = stderr;
+
+    ds = rpmdsInit(ds);
+    while (rpmdsNext(ds) >= 0) {
+  fprintf(fp, "%s %s: %s\n", filename, rpmdsType(ds), rpmdsDNEVR(ds)+2);
+    }
+    return 0;
+}
+
+static struct poptOption optionsTable[] = {
+
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
+  N_("Common options:"),
+  NULL }, 
+
+   POPT_AUTOALIAS
+   POPT_AUTOHELP
+   POPT_TABLEEND
+};
+
+
+int
+main(int argc, char *argv[])
+{
+    poptContext optCon;
+    ARGV_t av = NULL;
+    rpmfc fc = NULL;
+    FILE * fp = NULL;
+    int flags = 0;
+    int ac = 0;
+    int ec = 1;
+    int xx;
+    int i;
+    char buf[BUFSIZ];
+    int nddict;
+    const char * s;
+    char * se;
+    const char * fn;
+    const char * N;
+    const char * EVR;
+    evrFlags Flags;
+    unsigned char deptype;
+    int ix;
+    rpmds ds;
+
+/*@-modobserver@*/
+    if ((progname = strrchr(argv[0], '/')) != NULL)
+  progname++;
+    else
+  progname = argv[0];
+/*@=modobserver@*/
+
+    optCon = rpmcliInit(argc, argv, optionsTable);
+    if (optCon == NULL)
+  goto exit;
+
+    av = poptGetArgs(optCon);
+    ac = argvCount(av);
+
+    if (ac == 0) {
+  av = NULL;
+  xx = argvFgets(&av, NULL);
+  ac = argvCount(av);
+    }
+
+    /* Make sure file names are sorted. */
+    xx = argvSort(av, NULL);
+
+    /* Build file class dictionary. */
+    fc = rpmfcNew();
+    xx = rpmfcClassify(fc, av, NULL);
+
+    /* Build file/package dependency dictionary. */
+    xx = rpmfcApply(fc);
+
+    /* Generate per-file indices into package dependencies. */
+    nddict = argvCount(fc->ddict);
+
+    for (i = 0; i < nddict; i++) {
+  s = fc->ddict[i];
+
+  /* Parse out (file#,deptype,N,EVR,Flags) */
+  ix = strtol(s, &se, 10);
+  assert(se != NULL);
+  deptype = *se++;
+  se++;
+  N = se;
+  while (*se && *se != ' ')
+      se++;
+  *se++ = '\0';
+  EVR = se;
+  while (*se && *se != ' ')
+      se++;
+  *se++ = '\0';
+  Flags = strtol(se, NULL, 16);
+
+  switch (deptype) {
+  default:
+      /*@switchbreak@*/ break;
+  case 'P':   
+      ds = rpmdsSingle(RPMTAG_PROVIDENAME, N, EVR, Flags);
+      rpmdepPrint((char *)fc->fn[ix], ds, stdout);
+      (void)rpmdsFree(ds);
+      ds = NULL;
+      /*@switchbreak@*/ break;
+  case 'R':
+      ds = rpmdsSingle(RPMTAG_REQUIRENAME, N, EVR, Flags);
+      rpmdepPrint((char *)fc->fn[ix], ds, stdout);
+      (void)rpmdsFree(ds);
+      ds = NULL;
+      /*@switchbreak@*/ break;
+  }
+    }
+
+    fc = rpmfcFree(fc);
+
+    ec = 0;
+
+exit:
+    optCon = rpmcliFini(optCon);
+    return ec;
+}
-- 
1.7.4.1