# poptBT.c

Go to the documentation of this file.

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