Mailinglist Archive: opensuse-buildservice (137 mails)

< Previous Next >
Re: [opensuse-buildservice] Patch: drop "Suggests:" and "Recommends:" if rpm does not know them
On 11/14/2015 7:12 AM, Stefan Seyfried wrote:
Hi,

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
+%endif

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"
fi

+ 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/.spec.new" >/dev/null 2>&1 ||
continue
+ 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
+ EOF
+ 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:
'$i'"
+ sed -i -e "/^$i/d" "$BUILD_ROOT/.spec.new"
+ done
+ fi
+ fi
+
# report specfile changes
if test -f $BUILD_ROOT/.spec.new ; then
if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE
$BUILD_ROOT/.spec.new ; then

Have fun,

seife



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

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

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.

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.

Thank you for making this.

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

< Previous Next >
References