[Rpm-maint] [PATCH v2] Allow '--short-circuit' for '-bb'
Michal Schmidt
mschmidt at redhat.com
Mon Jun 21 15:20:02 UTC 2010
This patch allows short-circuiting of building binary packages. To
prevent accidental use of short-circuited rpms, they are marked with
an unsatisfiable dependency "rpmlib(ShortCircuited)". A developer using
this feature for local development and testing will use "--nodeps".
Should such a rpm leak into the world, users will quickly notice
it does not install by default.
Warning: This adds a parameter to packageBinaries() which is a part of
the public API, I believe.
diff --git a/build/build.c b/build/build.c
index c3295b9..36b8154 100644
--- a/build/build.c
+++ b/build/build.c
@@ -265,7 +265,7 @@ rpmRC buildSpec(rpmts ts, rpmSpec spec, int what, int test)
return rc;
if (((what & RPMBUILD_PACKAGEBINARY) && !test) &&
- (rc = packageBinaries(spec)))
+ (rc = packageBinaries(spec, !(what & RPMBUILD_INSTALL))))
goto exit;
if ((what & RPMBUILD_CLEAN) &&
diff --git a/build/pack.c b/build/pack.c
index c7622cc..3b94003 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -714,7 +714,7 @@ rpmRC checkPackages(char *pkgcheck)
return RPMRC_OK;
}
-rpmRC packageBinaries(rpmSpec spec)
+rpmRC packageBinaries(rpmSpec spec, int shortCircuited)
{
struct cpioSourceArchive_s csabuf;
CSA_t csa = &csabuf;
@@ -753,6 +753,10 @@ rpmRC packageBinaries(rpmSpec spec)
if (spec->sourcePkgId != NULL) {
headerPutBin(pkg->header, RPMTAG_SOURCEPKGID, spec->sourcePkgId,16);
}
+
+ if (shortCircuited) {
+ (void) rpmlibNeedsFeature(pkg->header, "ShortCircuited", "4.9.0-1");
+ }
{ char *binFormat = rpmGetPath("%{_rpmfilename}", NULL);
char *binRpm, *binDir;
diff --git a/build/rpmbuild.h b/build/rpmbuild.h
index c7d0da3..17091c4 100644
--- a/build/rpmbuild.h
+++ b/build/rpmbuild.h
@@ -421,9 +421,10 @@ rpmRC checkPackages(char *pkgcheck);
/** \ingroup rpmbuild
* Generate binary package(s).
* @param spec spec file control structure
+ * @param shortCircuited mark the package(s) as short-circuited
* @return RPMRC_OK on success
*/
-rpmRC packageBinaries(rpmSpec spec);
+rpmRC packageBinaries(rpmSpec spec, int shortCircuited);
/** \ingroup rpmbuild
* Generate source package.
diff --git a/doc/rpmbuild.8 b/doc/rpmbuild.8
index 6ad5bf1..5854c7e 100644
--- a/doc/rpmbuild.8
+++ b/doc/rpmbuild.8
@@ -170,8 +170,10 @@ used standalone, eg. "\fBrpmbuild\fR \fB--rmspec foo.spec\fR").
.TP
\fB--short-circuit\fR
Skip straight to specified stage (i.e., skip all stages leading
-up to the specified stage). Only valid with \fB-bc\fR
-and \fB-bi\fR.
+up to the specified stage). Only valid with \fB-bc\fR, \fB-bi\fR
+or \fB-bb\fR. Useful for local testing only. Packages built this
+way will be marked with an unsatisfiable dependency to prevent
+their accidental use.
.TP
\fB--sign\fR
Embed a GPG signature in the package. This signature can be used
diff --git a/rpmqv.c b/rpmqv.c
index be2707c..6104e2f 100644
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -660,6 +660,8 @@ int main(int argc, char *argv[])
case 'b':
ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
ba->buildAmount |= RPMBUILD_CLEAN;
+ if ((ba->buildChar == 'b') && ba->shortCircuit)
+ break;
case 'i':
ba->buildAmount |= RPMBUILD_INSTALL;
ba->buildAmount |= RPMBUILD_CHECK;
More information about the Rpm-maint
mailing list