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