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