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