From d90d5a06005b79aaac51958e3ace31d1eedf1805 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Mon, 6 Aug 2018 23:05:45 -0700 Subject: [PATCH] Add shortcut to --nodebuginfo Currenlty, the incantation to skip creating debuginfo RPMs is: $ rpmbuild -ba --define "debug_package %{nil}" hello.spec Which looks ad-hoc and always requires me to go back and check my notes... This commit adds a shortcut by making it possible to run: $ rpmbuild -ba --nodebuginfo hello.spec Also add test coverage for the new feature. --- rpmpopt.in | 2 ++ tests/rpmbuild.at | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/rpmpopt.in b/rpmpopt.in index eabda881d1..3e44937b46 100644 --- a/rpmpopt.in +++ b/rpmpopt.in @@ -220,6 +220,8 @@ rpmbuild alias --sign \ --POPTdesc=$"generate GPG signature (deprecated, use command rpmsign instead)" # [--trace] "trace macro expansion" rpmbuild alias --trace --eval '%trace' +rpmbuild alias --nodebuginfo --define 'debug_package %{nil}' \ + --POPTdesc=$"do not generate debuginfo for this package" rpmsign alias --key-id --define '_gpg_name !#:+' \ --POPTdesc=$"key id/name to sign with" \ diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at index 28f88e820f..55867523b6 100644 --- a/tests/rpmbuild.at +++ b/tests/rpmbuild.at @@ -567,6 +567,36 @@ test "$canonmultiref" = "$canonmultifile" \ [ignore]) AT_CLEANUP +# ------------------------------ +# Check that rpmbuild creates no debuginfo when --nodebuginfo is passed +AT_SETUP([rpmbuild no debuginfo]) +AT_KEYWORDS([build] [debuginfo]) +AT_CHECK([ +rm -rf ${TOPDIR} + +# Use macros.debug to generate a debuginfo package, +# but pass --nodebuginfo to skip it. +export CFLAGS="-g" +rundebug rpmbuild --quiet --nodebuginfo \ + --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm + +# Extract the main package and inspect the hello binary +# It should not contain .gnu_debugdata, but the full .symtab +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu +test -f ./usr/local/bin/hello || exit 1 +readelf -S ./usr/local/bin/hello |\ + grep -q .gnu_debugdata; test $? == 1 || exit 1 +readelf -S ./usr/local/bin/hello \ + | grep -q .symtab; test $? == 0 || exit 1 + +# And the opposite for the debuginfo package +test ! -e ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm || exit 1 +], +[0], +[], +[ignore]) +AT_CLEANUP + # ------------------------------ # Check if rpmbuild runs dwz and generates a multi file that with shared # debuginfo. This is simply the hello example with one binary build twice