From 8a1ef14e1ec9e32ee24650a543293938cf8e0d23 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Sat, 18 Sep 2021 11:49:25 +0800 Subject: [PATCH] debugedit: add -n, --no-recompute-build-id --- ...-debugedit-add-no_recompute_build_id.patch | 353 ++++++++++++++++++ rpm.spec | 14 +- 2 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 1000-rpm-anolis-debugedit-add-no_recompute_build_id.patch diff --git a/1000-rpm-anolis-debugedit-add-no_recompute_build_id.patch b/1000-rpm-anolis-debugedit-add-no_recompute_build_id.patch new file mode 100644 index 0000000..e8d49ce --- /dev/null +++ b/1000-rpm-anolis-debugedit-add-no_recompute_build_id.patch @@ -0,0 +1,353 @@ +From 6e9fd97f6dba9e04cfd33225b610272b964cc5fc Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sun, 16 Apr 2017 18:16:46 +0200 +Subject: [PATCH] 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. + +[shile] with the initial of rpmbuildid.at backport. + +Signed-off-by: Mark Wielaard +Signed-off-by: Shile Zhang +--- + macros.in | 7 ++- + scripts/find-debuginfo.sh | 16 ++++++- + tests/rpmbuildid.at | 187 ++++++++++++++++++++++++++++++++++++++ + tests/Makefile.am | 1 + + tests/rpmtests.at | 1 + + tools/debugedit.c | 6 +- + 6 files changed, 213 insertions(+), 4 deletions(-) + +diff --git a/macros.in b/macros.in +index f7d16dee1..cf22628d7 100644 +--- a/macros.in ++++ b/macros.in +@@ -180,7 +180,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} %{?_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} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\ + %{nil} + + # Template for debug information sub-package. +@@ -435,6 +435,11 @@ + # + #%_include_minidebuginfo 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 ++ + # + # Use internal dependency generator rather than external helpers? + %_use_internal_dependency_generator 1 +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] ++# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-n] + # [--g-libs] + # [-o debugfiles.list] + # [--run-dwz] [--dwz-low-mem-die-limit N] +@@ -13,6 +13,7 @@ + # The --strict-build-id flag says to exit with failure status if + # any ELF binary processed fails to contain a build-id note. + # The -r flag says to use eu-strip --reloc-debug-sections. ++# 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. +@@ -41,6 +42,9 @@ + # 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= +@@ -71,6 +75,9 @@ + -m) + include_minidebug=true + ;; ++ -n) ++ no_recompute_build_id=true ++ ;; + -o) + if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then + out=$2 +@@ -291,8 +298,12 @@ + fi + + echo "extracting debug info from $f" ++ no_recompute= ++ if [ "$no_recompute_build_id" = "true" ]; then ++ no_recompute="-n" ++ fi + id=$(/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \ +- -i -l "$SOURCEFILE" "$f") || exit ++ $no_recompute -i -l "$SOURCEFILE" "$f") || exit + if [ $nlinks -gt 1 ]; then + eval linkedid_$inum=\$id + fi +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 779b92fb3..96c05ff44 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -19,6 +19,7 @@ TESTSUITE_AT += rpmquery.at + TESTSUITE_AT += rpmverify.at + TESTSUITE_AT += rpmdb.at + TESTSUITE_AT += rpmbuild.at ++TESTSUITE_AT += rpmbuildid.at + TESTSUITE_AT += rpmi.at + TESTSUITE_AT += rpmvercmp.at + TESTSUITE_AT += rpmdeps.at +diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at +new file mode 100644 +index 000000000..88ce22628 100644 +--- /dev/null ++++ b/tests/rpmbuildid.at +@@ -0,0 +1,187 @@ ++# rpmbuild.at: test rpmbuild ++# ++# Copyright (C) 2007 Ralf Corsépius ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ ++AT_BANNER([RPM build]) ++ ++# ------------------------------ ++# Check if rpmbuild -ba *.spec works ++AT_SETUP([rpmbuild -ba *.spec]) ++AT_KEYWORDS([build]) ++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 ++ ++run rpmbuild \ ++ -ba "${abs_srcdir}"/data/SPECS/hello.spec ++], ++[0], ++[ignore], ++[ignore]) ++AT_CLEANUP ++ ++# ------------------------------ ++# Check if rpmbuild --rebuild *.src.rpm works ++AT_SETUP([rpmbuild --rebuild]) ++AT_KEYWORDS([build]) ++AT_CHECK([ ++rm -rf ${TOPDIR} ++ ++run rpmbuild \ ++ --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm ++], ++[0], ++[ignore], ++[ignore]) ++AT_CLEANUP ++ ++# ------------------------------ ++# Check if tar unpacking works ++AT_SETUP([rpmbuild -tb ]) ++AT_KEYWORDS([build]) ++AT_CHECK([ ++rm -rf ${TOPDIR} ++ ++run rpmbuild \ ++ -tb "${RPMDATA}/SOURCES/hello-1.0.tar.gz" ++], ++[1], ++[ignore], ++[error: line 5: Unknown tag: Serial: 1 ++]) ++AT_CLEANUP ++ ++# ------------------------------ ++# Check if tar build works ++# TODO: test that the rpms are actually created... ++AT_SETUP([rpmbuild -tb]) ++AT_KEYWORDS([build]) ++AT_CHECK([ ++rm -rf ${TOPDIR} ++ ++run rpmbuild \ ++ -ta "${RPMDATA}/SOURCES/hello-2.0.tar.gz" ++], ++[0], ++[ignore], ++[ignore]) ++AT_CLEANUP ++ ++# ------------------------------ ++# %attr/%defattr tests ++AT_SETUP([rpmbuild %attr and %defattr]) ++AT_KEYWORDS([build]) ++AT_CHECK([[ ++rm -rf ${TOPDIR} ++ ++runroot rpmbuild \ ++ -bb --quiet /data/SPECS/attrtest.spec ++ ++runroot rpm -qp --qf \ ++ "\n[%{filemodes:perms} %-8{fileusername} %-8{filegroupname} %{filenames}\n]"\ ++ "${TOPDIR}"/RPMS/noarch/attrtest-1.0-1.noarch.rpm ++]], ++[0], ++[ ++drwx------ root root /a/dir ++-r-------- root root /a/file ++drwx------ daemon adm /b/dir ++-r-------- daemon adm /b/file ++drwxr-x--- root adm /c/dir ++-rw-r----- daemon root /c/file ++drwxr-x--x daemon bin /d/dir ++-rw-r--r-- bin daemon /d/file ++drwx------ foo bar /e/dir ++-r-------- foo bar /e/file ++drwxrwx--- bar foo /f/dir ++-rw-rw---- bar foo /f/file ++drwx------ adm foo /g/dir ++-r-------- bar adm /g/file ++drwxr-xr-x foo bar /h/dir ++-rw-r--r-- foo bar /h/file ++drwxr-x--- adm root /i/dir ++-rwsr-xr-x root adm /i/file ++drwxrwxrwx zoot zoot /j/dir ++--w--w--w- zoot zoot /j/file ++], ++[]) ++AT_CLEANUP ++ ++# ------------------------------ ++# hardlink tests ++AT_SETUP([rpmbuild hardlink]) ++AT_KEYWORDS([build]) ++AT_CHECK([ ++RPMDB_CLEAR ++RPMDB_INIT ++rm -rf ${TOPDIR} ++ ++runroot rpmbuild \ ++ -bb --quiet /data/SPECS/hlinktest.spec ++ ++runroot rpm -i "${TOPDIR}"/RPMS/noarch/hlinktest-1.0-1.noarch.rpm ++ ++runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]%{longsize}\n" hlinktest ++runroot rpm -V --nouser --nogroup hlinktest ++ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l ++ ++], ++[0], ++[1 /foo/copyllo ++4 /foo/hello ++4 /foo/hello-bar ++4 /foo/hello-foo ++4 /foo/hello-world ++58 ++1 ++], ++[]) ++AT_CLEANUP ++ ++AT_SETUP([rpmbuild glob]) ++AT_KEYWORDS([build]) ++AT_CHECK([ ++RPMDB_CLEAR ++RPMDB_INIT ++rm -rf ${TOPDIR} ++ ++runroot rpmbuild -bb --quiet /data/SPECS/globtest.spec ++runroot rpm -qp \ ++ --qf "[[%{filemodes:perms} %{filenames}\n]]" \ ++ "${TOPDIR}"/RPMS/noarch/globtest-1.0-1.noarch.rpm ++], ++[0], ++[-rw-r--r-- /opt/globtest/baf ++drwxr-xr-x /opt/globtest/bang ++-rw-r--r-- /opt/globtest/bif ++drwxr-xr-x /opt/globtest/bing ++drwxr-xr-x /opt/globtest/bong ++drwxr-xr-x /opt/globtest/foo ++-rw-r--r-- /opt/globtest/foo/one ++-rw-r--r-- /opt/globtest/foo/three ++-rw-r--r-- /opt/globtest/foo/two ++lrwxrwxrwx /opt/globtest/linkbad ++lrwxrwxrwx /opt/globtest/linkgood ++-rw-r--r-- /opt/globtest/weird%name ++-rw-r--r-- /opt/globtest/zab ++-rw-r--r-- /opt/globtest/zeb ++-rw-r--r-- /opt/globtest/zib ++], ++[]) ++AT_CLEANUP +diff --git a/tests/rpmtests.at b/tests/rpmtests.at +index b51266a2d..5495cced1 100644 +--- a/tests/rpmtests.at ++++ b/tests/rpmtests.at +@@ -4,6 +4,7 @@ m4_include([rpmverify.at]) + m4_include([rpmdb.at]) + m4_include([rpmi.at]) + m4_include([rpmbuild.at]) ++m4_include([rpmbuildid.at]) + m4_include([rpmscript.at]) + m4_include([rpmvercmp.at]) + m4_include([rpmdeps.at]) +diff --git a/tools/debugedit.c b/tools/debugedit.c +index b618dceb5..8444e030e 100644 +--- a/tools/debugedit.c ++++ b/tools/debugedit.c +@@ -54,6 +54,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; + + typedef struct + { +@@ -1296,6 +1297,8 @@ static struct poptOption optionsTable[] = { + "file where to put list of source and header file names", NULL }, + { "build-id", 'i', POPT_ARG_NONE, &do_build_id, 0, + "recompute build ID note and print ID on stdout", 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 } + }; +@@ -1400,7 +1403,8 @@ handle_build_id (DSO *dso, Elf_Data *build_id, + exit (1); + } + +- if (!dirty_elf) ++ if (no_recompute_build_id ++ || !dirty_elf) + goto print; + + if (elf_update (dso->elf, ELF_C_NULL) < 0) diff --git a/rpm.spec b/rpm.spec index cadf92e..89eb227 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 # build against xz? %bcond_without xz # just for giggles, option to build with internal Berkeley DB @@ -21,7 +22,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}48%{?dist} +Release: %{?snapver:0.%{snapver}.}48%{anolis_release}%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://rpm.org/releases/rpm-4.11.x/%{name}-%{srcver}.tar.bz2 @@ -154,6 +155,11 @@ Patch504: rpm-4.11.x-add-g-libs.patch Patch505: rpm-4.11.3-brp-python-bytecompile-Fix-when-default-python-is-no.patch Patch506: rpm-4.11.x-correct-g-libs.patch +# Add by Anolis +# https://github.com/rpm-software-management/rpm/commit/6e9fd97f6dba9e04cfd33225b610272b964cc5fc +Patch1000: 1000-rpm-anolis-debugedit-add-no_recompute_build_id.patch +# End + # Partially GPL/LGPL dual-licensed and some bits with BSD # SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD License: GPLv2+ @@ -431,6 +437,8 @@ Requires: rpm-libs%{_isa} = %{version}-%{release} %patch505 -p1 -b .brp-python-bytecompile %patch506 -p1 -b .fix-g-libs +%patch1000 -p1 -b .anolis + %if %{with int_bdb} ln -s db-%{bdbver} db %endif @@ -661,6 +669,10 @@ exit 0 %doc COPYING doc/librpm/html/* %changelog +* Mon Jul 04 2022 Liwei Ge - 4.11.3-48.0.1 +- debugedit: Add -n, --no-recompute-build-id +- Cherry-pick [1cc07c5] + * Mon Nov 01 2021 Michal Domonkos - 4.11.3-48 - Fix double-free in previously added patch (#2004228) -- Gitee