From 6e9fd97f6dba9e04cfd33225b610272b964cc5fc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 16 Apr 2017 18:16:46 +0200 Subject: debugedit: Add -n, --no-recompute-build-id. Some packages depend on the build-ids as generated during the build and cannot handle rpmbuild recomputing them before generating the package file list. Add -n, --no-recompute-build-id to debugedit and add -n to find-debuginfo.sh set by defining the %_no_recompute_build_ids macro for such packages. %_no_recompute_build_ids can not be used together with %_unique_build_ids. Signed-off-by: Mark Wielaard --- macros.in | 7 ++- scripts/find-debuginfo.sh | 20 +++++++- tests/rpmbuildid.at | 122 ++++++++++++++++++++++++++++++++++++++++++++++ tools/debugedit.c | 6 ++- 4 files changed, 151 insertions(+), 4 deletions(-) diff --git a/macros.in b/macros.in index f7d16dee1..cf22628d7 100644 --- a/macros.in +++ b/macros.in @@ -172,7 +172,7 @@ # the script. See the script for details. # %__debug_install_post \ - %{_rpmconfigdir}/find-debuginfo.sh %{?_smp_mflags} %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{VERSION}-%{RELEASE}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_unique_debug_srcs:--unique-debug-src-base "%{name}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\ + %{_rpmconfigdir}/find-debuginfo.sh %{?_smp_mflags} %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_no_recompute_build_ids:-n} %{?_include_minidebuginfo:-m} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{VERSION}-%{RELEASE}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_unique_debug_srcs:--unique-debug-src-base "%{name}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\ %{nil} # Template for debug information sub-package. @@ -498,6 +498,11 @@ package or when debugging this package.\ # onto debugedit --build-id-seed to be used to prime the build-id note hash. %_unique_build_ids 1 +# Do not recompute build-ids but keep whatever is in the ELF file already. +# Cannot be used together with _unique_build_ids (which forces recomputation). +# Defaults to undefined (unset). +#%_no_recompute_build_ids 1 + # Whether .debug files should be made unique between package version, # release and architecture. If set to 1 this will pass # --unique-debug-arch "%{_arch}" to find-debuginfo.sh to create diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh index 6f38e191b..f7ffbbc2a 100755 --- a/scripts/find-debuginfo.sh +++ b/scripts/find-debuginfo.sh @@ -2,7 +2,7 @@ #find-debuginfo.sh - automagically generate debug info and file list #for inclusion in an rpm spec file. # -# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] +# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n] # [-o debugfiles.list] # [--run-dwz] [--dwz-low-mem-die-limit N] # [--dwz-max-die-limit N] @@ -16,6 +16,7 @@ # The -r flag says to use eu-strip --reloc-debug-sections. # The -m flag says to include a .gnu_debugdata section in the main binary. # The -i flag says to include a .gdb_index section in the .debug file. +# The -n flag says to not recompute the build-id. # # A single -o switch before any -l or -p switches simply renames # the primary output file from debugfiles.list to something else. @@ -56,6 +57,9 @@ include_gdb_index=false # Barf on missing build IDs. strict=false +# Do not recompute build IDs. +no_recompute_build_id=false + # DWZ parameters. run_dwz=false dwz_low_mem_die_limit= @@ -110,6 +114,9 @@ while [ $# -gt 0 ]; do -m) include_minidebug=true ;; + -n) + no_recompute_build_id=true + ;; -i) include_gdb_index=true ;; @@ -159,6 +166,11 @@ if test -z "$unique_debug_arch" -a -n "$unique_debug_src_base"; then exit 2 fi +if test -n "$ver_rel" -a "$no_recompute_build_id" = "true"; then + echo >&2 "*** ERROR: --ver-rel (unique build-ids) and -n (do not recompute build-id cannot be used together" + exit 2 +fi + i=0 while ((i < nout)); do outs[$i]="$BUILDDIR/${outs[$i]}" @@ -324,8 +336,12 @@ do_file() debug_base_name="$BUILDDIR" debug_dest_name="/usr/src/debug/${unique_debug_src_base}-${ver_rel}.${unique_debug_arch}" fi + no_recompute= + if [ "$no_recompute_build_id" = "true" ]; then + no_recompute="-n" + fi id=$(${lib_rpm_dir}/debugedit -b $debug_base_name -d $debug_dest_name \ - -i $build_id_seed -l "$SOURCEFILE" "$f") || exit + $no_recompute -i $build_id_seed -l "$SOURCEFILE" "$f") || exit if [ -z "$id" ]; then echo >&2 "*** ${strict_error}: No build ID note found in $f" $strict && exit 2 diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at index dc47b90c7..88ce22628 100644 --- a/tests/rpmbuildid.at +++ b/tests/rpmbuildid.at @@ -1059,6 +1059,128 @@ debug dup id in debug package []) AT_CLEANUP +# ------------------------------ +# Check build-ids are recomputed with unique_build_ids, +# but not with _no_recompute_build_ids +AT_SETUP([rpmbuild buildid recompute]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Make sure we get debuginfo +export CFLAGS="-g" + +# Unique 1 +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_unique_build_ids 1" \ + --undefine="_no_recompute_build_ids" \ + -ba "${abs_srcdir}"/data/SPECS/hello.spec + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +test -f $hello_file || echo "No $hello_file" +id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/') + +# Make sure we generate a new one +rm $hello_file + +# Unique 2 +# Build the "next" release, which has no changes except for the release update. +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_unique_build_ids 1" \ + --undefine="_no_recompute_build_ids" \ + -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \ + | cpio -diu --quiet + +# Extract the build-id from the main file +test -f $hello_file || echo "No $hello_file" +id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/') + +# Two unique builds should not be equal +if test "$id1" == "$id2"; then + echo "uniques equal"; +else + echo "uniques unequal"; +fi + +# Make sure we generate a new one +rm $hello_file + +# no-recompute 1 +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --undefine="_unique_build_ids" \ + --undefine="_unique_debug_names" \ + --undefine="_unique_debug_srcs" \ + --define="_no_recompute_build_ids 1" \ + -ba "${abs_srcdir}"/data/SPECS/hello.spec + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +test -f $hello_file || echo "No $hello_file" +id3=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/') + +# An unique and no-recompute build should be unequal +if test "$id2" == "$id3"; then + echo "no-recompute unique equal"; +else + echo "no-recompute unique unequal"; +fi + +# Make sure we generate a new one +rm $hello_file + +# no-recompute 2 +# Build the "next" release, which has no changes except for the release update. +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --undefine="_unique_build_ids" \ + --undefine="_unique_debug_names" \ + --undefine="_unique_debug_srcs" \ + --define="_no_recompute_build_ids 1" \ + -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \ + | cpio -diu --quiet + +# Extract the build-id from the main file +test -f $hello_file || echo "No $hello_file" +id4=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/') + +# Two no-recompute builds should be equal. Even for different "releases". +if test "$id3" == "$id4"; then + echo "no-recomputes equal"; +else + echo "no-recomputes unequal"; +fi +], +[0], +[uniques unequal +no-recompute unique unequal +no-recomputes equal +], +[ignore]) +AT_CLEANUP + # ------------------------------ # Check build-ids are unique between versions/releases # with _unique_build_ids defined. diff --git a/tools/debugedit.c b/tools/debugedit.c index b618dceb5..8444e030e 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -85,6 +85,7 @@ char *dest_dir = NULL; char *list_file = NULL; int list_file_fd = -1; int do_build_id = 0; +int no_recompute_build_id = 0; char *build_id_seed = NULL; /* We go over the debug sections in two phases. In phase zero we keep @@ -2261,6 +2262,8 @@ static struct poptOption optionsTable[] = { "recompute build ID note and print ID on stdout", NULL }, { "build-id-seed", 's', POPT_ARG_STRING, &build_id_seed, 0, "if recomputing the build ID note use this string as hash seed", NULL }, + { "no-recompute-build-id", 'n', POPT_ARG_NONE, &no_recompute_build_id, 0, + "do not recompute build ID note even when -i or -s are given", NULL }, POPT_AUTOHELP { NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -2380,7 +2383,8 @@ handle_build_id (DSO *dso, Elf_Data *build_id, exit (1); } - if (!dirty_elf && build_id_seed == NULL) + if (no_recompute_build_id + || (! dirty_elf && build_id_seed == NULL)) goto print; /* Clear the old bits so they do not affect the new hash. */ -- cgit v1.2.1