From 3462e824f54398fa435f97a32e561074a9160455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= Date: Fri, 19 Apr 2019 21:00:46 +0200 Subject: [PATCH] Disable subpackages checking for scriptlets when building SRPM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #674. Signed-off-by: Robert-André Mauchin --- build/rpmspec.h | 1 + build/spec.c | 6 +++++- python/rpmbmodule.c | 1 + rpmbuild.c | 7 ++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build/rpmspec.h b/build/rpmspec.h index 164c9b6acc..12cce4ed08 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -37,6 +37,7 @@ enum rpmSpecFlags_e { RPMSPEC_FORCE = (1 << 1), RPMSPEC_NOLANG = (1 << 2), RPMSPEC_NOUTF8 = (1 << 3), + RPMSPEC_NOCHECK = (1 << 4), }; typedef rpmFlags rpmSpecFlags; diff --git a/build/spec.c b/build/spec.c index 55095c6ce0..60e88f80e3 100644 --- a/build/spec.c +++ b/build/spec.c @@ -91,9 +91,13 @@ rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg) } if (!(flag & PART_QUIET)) { - if (p == NULL && pkg != NULL) { + if (p == NULL && pkg != NULL && !(spec->flags & RPMSPEC_NOCHECK)) { rpmlog(RPMLOG_ERR, _("line %d: %s: package %s does not exist\n"), spec->lineNum, spec->line, name); + } else if (p == NULL && pkg != NULL && spec->flags & RPMSPEC_NOCHECK) { + rpmlog(RPMLOG_WARNING, _("line %d: %s: package %s does not exist\n"), + spec->lineNum, spec->line, name); + p = spec->packages; } else if (p != NULL && pkg == NULL) { rpmlog(RPMLOG_ERR, _("line %d: %s: package %s already exists\n"), spec->lineNum, spec->line, name); diff --git a/python/rpmbmodule.c b/python/rpmbmodule.c index ad30570e40..b456103f9e 100644 --- a/python/rpmbmodule.c +++ b/python/rpmbmodule.c @@ -49,6 +49,7 @@ static int initModule(PyObject *m) REGISTER_ENUM(RPMSPEC_ANYARCH); REGISTER_ENUM(RPMSPEC_FORCE); REGISTER_ENUM(RPMSPEC_NOLANG); + REGISTER_ENUM(RPMSPEC_NOCHECK); return 1; } diff --git a/rpmbuild.c b/rpmbuild.c index ffb61fc804..3eeace39cf 100644 --- a/rpmbuild.c +++ b/rpmbuild.c @@ -503,7 +503,12 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba) if (_anyarch(buildAmount)) specFlags |= RPMSPEC_ANYARCH; #undef _anyarch - + + /* Don't check the spec subpackage if building the SRPM */ + if (ba->buildAmount == RPMBUILD_PACKAGESOURCE) { + specFlags |= RPMSPEC_NOCHECK; + } + spec = rpmSpecParse(specFile, specFlags, buildRootURL); if (spec == NULL) { goto exit;