00001
00006 #include "system.h"
00007
00008 #include "rpmcli.h"
00009 #include "rpmbuild.h"
00010
00011 #include "build.h"
00012 #include "debug.h"
00013
00014
00015 struct rpmBuildArguments_s rpmBTArgs;
00016
00017 #define POPT_USECATALOG -1000
00018 #define POPT_NOLANG -1001
00019 #define POPT_RMSOURCE -1002
00020 #define POPT_RMBUILD -1003
00021 #define POPT_BUILDROOT -1004
00022 #define POPT_TARGETPLATFORM -1007
00023 #define POPT_NOBUILD -1008
00024 #define POPT_SHORTCIRCUIT -1009
00025 #define POPT_RMSPEC -1010
00026 #define POPT_NODEPS -1011
00027 #define POPT_SIGN -1012
00028 #define POPT_FORCE -1013
00029
00030 #define POPT_REBUILD 0x4220
00031 #define POPT_RECOMPILE 0x4320
00032 #define POPT_BA 0x6261
00033 #define POPT_BB 0x6262
00034 #define POPT_BC 0x6263
00035 #define POPT_BI 0x6269
00036 #define POPT_BL 0x626c
00037 #define POPT_BE 0x6245
00038 #define POPT_BP 0x6270
00039 #define POPT_BS 0x6273
00040 #define POPT_TA 0x7461
00041 #define POPT_TB 0x7462
00042 #define POPT_TC 0x7463
00043 #define POPT_TI 0x7469
00044 #define POPT_TL 0x746c
00045 #define POPT_TP 0x7470
00046 #define POPT_TS 0x7473
00047
00048 char *_rpm_nosource;
00049 char *_rpm_nopatch;
00050
00051
00052
00053 extern int _noDirTokens;
00054
00055 extern int _fsm_debug;
00056
00057
00058
00059 static int force = 0;
00060
00061
00062
00063 int noLang = 0;
00064
00065
00066
00067 static int noBuild = 0;
00068
00069
00070 static int noDeps = 0;
00071
00072
00073 static int signIt = 0;
00074
00075
00076 static int useCatalog = 0;
00077
00080 static void buildArgCallback( poptContext con,
00081 enum poptCallbackReason reason,
00082 const struct poptOption * opt, const char * arg,
00083 const void * data)
00084 {
00085 BTA_t rba = &rpmBTArgs;
00086
00087 switch (opt->val) {
00088 case POPT_REBUILD:
00089 case POPT_RECOMPILE:
00090 case POPT_BA:
00091 case POPT_BB:
00092 case POPT_BC:
00093 case POPT_BI:
00094 case POPT_BL:
00095 case POPT_BE:
00096 case POPT_BP:
00097 case POPT_BS:
00098 case POPT_TA:
00099 case POPT_TB:
00100 case POPT_TC:
00101 case POPT_TI:
00102 case POPT_TL:
00103 case POPT_TP:
00104 case POPT_TS:
00105 if (rba->buildMode == ' ') {
00106 rba->buildMode = (((unsigned)opt->val) >> 8) & 0xff;
00107 rba->buildChar = (opt->val ) & 0xff;
00108 }
00109 break;
00110 case POPT_FORCE: rba->force = 1; break;
00111 case POPT_NOBUILD: rba->noBuild = 1; break;
00112 case POPT_NODEPS: rba->noDeps = 1; break;
00113 case POPT_NOLANG: rba->noLang = 1; break;
00114 case POPT_SHORTCIRCUIT: rba->shortCircuit = 1; break;
00115 case POPT_SIGN: rba->sign = 1; break;
00116 case POPT_USECATALOG: rba->useCatalog = 1; break;
00117 case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
00118 case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
00119 case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
00120 case POPT_BUILDROOT:
00121 if (rba->buildRootOverride) {
00122 rpmError(RPMERR_BUILDROOT, _("buildroot already specified, ignoring %s\n"), arg);
00123 break;
00124 }
00125 rba->buildRootOverride = xstrdup(arg);
00126 break;
00127 case POPT_TARGETPLATFORM:
00128 if (rba->targets) {
00129 int len = strlen(rba->targets) + 1 + strlen(arg) + 1;
00130 rba->targets = xrealloc(rba->targets, len);
00131 strcat(rba->targets, ",");
00132 } else {
00133 rba->targets = xmalloc(strlen(arg) + 1);
00134 rba->targets[0] = '\0';
00135 }
00136 strcat(rba->targets, arg);
00137 break;
00138 }
00139 }
00140
00143
00144
00145 struct poptOption rpmBuildPoptTable[] = {
00146
00147 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
00148 buildArgCallback, 0, NULL, NULL },
00149
00150
00151 { "bE", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BE,
00152 N_("preprocess (show macro expansion) <specfile>"),
00153 N_("<specfile>") },
00154 { "bp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BP,
00155 N_("build through %prep (unpack sources and apply patches) from <specfile>"),
00156 N_("<specfile>") },
00157 { "bc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BC,
00158 N_("build through %build (%prep, then compile) from <specfile>"),
00159 N_("<specfile>") },
00160 { "bi", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BI,
00161 N_("build through %install (%prep, %build, then install) from <specfile>"),
00162 N_("<specfile>") },
00163 { "bl", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BL,
00164 N_("verify %files section from <specfile>"),
00165 N_("<specfile>") },
00166 { "ba", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BA,
00167 N_("build source and binary packages from <specfile>"),
00168 N_("<specfile>") },
00169 { "bb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BB,
00170 N_("build binary package only from <specfile>"),
00171 N_("<specfile>") },
00172 { "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
00173 N_("build source package only from <specfile>"),
00174 N_("<specfile>") },
00175
00176 { "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
00177 N_("build through %prep (unpack sources and apply patches) from <tarball>"),
00178 N_("<tarball>") },
00179 { "tc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TC,
00180 N_("build through %build (%prep, then compile) from <tarball>"),
00181 N_("<tarball>") },
00182 { "ti", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TI,
00183 N_("build through %install (%prep, %build, then install) from <tarball>"),
00184 N_("<tarball>") },
00185 { "tl", 0, POPT_ARGFLAG_ONEDASH|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_TL,
00186 N_("verify %files section from <tarball>"),
00187 N_("<tarball>") },
00188 { "ta", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TA,
00189 N_("build source and binary packages from <tarball>"),
00190 N_("<tarball>") },
00191 { "tb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TB,
00192 N_("build binary package only from <tarball>"),
00193 N_("<tarball>") },
00194 { "ts", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TS,
00195 N_("build source package only from <tarball>"),
00196 N_("<tarball>") },
00197
00198 { "rebuild", '\0', 0, 0, POPT_REBUILD,
00199 N_("build binary package from <source package>"),
00200 N_("<source package>") },
00201 { "recompile", '\0', 0, 0, POPT_REBUILD,
00202 N_("build through %install (%prep, %build, then install) from <source package>"),
00203 N_("<source package>") },
00204
00205 { "buildroot", '\0', POPT_ARG_STRING, 0, POPT_BUILDROOT,
00206 N_("override build root"), "DIRECTORY" },
00207 { "clean", '\0', 0, 0, POPT_RMBUILD,
00208 N_("remove build tree when done"), NULL},
00209 { "dirtokens", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_noDirTokens, 0,
00210 N_("generate headers compatible with rpm4 packaging"), NULL},
00211 { "force", '\0', POPT_ARGFLAG_DOC_HIDDEN, &force, POPT_FORCE,
00212 N_("ignore ExcludeArch: directives from spec file"), NULL},
00213 { "fsmdebug", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN), &_fsm_debug, -1,
00214 N_("debug file state machine"), NULL},
00215 { "nobuild", '\0', 0, &noBuild, POPT_NOBUILD,
00216 N_("do not execute any stages of the build"), NULL },
00217 { "nodeps", '\0', 0, &noDeps, POPT_NODEPS,
00218 N_("do not verify build dependencies"), NULL },
00219 { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1,
00220 N_("generate package header(s) compatible with (legacy) rpm[23] packaging"),
00221 NULL},
00222 { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, &noLang, POPT_NOLANG,
00223 N_("do not accept i18N msgstr's from specfile"), NULL},
00224 { "nopatch", '\0', POPT_ARG_STRING, &_rpm_nopatch, 0,
00225 N_("do not include specified patches into source rpm file"), NULL},
00226 { "nosource", '\0', POPT_ARG_STRING, &_rpm_nosource, 0,
00227 N_("do not include specified sources into source rpm file"), NULL},
00228 { "rmsource", '\0', 0, 0, POPT_RMSOURCE,
00229 N_("remove sources when done"), NULL},
00230 { "rmspec", '\0', 0, 0, POPT_RMSPEC,
00231 N_("remove specfile when done"), NULL},
00232 { "short-circuit", '\0', 0, 0, POPT_SHORTCIRCUIT,
00233 N_("skip straight to specified stage (only for c,i)"), NULL },
00234 { "sign", '\0', POPT_ARGFLAG_DOC_HIDDEN, &signIt, POPT_SIGN,
00235 N_("generate PGP/GPG signature"), NULL },
00236 { "target", '\0', POPT_ARG_STRING, 0, POPT_TARGETPLATFORM,
00237 N_("override target platform"), "CPU-VENDOR-OS" },
00238 { "usecatalog", '\0', POPT_ARGFLAG_DOC_HIDDEN, &useCatalog, POPT_USECATALOG,
00239 N_("lookup i18N strings in specfile catalog"), NULL},
00240
00241 POPT_TABLEEND
00242 };
00243