summaryrefslogtreecommitdiff
path: root/rpmbuild.c
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2018-10-26 10:30:47 +0200
committerPanu Matilainen <pmatilai@redhat.com>2019-05-28 09:24:01 +0300
commit58dcfddc376a7c97de1432f0082be0d5f01adbcd (patch)
treed015a68d0dc7d2e6baede42b5fb159e322190344 /rpmbuild.c
parentd0754b4f2c97203e593152ba8ef14d8370ace6f5 (diff)
downloadrpm-58dcfddc376a7c97de1432f0082be0d5f01adbcd.tar.gz
Add support for dynamic BuildRequires
Supports new %generate_buildrequires section in the spec file which is executed after %prep. Stdout is captured and turned into BuildRequires. These are then checked. If they cannot be fulfilled a source package is created with all BuildRequires and the build is terminated after that. rpmbuild has now the following new build modes -br, -tr, -rr and exits with 11 if build requirements are not met. That means for users: * No %generate_buildrequires * rpmbuild -br is equivalent to rpmbuild -bs * rpmbuild -br --nodeps is equivalent to rpmbuild -bs * %generate_buildrequires * rpmbuild -br will check dynamic BuildRequires * Satisfied → src.rpm * Unsatisfied → buildreqs.nosrc.rpm * rpmbuild -br --nodeps will always generate buildreqs.nosrc.rpm Source packages contain Requires: rpmlib(DynamicBuildRequires) <= 4.15.0-1 if the spec contains a %generate_buildrequires section and Provide: rpmlib(DynamicBuildRequires) = 4.15.0-1 if the results been added to the source package. Co-authored-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'rpmbuild.c')
-rw-r--r--rpmbuild.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/rpmbuild.c b/rpmbuild.c
index 1e23b4ae3..1e0dc2253 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -38,6 +38,7 @@ static struct rpmBuildArguments_s rpmBTArgs;
#define POPT_BL 0x626c
#define POPT_BP 0x6270
#define POPT_BS 0x6273
+#define POPT_BR 0x6272
#define POPT_RA 0x4261
#define POPT_RB 0x4262
#define POPT_RC 0x4263
@@ -45,6 +46,7 @@ static struct rpmBuildArguments_s rpmBTArgs;
#define POPT_RL 0x426c
#define POPT_RP 0x4270
#define POPT_RS 0x4273
+#define POPT_RR 0x4272
#define POPT_TA 0x7461
#define POPT_TB 0x7462
#define POPT_TC 0x7463
@@ -52,6 +54,7 @@ static struct rpmBuildArguments_s rpmBTArgs;
#define POPT_TL 0x746c
#define POPT_TP 0x7470
#define POPT_TS 0x7473
+#define POPT_TR 0x7472
extern int _fsm_debug;
@@ -81,6 +84,7 @@ static void buildArgCallback( poptContext con,
case POPT_BL:
case POPT_BP:
case POPT_BS:
+ case POPT_BR:
case POPT_RA:
/* case POPT_RB: same value as POPT_REBUILD */
case POPT_RC:
@@ -88,6 +92,7 @@ static void buildArgCallback( poptContext con,
case POPT_RL:
case POPT_RP:
case POPT_RS:
+ case POPT_RR:
case POPT_TA:
case POPT_TB:
case POPT_TC:
@@ -95,6 +100,7 @@ static void buildArgCallback( poptContext con,
case POPT_TL:
case POPT_TP:
case POPT_TS:
+ case POPT_TR:
if (opt->val == POPT_BS || opt->val == POPT_TS)
noDeps = 1;
if (buildMode == '\0' && buildChar == '\0') {
@@ -156,6 +162,9 @@ static struct poptOption rpmBuildPoptTable[] = {
{ "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
N_("build source package only from <specfile>"),
N_("<specfile>") },
+ { "br", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BR,
+ N_("build source package only from <specfile> - calculate dynamic build requires"),
+ N_("<specfile>") },
{ "rp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RP,
N_("build through %prep (unpack sources and apply patches) from <source package>"),
@@ -178,6 +187,9 @@ static struct poptOption rpmBuildPoptTable[] = {
{ "rs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RS,
N_("build source package only from <source package>"),
N_("<source package>") },
+ { "rr", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RR,
+ N_("build source package only from <source package> - calculate dynamic build requires"),
+ N_("<source package>") },
{ "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
N_("build through %prep (unpack sources and apply patches) from <tarball>"),
@@ -200,7 +212,9 @@ static struct poptOption rpmBuildPoptTable[] = {
{ "ts", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TS,
N_("build source package only from <tarball>"),
N_("<tarball>") },
-
+ { "tr", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TR,
+ N_("build source package only from <tarball> - calculate dynamic build requires"),
+ N_("<tarball>") },
{ "rebuild", '\0', 0, 0, POPT_REBUILD,
N_("build binary package from <source package>"),
N_("<source package>") },
@@ -623,7 +637,9 @@ int main(int argc, char *argv[])
break;
case 'c':
ba->buildAmount |= RPMBUILD_BUILD;
+ ba->buildAmount |= RPMBUILD_BUILDREQUIRES;
if (!noDeps) {
+ ba->buildAmount |= RPMBUILD_DUMPBUILDREQUIRES;
ba->buildAmount |= RPMBUILD_CHECKBUILDREQUIRES;
}
if ((buildChar == 'c') && shortCircuit)
@@ -634,6 +650,12 @@ int main(int argc, char *argv[])
case 'l':
ba->buildAmount |= RPMBUILD_FILECHECK;
break;
+ case 'r':
+ ba->buildAmount |= RPMBUILD_PREP;
+ ba->buildAmount |= RPMBUILD_BUILDREQUIRES;
+ ba->buildAmount |= RPMBUILD_DUMPBUILDREQUIRES;
+ if (!noDeps)
+ ba->buildAmount |= RPMBUILD_CHECKBUILDREQUIRES;
case 's':
ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
break;