- update trpm.
[platform/upstream/rpm.git] / build / poptBT.c
1 /** \ingroup rpmcli
2  * \file lib/poptBT.c
3  *  Popt tables for build modes.
4  */
5
6 #include "system.h"
7
8 #include <rpmcli.h>
9 #include <rpmbuild.h>
10
11 #include "build.h"
12 #include "legacy.h"     /* XXX _noDirTokens */
13 #include "debug.h"
14
15 /*@unchecked@*/
16 struct rpmBuildArguments_s         rpmBTArgs;
17
18 #define POPT_USECATALOG         -1011
19 #define POPT_NOLANG             -1012
20 #define POPT_RMSOURCE           -1013
21 #define POPT_RMBUILD            -1014
22 #define POPT_BUILDROOT          -1015
23 #define POPT_TARGETPLATFORM     -1016
24 #define POPT_NOBUILD            -1017
25 #define POPT_SHORTCIRCUIT       -1018
26 #define POPT_RMSPEC             -1019
27 #define POPT_SIGN               -1020
28
29 #define POPT_REBUILD            0x4220
30 #define POPT_RECOMPILE          0x4320
31 #define POPT_BA                 0x6261
32 #define POPT_BB                 0x6262
33 #define POPT_BC                 0x6263
34 #define POPT_BI                 0x6269
35 #define POPT_BL                 0x626c
36 #define POPT_BP                 0x6270
37 #define POPT_BS                 0x6273
38 #define POPT_TA                 0x7461
39 #define POPT_TB                 0x7462
40 #define POPT_TC                 0x7463
41 #define POPT_TI                 0x7469
42 #define POPT_TL                 0x746c
43 #define POPT_TP                 0x7470
44 #define POPT_TS                 0x7473
45
46 /*@-redecl@*/
47 /*@unchecked@*/
48 extern int _fsm_debug;
49 /*@=redecl@*/
50
51 /*@-exportlocal@*/
52 /*@unchecked@*/
53 int noLang = 0;
54 /*@=exportlocal@*/
55
56 /*@unchecked@*/
57 static int noBuild = 0;
58
59 /*@unchecked@*/
60 static int signIt = 0;
61
62 /*@unchecked@*/
63 static int useCatalog = 0;
64
65 /**
66  */
67 /*@-boundswrite@*/
68 static void buildArgCallback( /*@unused@*/ poptContext con,
69         /*@unused@*/ enum poptCallbackReason reason,
70         const struct poptOption * opt, const char * arg,
71         /*@unused@*/ const void * data)
72 {
73     BTA_t rba = &rpmBTArgs;
74
75     switch (opt->val) {
76     case POPT_REBUILD:
77     case POPT_RECOMPILE:
78     case POPT_BA:
79     case POPT_BB:
80     case POPT_BC:
81     case POPT_BI:
82     case POPT_BL:
83     case POPT_BP:
84     case POPT_BS:
85     case POPT_TA:
86     case POPT_TB:
87     case POPT_TC:
88     case POPT_TI:
89     case POPT_TL:
90     case POPT_TP:
91     case POPT_TS:
92         if (rba->buildMode == '\0' && rba->buildChar == '\0') {
93             rba->buildMode = (((unsigned)opt->val) >> 8) & 0xff;
94             rba->buildChar = (opt->val     ) & 0xff;
95         }
96         break;
97
98     case POPT_NOBUILD: rba->noBuild = 1; break;
99     case POPT_NOLANG: rba->noLang = 1; break;
100     case POPT_SHORTCIRCUIT: rba->shortCircuit = 1; break;
101     case POPT_SIGN: rba->sign = 1; break;
102     case POPT_USECATALOG: rba->useCatalog = 1; break;
103     case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
104     case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
105     case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
106     case POPT_BUILDROOT:
107         if (rba->buildRootOverride) {
108             rpmError(RPMERR_BUILDROOT, _("buildroot already specified, ignoring %s\n"), arg);
109             break;
110         }
111         rba->buildRootOverride = xstrdup(arg);
112         break;
113     case POPT_TARGETPLATFORM:
114         if (rba->targets) {
115             int len = strlen(rba->targets) + 1 + strlen(arg) + 1;
116             rba->targets = xrealloc(rba->targets, len);
117             strcat(rba->targets, ",");
118         } else {
119             rba->targets = xmalloc(strlen(arg) + 1);
120             rba->targets[0] = '\0';
121         }
122         strcat(rba->targets, arg);
123         break;
124
125     case RPMCLI_POPT_NODIGEST:
126         rba->qva_flags |= VERIFY_DIGEST;
127         break;
128
129     case RPMCLI_POPT_NOSIGNATURE:
130         rba->qva_flags |= VERIFY_SIGNATURE;
131         break;
132
133     case RPMCLI_POPT_NOHDRCHK:
134         rba->qva_flags |= VERIFY_HDRCHK;
135         break;
136
137     case RPMCLI_POPT_NODEPS:
138         rba->noDeps = 1;
139         break;
140
141     case RPMCLI_POPT_FORCE:
142         rba->force = 1;
143         break;
144
145     }
146 }
147 /*@=boundswrite@*/
148
149 /**
150  */
151 /*@-bitwisesigned -compmempass @*/
152 /*@unchecked@*/
153 struct poptOption rpmBuildPoptTable[] = {
154 /*@-type@*/ /* FIX: cast? */
155  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
156         buildArgCallback, 0, NULL, NULL },
157 /*@=type@*/
158
159  { "bp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BP,
160         N_("build through %prep (unpack sources and apply patches) from <specfile>"),
161         N_("<specfile>") },
162  { "bc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BC,
163         N_("build through %build (%prep, then compile) from <specfile>"),
164         N_("<specfile>") },
165  { "bi", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BI,
166         N_("build through %install (%prep, %build, then install) from <specfile>"),
167         N_("<specfile>") },
168  { "bl", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BL,
169         N_("verify %files section from <specfile>"),
170         N_("<specfile>") },
171  { "ba", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BA,
172         N_("build source and binary packages from <specfile>"),
173         N_("<specfile>") },
174  { "bb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BB,
175         N_("build binary package only from <specfile>"),
176         N_("<specfile>") },
177  { "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
178         N_("build source package only from <specfile>"),
179         N_("<specfile>") },
180
181  { "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
182         N_("build through %prep (unpack sources and apply patches) from <tarball>"),
183         N_("<tarball>") },
184  { "tc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TC,
185         N_("build through %build (%prep, then compile) from <tarball>"),
186         N_("<tarball>") },
187  { "ti", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TI,
188         N_("build through %install (%prep, %build, then install) from <tarball>"),
189         N_("<tarball>") },
190  { "tl", 0, POPT_ARGFLAG_ONEDASH|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_TL,
191         N_("verify %files section from <tarball>"),
192         N_("<tarball>") },
193  { "ta", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TA,
194         N_("build source and binary packages from <tarball>"),
195         N_("<tarball>") },
196  { "tb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TB,
197         N_("build binary package only from <tarball>"),
198         N_("<tarball>") },
199  { "ts", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TS,
200         N_("build source package only from <tarball>"),
201         N_("<tarball>") },
202
203  { "rebuild", '\0', 0, 0, POPT_REBUILD,
204         N_("build binary package from <source package>"),
205         N_("<source package>") },
206  { "recompile", '\0', 0, 0, POPT_REBUILD,
207         N_("build through %install (%prep, %build, then install) from <source package>"),
208         N_("<source package>") },
209
210  { "buildroot", '\0', POPT_ARG_STRING, 0,  POPT_BUILDROOT,
211         N_("override build root"), "DIRECTORY" },
212  { "clean", '\0', 0, 0, POPT_RMBUILD,
213         N_("remove build tree when done"), NULL},
214  { "dirtokens", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_noDirTokens, 0,
215         N_("generate headers compatible with rpm4 packaging"), NULL},
216  { "force", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmBTArgs.force, RPMCLI_POPT_FORCE,
217         N_("ignore ExcludeArch: directives from spec file"), NULL},
218  { "fsmdebug", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN), &_fsm_debug, -1,
219         N_("debug file state machine"), NULL},
220  { "nobuild", '\0', 0, &noBuild,  POPT_NOBUILD,
221         N_("do not execute any stages of the build"), NULL },
222  { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
223         N_("do not verify build dependencies"), NULL },
224  { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1,
225         N_("generate package header(s) compatible with (legacy) rpm[23] packaging"),
226         NULL},
227
228  { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
229         N_("don't verify package digest(s)"), NULL },
230  { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
231         N_("don't verify database header(s) when retrieved"), NULL },
232  { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
233         N_("don't verify package signature(s)"), NULL },
234
235  { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, &noLang, POPT_NOLANG,
236         N_("do not accept i18N msgstr's from specfile"), NULL},
237  { "rmsource", '\0', 0, 0, POPT_RMSOURCE,
238         N_("remove sources when done"), NULL},
239  { "rmspec", '\0', 0, 0, POPT_RMSPEC,
240         N_("remove specfile when done"), NULL},
241  { "short-circuit", '\0', 0, 0,  POPT_SHORTCIRCUIT,
242         N_("skip straight to specified stage (only for c,i)"), NULL },
243  { "sign", '\0', POPT_ARGFLAG_DOC_HIDDEN, &signIt, POPT_SIGN,
244         N_("generate PGP/GPG signature"), NULL },
245  { "target", '\0', POPT_ARG_STRING, 0,  POPT_TARGETPLATFORM,
246         N_("override target platform"), "CPU-VENDOR-OS" },
247  { "usecatalog", '\0', POPT_ARGFLAG_DOC_HIDDEN, &useCatalog, POPT_USECATALOG,
248         N_("lookup i18N strings in specfile catalog"), NULL},
249
250    POPT_TABLEEND
251 };
252 /*@=bitwisesigned =compmempass @*/