Mailinglist Archive: opensuse-buildservice (137 mails)

< Previous Next >
[opensuse-buildservice] Patch: drop "Suggests:" and "Recommends:" if rpm does not know them
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
--
Stefan Seyfried

"For a successful technology, reality must take precedence over
public relations, for nature cannot be fooled." -- Richard Feynman
--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-buildservice+owner@xxxxxxxxxxxx

< Previous Next >