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