00001
00006 #include "system.h"
00007
00008 #include <rpmio.h>
00009 #include <rpmcli.h>
00010 #include <rpmbuild.h>
00011
00012 #include "build.h"
00013 #include "debug.h"
00014
00015
00016 struct rpmBuildArguments_s rpmBTArgs;
00017
00018 #define POPT_USECATALOG -1011
00019 #define POPT_NOLANG -1012
00020 #define POPT_RMSOURCE -1013
00021 #define POPT_RMBUILD -1014
00022
00023
00024 #define POPT_NOBUILD -1017
00025 #define POPT_SHORTCIRCUIT -1018
00026 #define POPT_RMSPEC -1019
00027 #define POPT_SIGN -1020
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_BT 0x6274
00039 #if defined(RPM_VENDOR_OPENPKG)
00040 #define POPT_BF 0x6266
00041 #endif
00042 #define POPT_TA 0x7461
00043 #define POPT_TB 0x7462
00044 #define POPT_TC 0x7463
00045 #define POPT_TI 0x7469
00046 #define POPT_TL 0x746c
00047 #define POPT_TP 0x7470
00048 #define POPT_TS 0x7473
00049
00050
00051 int _rpmbuildFlags = 3;
00052
00053
00054
00055 int noLang = 0;
00056
00057
00058
00059 static int signIt = 0;
00060
00061
00062 static int useCatalog = 0;
00063
00066 static void buildArgCallback( poptContext con,
00067 enum poptCallbackReason reason,
00068 const struct poptOption * opt,
00069 const char * arg,
00070 const void * data)
00071 {
00072 BTA_t rba = &rpmBTArgs;
00073
00074 switch (opt->val) {
00075 case POPT_REBUILD:
00076 case POPT_RECOMPILE:
00077 case POPT_BA:
00078 case POPT_BB:
00079 case POPT_BC:
00080 case POPT_BI:
00081 case POPT_BL:
00082 case POPT_BP:
00083 case POPT_BS:
00084 case POPT_BT:
00085 #if defined(RPM_VENDOR_OPENPKG)
00086 case POPT_BF:
00087 #endif
00088 case POPT_TA:
00089 case POPT_TB:
00090 case POPT_TC:
00091 case POPT_TI:
00092 case POPT_TL:
00093 case POPT_TP:
00094 case POPT_TS:
00095 if (rba->buildMode == '\0' && rba->buildChar == '\0') {
00096 rba->buildMode = (((unsigned)opt->val) >> 8) & 0xff;
00097 rba->buildChar = (opt->val ) & 0xff;
00098 }
00099 break;
00100
00101 case POPT_NOBUILD: rba->noBuild = 1; break;
00102 case POPT_NOLANG: rba->noLang = 1; break;
00103 case POPT_SHORTCIRCUIT: rba->shortCircuit = 1; break;
00104 case POPT_SIGN: rba->sign = 1; break;
00105 case POPT_USECATALOG: rba->useCatalog = 1; break;
00106 case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
00107 case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
00108 case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
00109
00110 case RPMCLI_POPT_NODIGEST:
00111 rba->qva_flags |= VERIFY_DIGEST;
00112 break;
00113
00114 case RPMCLI_POPT_NOSIGNATURE:
00115 rba->qva_flags |= VERIFY_SIGNATURE;
00116 break;
00117
00118 case RPMCLI_POPT_NOHDRCHK:
00119 rba->qva_flags |= VERIFY_HDRCHK;
00120 break;
00121
00122 case RPMCLI_POPT_NODEPS:
00123 rba->noDeps = 1;
00124 break;
00125
00126 }
00127 }
00128
00131
00132
00133 struct poptOption rpmBuildPoptTable[] = {
00134
00135 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
00136 buildArgCallback, 0, NULL, NULL },
00137
00138
00139 { "bp", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BP,
00140 N_("build through %prep (unpack sources and apply patches) from <specfile>"),
00141 N_("<specfile>") },
00142 { "bc", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BC,
00143 N_("build through %build (%prep, then compile) from <specfile>"),
00144 N_("<specfile>") },
00145 { "bi", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BI,
00146 N_("build through %install (%prep, %build, then install) from <specfile>"),
00147 N_("<specfile>") },
00148 { "bl", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BL,
00149 N_("verify %files section from <specfile>"),
00150 N_("<specfile>") },
00151 { "ba", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BA,
00152 N_("build source and binary packages from <specfile>"),
00153 N_("<specfile>") },
00154 { "bb", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BB,
00155 N_("build binary package only from <specfile>"),
00156 N_("<specfile>") },
00157 { "bs", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_BS,
00158 N_("build source package only from <specfile>"),
00159 N_("<specfile>") },
00160
00161 { "bt", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BT,
00162 N_("track versions of sources from <specfile>"),
00163 N_("<specfile>") },
00164 #if defined(RPM_VENDOR_OPENPKG)
00165 { "bf", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BF,
00166 N_("fetch missing source and patch files"),
00167 N_("<specfile>") },
00168 #endif
00169
00170 { "tp", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TP,
00171 N_("build through %prep (unpack sources and apply patches) from <tarball>"),
00172 N_("<tarball>") },
00173 { "tc", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TC,
00174 N_("build through %build (%prep, then compile) from <tarball>"),
00175 N_("<tarball>") },
00176 { "ti", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TI,
00177 N_("build through %install (%prep, %build, then install) from <tarball>"),
00178 N_("<tarball>") },
00179 { "tl", 0, POPT_ARGFLAG_ONEDASH|POPT_ARGFLAG_DOC_HIDDEN, NULL, POPT_TL,
00180 N_("verify %files section from <tarball>"),
00181 N_("<tarball>") },
00182 { "ta", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TA,
00183 N_("build source and binary packages from <tarball>"),
00184 N_("<tarball>") },
00185 { "tb", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TB,
00186 N_("build binary package only from <tarball>"),
00187 N_("<tarball>") },
00188 { "ts", 0, POPT_ARGFLAG_ONEDASH, NULL, POPT_TS,
00189 N_("build source package only from <tarball>"),
00190 N_("<tarball>") },
00191
00192 { "rebuild", '\0', 0, NULL, POPT_REBUILD,
00193 N_("build binary package from <source package>"),
00194 N_("<source package>") },
00195 { "recompile", '\0', 0, NULL, POPT_RECOMPILE,
00196 N_("build through %install (%prep, %build, then install) from <source package>"),
00197 N_("<source package>") },
00198
00199 { "clean", '\0', 0, NULL, POPT_RMBUILD,
00200 N_("remove build tree when done"), NULL},
00201 { "nobuild", '\0', 0, NULL, POPT_NOBUILD,
00202 N_("do not execute any stages of the build"), NULL },
00203 { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
00204 N_("do not verify build dependencies"), NULL },
00205 { "noautoprov", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, &_rpmbuildFlags, 1,
00206 N_("disable automagic Provides: extraction"), NULL },
00207 { "noautoreq", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, &_rpmbuildFlags, 2,
00208 N_("disable automagic Requires: extraction"), NULL },
00209 { "notinlsb", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &_rpmbuildFlags, 4,
00210 N_("disable tags forbidden by LSB"), NULL },
00211
00212 { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, NULL, RPMCLI_POPT_NODIGEST,
00213 N_("don't verify package digest(s)"), NULL },
00214 { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, NULL, RPMCLI_POPT_NOHDRCHK,
00215 N_("don't verify database header(s) when retrieved"), NULL },
00216 { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, NULL, RPMCLI_POPT_NOSIGNATURE,
00217 N_("don't verify package signature(s)"), NULL },
00218
00219 { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, &noLang, POPT_NOLANG,
00220 N_("do not accept i18n msgstr's from specfile"), NULL},
00221 { "rmsource", '\0', 0, NULL, POPT_RMSOURCE,
00222 N_("remove sources when done"), NULL},
00223 { "rmspec", '\0', 0, NULL, POPT_RMSPEC,
00224 N_("remove specfile when done"), NULL},
00225 { "short-circuit", '\0', 0, NULL, POPT_SHORTCIRCUIT,
00226 N_("skip straight to specified stage (only for c,i)"), NULL },
00227 { "sign", '\0', POPT_ARGFLAG_DOC_HIDDEN, &signIt, POPT_SIGN,
00228 N_("generate PGP/GPG signature"), NULL },
00229 { "target", '\0', POPT_ARG_STRING, NULL, RPMCLI_POPT_TARGETPLATFORM,
00230 N_("override target platform"), N_("CPU-VENDOR-OS") },
00231 { "usecatalog", '\0', POPT_ARGFLAG_DOC_HIDDEN, &useCatalog, POPT_USECATALOG,
00232 N_("look up i18n strings in specfile catalog"), NULL},
00233
00234 POPT_TABLEEND
00235 };
00236