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