Mailinglist Archive: opensuse-buildservice (137 mails)

< Previous Next >
Re: [opensuse-buildservice] Patch: drop "Suggests:" and "Recommends:" if rpm does not know them
On Monday 16 November 2015, 13:10:21 wrote Brian K. White:
On 11/14/2015 7:12 AM, Stefan Seyfried wrote:

I'm running an OBS instance, used amongst others to build stuff for
multiple distributions (SLES and RHEL, mostly).

Now if I import packages from openSUSE OBS, I often have to patch the
spec file. 95% of these patches are like this:

+%if 0%{?suse_version}
Recommends: not_really_necessary_thing_1
Suggests: totally_unnecessary_thing_2

I automated this task in build-recipe-spec: If the target's RPM does not
know "Recommends:" or "Suggests:", just drop these lines.

This is made configurable with the following prjconf
Buildflags: dropunknownrpmtags

here is the patch for discussion, if this would be interesting for
upstream, I'll prepare a proper pull request.

diff --git a/build-recipe-spec b/build-recipe-spec
index d72a3b7..f92d857 100644
--- a/build-recipe-spec
+++ b/build-recipe-spec
@@ -85,6 +85,40 @@ recipe_prepare_spec() {
test -z "$ABUILD_TARGET" || echo "build target is $ABUILD_TARGET"

+ DROP_UNKNOWN=$(queryconfig --dist "$BUILD_DIST" --configdir
"$CONFIG_DIR" --archpath "$BUILD_ARCH" buildflags dropunknownrpmtags)
+ if [ -n "$DROP_UNKNOWN" ]; then
+ declare -i SUSE_VERSION=$(chroot $BUILD_ROOT rpm --eval
'%{?suse_version}' 2>/dev/null)
+ if ! [ -e "$BUILD_ROOT/usr/bin/rpmbuild" ]; then
+ echo "NOTE: no /usr/bin/rpmbuild in target, no check for
unnown specfile tags"
+ elif ((SUSE_VERSION == 0)); then # just assume that every SUSE
has patched RPM...
+ # echo "SUSE_VERSION is zero"
+ for i in Suggests: Recommends:; do
+ # if no suggests/recommends, then we don't need to test
+ grep "^$i" "$BUILD_ROOT/" >/dev/null 2>&1 ||
+ rm -f "$BUILD_ROOT/.spec.test"
+ cat > "$BUILD_ROOT/.spec.test" <<-EOF
+ $i foo
+ Name: foo
+ Version: 0
+ Release: 0
+ Summary: foo
+ License: WTFPL
+ %description
+ foo
+ UNKNOWN="`chroot $BUILD_ROOT /bin/rpmbuild --nobuild
/.spec.test 2>&1`"
+ # echo "found unknown tag '$UNKNOWN'"
+ RES=$?
+ rm -f "$BUILD_ROOT/.spec.test"
+ test $RES = 0 && continue
+ # echo "nobuild result for $i $RES"
+ echo "WARNING: removing unknown tag on non-SUSE distro:
+ sed -i -e "/^$i/d" "$BUILD_ROOT/"
+ done
+ fi
+ fi
# report specfile changes
if test -f $BUILD_ROOT/ ; then
$BUILD_ROOT/ ; then

Have fun,


Is the original data lost or just not used to build?

it stays untouched in source repository.

If you had these tags in a spec on obs, what is in the spec of the
resulting .src.rpm?

the edited spec file will get packaged.

I think ideally, you want to output a .src.rpm that will build on the
target outside of obs, so *something* has to happen to them rather than
copy the original spec verbatim. But you also don't want to lose data,
and so the removed tags should be converted into comments for those
output src.rpm. Maybe even echo commands to make the comment visible at
install time.

If you use the src.rpm for your target platform you will get the right spec

But it's a tiny point.

I wish obs had this since 5 years ago or really since the first time obs
used an rpm that was newer than any build target.

Same for new convenience macros, though the action isn't usually as easy
as dropping the new/unknown macro. But it is often possible to replace
the new convenience macro with a lower denominator equivalent, or by
including a copy of the macro itself.

OBS is not providing our updating rpm, the distribution content is doing
So, if you want to have macro definitions in old distros, you need to
provide them either via package or prjconf.

Thank you for making this.


Adrian Schroeter
email: adrian@xxxxxxx

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284
(AG Nürnberg)

Maxfeldstraße 5
90409 Nürnberg

To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-buildservice+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups