rpm/0024-no-recompute-build-id.patch

272 lines
10 KiB
Diff
Raw Normal View History

commit 8edddd82f855d547bd68ba4d693db497bbbed7ab
Author: Mark Wielaard <mark@klomp.org>
Date: Sat Apr 15 20:31:14 2017 +0200
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 <mark@klomp.org>
diff --git a/macros.in b/macros.in
index f7d16de..cf22628 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 %{?_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 %{?_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 b52822e..86a248d 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]}"
@@ -310,8 +322,12 @@
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 [ $nlinks -gt 1 ]; then
eval linkedid_$inum=\$id
fi
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index dc47b90..88ce226 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -1060,6 +1060,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.
AT_SETUP([rpmbuild buildid unique r1 r2])
diff --git a/tools/debugedit.c b/tools/debugedit.c
index b618dce..8444e03 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. */