]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-rpmspec.patch
- staring playing with rpm.org
[packages/rpm.git] / rpm-rpmspec.patch
1 diff -urN rpm-5.4.13/build/parseSpec.c rpm-5.4.13-rpmspec/build/parseSpec.c
2 --- rpm-5.4.13/build/parseSpec.c        2013-10-22 20:18:34.483039876 +0200
3 +++ rpm-5.4.13-rpmspec/build/parseSpec.c        2013-10-22 18:52:02.550664732 +0200
4 @@ -474,6 +474,11 @@
5         spec->line[0] = '\0';
6      }
7  
8 +    /* Collect parsed line */
9 +    if (spec->parsed == NULL)
10 +       spec->parsed = rpmiobNew(0);
11 +    spec->parsed = rpmiobAppend(spec->parsed, spec->line, 1);
12 +
13      /*@-compmempass@*/ /* FIX: spec->readStack->next should be dependent */
14      return 0;
15      /*@=compmempass@*/
16 diff -urN rpm-5.4.13/build/rpmspec.h rpm-5.4.13-rpmspec/build/rpmspec.h
17 --- rpm-5.4.13/build/rpmspec.h  2013-10-22 20:18:34.449706143 +0200
18 +++ rpm-5.4.13-rpmspec/build/rpmspec.h  2013-10-22 18:44:37.729692113 +0200
19 @@ -193,6 +193,8 @@
20  /*@only@*/
21      rpmiob clean;              /*!< %clean scriptlet. */
22  
23 +    rpmiob parsed;
24 +
25      size_t nfoo;
26  /*@only@*/ /*@relnull@*/
27      tagStore_t foo;
28 --- rpm-5.4.13/build/spec.c~    2013-07-27 02:16:06.000000000 +0200
29 +++ rpm-5.4.13/build/spec.c     2013-10-23 13:01:36.596670702 +0200
30 @@ -562,6 +562,7 @@
31      spec->install = rpmiobFree(spec->install);
32      spec->check = rpmiobFree(spec->check);
33      spec->clean = rpmiobFree(spec->clean);
34 +    spec->parsed = rpmiobFree(spec->parsed);
35      spec->foo = tagStoreFree(spec->foo, spec->nfoo);
36      spec->nfoo = 0;
37  
38 diff -urN rpm-5.4.13/tools/Makefile.am rpm-5.4.13-rpmspec/tools/Makefile.am
39 --- rpm-5.4.13/tools/Makefile.am        2013-10-22 20:18:34.426372530 +0200
40 +++ rpm-5.4.13-rpmspec/tools/Makefile.am        2013-10-22 20:02:30.365350944 +0200
41 @@ -61,7 +61,7 @@
42  pkgbin_PROGRAMS =      \
43         @WITH_AUGEAS_AUGTOOL@ chroot cp @WITH_CUDF_CUDFTOOL@ find mtree \
44         @WITH_SEMANAGE_SEMODULE@ wget \
45 -       rpmcache rpmdigest rpmrepo rpmspecdump \
46 +       rpmcache rpmdigest rpmrepo rpmspecdump rpmspec \
47         rpmcmp rpmdeps sqlite3 @WITH_KEYUTILS_RPMKEY@ @WITH_LIBELF_DEBUGEDIT@
48  if WITH_DB
49  pkgbin_PROGRAMS +=     dbconvert
50 @@ -195,6 +195,9 @@
51  rpmspecdump_SOURCES =  rpmspecdump.c
52  rpmspecdump_LDADD =    $(RPMBUILD_LDADD_COMMON)
53  
54 +rpmspec_SOURCES =      rpmspec.c
55 +rpmspec_LDADD =        $(RPMBUILD_LDADD_COMMON)
56 +
57  semodule_SOURCES =     semodule.c
58  semodule_LDADD =       $(RPMIO_LDADD_COMMON)
59  
60 diff -urN rpm-5.4.13/tools/rpmspec.c rpm-5.4.13-rpmspec/tools/rpmspec.c
61 --- rpm-5.4.13/tools/rpmspec.c  1970-01-01 01:00:00.000000000 +0100
62 +++ rpm-5.4.13-rpmspec/tools/rpmspec.c  2013-10-22 20:00:06.075242852 +0200
63 @@ -0,0 +1,176 @@
64 +#include "system.h"
65 +const char *__progname;
66 +
67 +#define        _AUTOHELP
68 +
69 +#if defined(IAM_RPM) || defined(__LCLINT__)
70 +#define        IAM_RPMBT
71 +#define        IAM_RPMDB
72 +#define        IAM_RPMEIU
73 +#define        IAM_RPMQV
74 +#define        IAM_RPMK
75 +#endif
76 +
77 +#include <rpmio.h>
78 +#include <rpmiotypes.h>
79 +#include <poptIO.h>
80 +
81 +#include <rpmtypes.h>
82 +#include <rpmtag.h>
83 +#include "rpmdb.h"
84 +
85 +#include "rpmversion.h"
86 +#include "rpmps.h"
87 +#include "rpmts.h"
88 +
89 +#include <rpmbuild.h>
90 +
91 +#ifdef IAM_RPMBT
92 +#include "build.h"
93 +#define GETOPT_REBUILD         1003
94 +#define GETOPT_RECOMPILE       1004
95 +#endif
96 +
97 +#include <rpmcli.h>
98 +
99 +#include "debug.h"
100 +
101 +enum modes {
102 +    MODE_UNKNOWN       = 0,
103 +    MODE_QUERY         = (1 <<  0),
104 +    MODE_PARSE         = (1 <<  1),
105 +};
106 +
107 +static int mode = MODE_UNKNOWN;
108 +static rpmQVSources source = RPMQV_RPM;
109 +static const char *target = NULL;
110 +static char *queryformat = NULL;
111 +
112 +static struct poptOption specOptsTable[] = {
113 +    { "parse", 'P', POPT_ARG_VAL, &mode, MODE_PARSE,
114 +       N_("parse spec file(s) to stdout"), NULL },
115 +    { "query", 'q', POPT_ARG_VAL, &mode, MODE_QUERY,
116 +       N_("query spec file(s)"), NULL },
117 +    { "rpms", 0, POPT_ARG_VAL, &source, RPMQV_RPM,
118 +       N_("operate on binary rpms generated by spec (default)"), NULL },
119 +    { "srpm", 0, POPT_ARG_VAL, &source, RPMQV_SPECSRPM,
120 +       N_("operate on source rpm generated by spec"), NULL },
121 +    { "target", 0, POPT_ARG_STRING, &target, 0,
122 +       N_("override target platform"), NULL },
123 +    { "queryformat", 0, POPT_ARG_STRING, &queryformat, 0,
124 +       N_("use the following query format"), "QUERYFORMAT" },
125 +    { "qf", 0, (POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN), &queryformat, 0,
126 +       NULL, NULL },
127 +    POPT_TABLEEND
128 +};
129 +
130 +/* the structure describing the options we take and the defaults */
131 +static struct poptOption optionsTable[] = {
132 +    { NULL, '\0', POPT_ARG_INCLUDE_TABLE, specOptsTable, 0,
133 +       N_("Spec options:"), NULL },
134 +
135 +    { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
136 +       N_("Common options for all rpm modes and executables:"), NULL },
137 +
138 +   POPT_AUTOALIAS
139 +   POPT_AUTOHELP
140 +   POPT_TABLEEND
141 +};
142 +
143 +/*@exits@*/ static void argerror(const char * desc)
144 +       /*@globals __assert_program_name, fileSystem @*/
145 +       /*@modifies fileSystem @*/
146 +{
147 +    fprintf(stderr, _("%s: %s\n"), __progname, desc);
148 +    exit(EXIT_FAILURE);
149 +}
150 +
151 +#ifdef DYING /* XXX rpmIsVerbose alone stops usage spewage with every --eval */
152 +static void printVersion(FILE * fp)
153 +       /*@globals rpmEVR, fileSystem @*/
154 +       /*@modifies *fp, fileSystem @*/
155 +{
156 +    fprintf(fp, "%s (" RPM_NAME ") %s\n", __progname, rpmEVR);
157 +    if (rpmIsVerbose())
158 +       fprintf(fp, "rpmlib 0x%08x,0x%08x,0x%08x\n",
159 +           rpmlibVersion(), rpmlibTimestamp(), rpmlibVendor());
160 +}
161 +
162 +static void printUsage(poptContext con, FILE * fp, int flags)
163 +       /*@globals rpmEVR, fileSystem, internalState @*/
164 +       /*@modifies *fp, fileSystem, internalState @*/
165 +{
166 +    printVersion(fp);
167 +    fprintf(fp, "\n");
168 +
169 +    if (rpmIsVerbose())
170 +       poptPrintHelp(con, fp, flags);
171 +    else
172 +       poptPrintUsage(con, fp, flags);
173 +}
174 +#endif
175 +
176 +int main(int argc, char *argv[])
177 +{
178 +    rpmts ts = NULL;
179 +    QVA_t qva = &rpmQVKArgs;
180 +
181 +    poptContext optCon;
182 +    int ec = 0;
183 +
184 +    optCon = rpmcliInit(argc, argv, optionsTable);
185 +
186 +    if (target) {
187 +       rpmFreeMacros(NULL);
188 +       rpmFreeRpmrc();
189 +        rpmcliConfigured();
190 +    }
191 +
192 +    ts = rpmtsCreate();
193 +    switch (mode) {
194 +
195 +    case MODE_QUERY:
196 +       if (!poptPeekArg(optCon))
197 +           argerror(_("no arguments given for query"));
198 +
199 +       qva->qva_queryFormat = queryformat;
200 +       qva->qva_source = source;
201 +       qva->qva_specQuery = rpmspecQuery;
202 +       ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
203 +       break;
204 +
205 +    case MODE_PARSE: {
206 +       const char * spath;
207 +       if (!poptPeekArg(optCon))
208 +           argerror(_("no arguments given for parse"));
209 +
210 +       while ((spath = poptGetArg(optCon)) != NULL) {
211 +           int ret = parseSpec(ts, spath, "/", 0, NULL, NULL, 1, 1, 0);
212 +           if (ret != 0) {
213 +               ec++;
214 +               continue;
215 +           }
216 +           Spec spec = rpmtsSpec(ts);
217 +           fprintf(stdout, "%s", rpmiobStr(spec->parsed));
218 +       }
219 +       break;
220 +    }
221 +
222 +    case MODE_UNKNOWN:
223 +#ifdef DYING /* XXX rpmIsVerbose alone stops usage spewage with every --eval */
224 +       if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
225 +           printUsage(optCon, stderr, 0);
226 +           ec = argc;
227 +       }
228 +#endif
229 +       break;
230 +    }
231 +
232 +    rpmtsFree(ts);
233 +
234 +    free(qva->qva_queryFormat);
235 +
236 +    rpmcliFini(optCon);
237 +
238 +    return ec;
239 +}
This page took 0.045554 seconds and 3 git commands to generate.