Rebase to rpm 4.13.90 aka 4.14.0-alpha (#1474836)

This commit is contained in:
Panu Matilainen 2017-08-10 14:20:12 +03:00
parent 4341d10fdf
commit 353b5cc65e
67 changed files with 29 additions and 11931 deletions

View File

@ -1,23 +0,0 @@
From 3936d5a227dfcfd502588c6fd8f52ccb826f11c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Wed, 20 Apr 2016 15:39:36 +0200
Subject: [PATCH] Use correct source file for rpmsign module
(cherry picked from commit eb632e5158fa4ef993b0e5df2a354f0be7a7a71d)
---
python/setup.py.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/setup.py.in b/python/setup.py.in
index b2c394136..f94873fe5 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -48,7 +48,7 @@ rpmbuild_mod = Extension('rpm._rpmb',
)
rpmsign_mod = Extension('rpm._rpms',
- sources = ['rpmbmodule.c'],
+ sources = ['rpmsmodule.c'],
include_dirs = pkgconfig('--cflags'),
libraries = pkgconfig('--libs') + ['rpmsign'],
extra_compile_args = cflags,

View File

@ -1,47 +0,0 @@
From aa74f749e8eba102069aaafd0b2e18af8f5f0fa0 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Tue, 14 Feb 2017 14:04:35 +0100
Subject: [PATCH] brp-python-bytecompile: Process python lib dirs even without
standard Python
There is no need for /usr/bin/python when byte compiling files in
/usr/lib/pythonX.Y (only /usr/bin/pythonX.Y). Moved check so we do not exit
prematurely.
Fixes: rhbz#1411588
(cherry picked from commit a8e51b3bb05c6acb1d9b2e3d34f859ddda1677be)
---
scripts/brp-python-bytecompile | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
index 838f23d9d..894fa3459 100644
--- a/scripts/brp-python-bytecompile
+++ b/scripts/brp-python-bytecompile
@@ -6,12 +6,6 @@ if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
exit 0
fi
-# If we don't have a python interpreter, avoid changing anything.
-default_python=${1:-/usr/bin/python}
-if [ ! -x "$default_python" ]; then
- exit 0
-fi
-
# Figure out how deep we need to descend. We could pick an insanely high
# number and hope it's enough, but somewhere, somebody's sure to run into it.
depth=`(find "$RPM_BUILD_ROOT" -type f -name "*.py" -print0 ; echo /) | \
@@ -86,7 +80,12 @@ done
# Handle other locations in the filesystem using the default python
-# implementation:
+# implementation - if we have a default python interpreter
+
+default_python=${1:-/usr/bin/python}
+if [ ! -x "$default_python" ]; then
+ exit 0
+fi
# Generate normal (.pyc) byte-compiled files.
python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"

View File

@ -1,80 +0,0 @@
From 6e748a4eb167b2ca201d9e90b927cc4523eabeda Mon Sep 17 00:00:00 2001
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
Date: Tue, 21 Feb 2017 11:48:27 +0100
Subject: [PATCH] Fix number of references on spec_Type (#114)
After creating a specPkg from a spec file we must increase spec file
reference counter. Otherwise spec file may be accidentally deallocated
and usage of SpecPkg can cause an error.
(cherry picked from commit 34b61a1f82f6f9b675ab4ca820b6255af63680f1)
---
python/spec-py.c | 14 +++++++++++---
python/spec-py.h | 2 +-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/python/spec-py.c b/python/spec-py.c
index f710f5c87..753afbad4 100644
--- a/python/spec-py.c
+++ b/python/spec-py.c
@@ -45,8 +45,14 @@ struct specPkgObject_s {
PyObject_HEAD
/*type specific fields */
rpmSpecPkg pkg;
+ specObject *source_spec;
};
+static void specPkg_dealloc(specPkgObject * s)
+{
+ Py_DECREF(s->source_spec);
+}
+
static PyObject *pkgGetSection(rpmSpecPkg pkg, int section)
{
char *sect = rpmSpecPkgGetSection(pkg, section);
@@ -95,7 +101,7 @@ PyTypeObject specPkg_Type = {
"rpm.specpkg", /* tp_name */
sizeof(specPkgObject), /* tp_size */
0, /* tp_itemsize */
- 0, /* tp_dealloc */
+ (destructor) specPkg_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
@@ -227,7 +233,7 @@ static PyObject * spec_get_packages(specObject *s, void *closure)
iter = rpmSpecPkgIterInit(s->spec);
while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) {
- PyObject *po = specPkg_Wrap(&specPkg_Type, pkg);
+ PyObject *po = specPkg_Wrap(&specPkg_Type, pkg, s);
if (!po) {
rpmSpecPkgIterFree(iter);
Py_DECREF(pkgList);
@@ -350,12 +356,14 @@ spec_Wrap(PyTypeObject *subtype, rpmSpec spec)
return (PyObject *) s;
}
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source)
{
specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
if (s == NULL) return NULL;
s->pkg = pkg;
+ s->source_spec = source;
+ Py_INCREF(s->source_spec);
return (PyObject *) s;
}
diff --git a/python/spec-py.h b/python/spec-py.h
index 558fbf207..65b8dc3d7 100644
--- a/python/spec-py.h
+++ b/python/spec-py.h
@@ -13,6 +13,6 @@ extern PyTypeObject specPkg_Type;
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type)
PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg);
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source);
#endif /* RPMPYTHON_SPEC */

File diff suppressed because it is too large Load Diff

View File

@ -1,346 +0,0 @@
From 3edae790572203f07a28448fedfda82d0629f4fb Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Tue, 14 Jun 2016 17:07:13 +0200
Subject: [PATCH] Make it possible to have unique build-ids across build
versions/releases.
Introduce a new macro _unique_build_ids that when set will pass the
version and release to find-debuginfo.sh and debugedit to recalculate
the build-id of ELF files.
Includes two new testcases to make sure the new setting works as expected
both when set and unset.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
(cherry picked from commit 5ef1166ad96e3545784fa5420a49e1b2cd481e8e)
---
macros.in | 8 +++-
scripts/find-debuginfo.sh | 20 ++++++++-
tests/data/SPECS/hello-r2.spec | 58 +++++++++++++++++++++++++
tests/rpmbuildid.at | 96 +++++++++++++++++++++++++++++++++++++++++-
tools/debugedit.c | 24 ++++++++++-
5 files changed, 201 insertions(+), 5 deletions(-)
create mode 100644 tests/data/SPECS/hello-r2.spec
diff --git a/macros.in b/macros.in
index e43d62b0a..dcd09612c 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} %{?_include_minidebuginfo:-m} %{?_unique_build_ids:--ver-rel "%{version}-%{release}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@@ -476,6 +476,12 @@ package or when debugging this package.\
# ELF /usr/lib/debug/.build-id/xx/yyy -> /usr/lib/.build-id/xx/yyy
%_build_id_links compat
+# Whether build-ids should be made unique between package version/releases
+# when generating debuginfo packages. If set to 1 this will pass
+# --ver-rel "%{version}-%{release}" to find-debuginfo.sh which will pass it
+# onto debugedit --build-id-seed to be used to prime the build-id note hash.
+%_unique_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 c9e2293de..2cb9570ba 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -6,6 +6,7 @@
# [-o debugfiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
+# [--ver-rel VERSION-RELEASE]
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
# [builddir]
#
@@ -26,6 +27,12 @@
# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
# provide detailed limits. See dwz(1) -l and -L option for details.
#
+# If --ver-rel VERSION-RELEASE is given then debugedit is called to
+# update the build-ids it finds adding the VERSION-RELEASE string as
+# seed to recalculate the build-id hash. This makes sure the
+# build-ids in the ELF files are unique between versions and releases
+# of the same package.
+#
# All file names in switches are relative to builddir (. if not given).
#
@@ -49,6 +56,9 @@ run_dwz=false
dwz_low_mem_die_limit=
dwz_max_die_limit=
+# Version and release of the spec. Given by --ver-rel
+ver_rel=
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -68,6 +78,10 @@ while [ $# -gt 0 ]; do
dwz_max_die_limit=$2
shift
;;
+ --ver-rel)
+ ver_rel=$2
+ shift
+ ;;
-g)
strip_g=true
;;
@@ -249,8 +263,12 @@ while read nlinks inum f; do
fi
echo "extracting debug info from $f"
+ build_id_seed=
+ if [ ! -z "$ver_rel" ]; then
+ build_id_seed="--build-id-seed=$ver_rel"
+ fi
id=$(${lib_rpm_dir}/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \
- -i -l "$SOURCEFILE" "$f") || exit
+ -i $build_id_seed -l "$SOURCEFILE" "$f") || exit
if [ $nlinks -gt 1 ]; then
eval linkedid_$inum=\$id
fi
diff --git a/tests/data/SPECS/hello-r2.spec b/tests/data/SPECS/hello-r2.spec
new file mode 100644
index 000000000..ca5091d10
--- /dev/null
+++ b/tests/data/SPECS/hello-r2.spec
@@ -0,0 +1,58 @@
+Summary: hello -- hello, world rpm
+Name: hello
+Version: 1.0
+Release: 2
+Group: Utilities
+License: GPL
+Distribution: RPM test suite.
+Vendor: Red Hat Software
+Packager: Red Hat Software <bugs@redhat.com>
+URL: http://www.redhat.com
+Source0: hello-1.0.tar.gz
+Patch0: hello-1.0-modernize.patch
+Excludearch: lsi
+Excludeos: cpm
+Provides: hi
+Conflicts: goodbye
+Obsoletes: howdy
+Prefix: /usr
+
+%description
+Simple rpm demonstration.
+
+%prep
+%setup -q
+%patch0 -p1 -b .modernize
+
+%build
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/usr/local/bin
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+
+%post
+
+%preun
+
+%postun
+
+%files
+%defattr(-,root,root)
+%doc FAQ
+#%readme README
+#%license COPYING
+%attr(0751,root,root) /usr/local/bin/hello
+
+%changelog
+* Wed Jun 8 2016 Mark Wielaard <mjw@redhat.com>
+- Update release for unique build-id generation tests.
+
+* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com>
+- create.
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index eddca969b..1da63022d 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -758,4 +758,98 @@ debug id in debug package
debug dup id in debug package
],
[])
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+# ------------------------------
+# Check build-ids are unique between versions/releases
+# with _unique_build_ids defined.
+AT_SETUP([rpmbuild buildid unique r1 r2])
+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
+
+# No warnings for hard links
+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" \
+ -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
+id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+# 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" \
+ -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
+id2=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+if test "$id1" == "$id2"; then echo "equal $id1"; else echo "unequal"; fi
+],
+[0],
+[unequal
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check build-ids are non-unique between versions/releases
+# with _unique_build_ids undefined (and exact same sources).
+AT_SETUP([rpmbuild buildid non-unique r1 r2])
+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
+
+# No warnings for hard links
+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" \
+ -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
+id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+# 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" \
+ -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
+id2=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi
+],
+[0],
+[equal
+],
+[ignore])
+AT_CLEANUP
diff --git a/tools/debugedit.c b/tools/debugedit.c
index cf89312fa..c0147f086 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2005, 2007, 2009, 2010, 2011 Red Hat, Inc.
+/* Copyright (C) 2001-2003, 2005, 2007, 2009-2011, 2016 Red Hat, Inc.
Written by Alexander Larsson <alexl@redhat.com>, 2002
Based on code by Jakub Jelinek <jakub@redhat.com>, 2001.
@@ -54,6 +54,7 @@ char *dest_dir = NULL;
char *list_file = NULL;
int list_file_fd = -1;
int do_build_id = 0;
+char *build_id_seed = NULL;
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 },
+ { "build-id-seed", 's', POPT_ARG_STRING, &build_id_seed, 0,
+ "if recomputing the build ID note use this string as hash seed", NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
@@ -1400,7 +1403,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
exit (1);
}
- if (!dirty_elf)
+ if (!dirty_elf && build_id_seed == NULL)
goto print;
if (elf_update (dso->elf, ELF_C_NULL) < 0)
@@ -1415,6 +1418,10 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
ctx = rpmDigestInit(algorithm, 0);
+ /* If a seed string was given use it to prime the hash. */
+ if (build_id_seed != NULL)
+ rpmDigestUpdate(ctx, build_id_seed, strlen (build_id_seed));
+
/* Slurp the relevant header bits and section contents and feed them
into the hash function. The only bits we ignore are the offset
fields in ehdr and shdrs, since the semantically identical ELF file
@@ -1541,6 +1548,19 @@ main (int argc, char *argv[])
}
}
+ if (build_id_seed != NULL && do_build_id == 0)
+ {
+ fprintf (stderr, "--build-id-seed (-s) needs --build-id (-i)\n");
+ exit (1);
+ }
+
+ if (build_id_seed != NULL && strlen (build_id_seed) < 1)
+ {
+ fprintf (stderr,
+ "--build-id-seed (-s) string should be at least 1 char\n");
+ exit (1);
+ }
+
/* Ensure clean paths, users can muck with these */
if (base_dir)
canonicalize_path(base_dir, base_dir);

View File

@ -1,212 +0,0 @@
From 68a0323ab1738aee40f9f5a60a7fb3163162bf39 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Tue, 14 Jun 2016 17:07:14 +0200
Subject: [PATCH] Make adding GDB index sections configurable.
Introduces _include_gdb_index macro and -i flag to find-debuginfo.sh to
enable or disable adding a .gdb_index section to debug files. Adds tests
to make sure the .gdb_index is really added (or not) when requested.
Checks that gdb-add-index is actually installed instead of silently
failing if not. Similar for dwz.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
(cherry picked from commit 67d3df338875ad5d9601e360bfdbd4289f271bc1)
Conflicts:
scripts/find-debuginfo.sh
---
macros.debug | 1 +
macros.in | 8 ++++++-
scripts/find-debuginfo.sh | 29 ++++++++++++++++++----
tests/rpmbuild.at | 61 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+), 5 deletions(-)
diff --git a/macros.debug b/macros.debug
index 6a8432eb7..d273c0876 100644
--- a/macros.debug
+++ b/macros.debug
@@ -2,6 +2,7 @@
%_enable_debug_packages 1
%_include_minidebuginfo 1
+%_include_gdb_index 1
# Expanded at end of %install scriptlet
diff --git a/macros.in b/macros.in
index dcd09612c..c845f5841 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} %{?_unique_build_ids:--ver-rel "%{version}-%{release}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_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}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@@ -449,6 +449,12 @@ package or when debugging this package.\
#%_include_minidebuginfo 1
#
+# Include a .gdb_index section in the .debug files.
+# Requires _enable_debug_packages and gdb-add-index installed.
+#
+#%_include_gdb_index 1
+
+#
# Defines how and if build_id links are generated for ELF files.
# The following settings are supported:
#
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 2cb9570ba..8e608134f 100644
--- 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] [-i]
# [-o debugfiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
@@ -14,6 +14,8 @@
# 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 -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.
#
# A single -o switch before any -l or -p switches simply renames
# the primary output file from debugfiles.list to something else.
@@ -48,6 +50,9 @@ strip_r=false
# with -m arg, add minimal debuginfo to binary.
include_minidebug=false
+# with -i arg, add GDB index to .debug file.
+include_gdb_index=false
+
# Barf on missing build IDs.
strict=false
@@ -88,6 +93,9 @@ while [ $# -gt 0 ]; do
-m)
include_minidebug=true
;;
+ -i)
+ include_gdb_index=true
+ ;;
-o)
if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
out=$2
@@ -277,7 +285,15 @@ while read nlinks inum f; do
$strict && exit 2
fi
- type gdb-add-index >/dev/null 2>&1 && gdb-add-index "$f" > /dev/null 2>&1
+ # Add .gdb_index if requested.
+ if $include_gdb_index; then
+ if type gdb-add-index >/dev/null 2>&1; then
+ gdb-add-index "$f"
+ else
+ echo >&2 "*** ERROR: GDB index requested, but no gdb-add-index installed"
+ exit 2
+ fi
+ fi
# A binary already copied into /usr/lib/debug doesn't get stripped,
# just has its file names collected and adjusted.
@@ -303,7 +319,7 @@ while read nlinks inum f; do
done || exit
# Invoke the DWARF Compressor utility.
-if $run_dwz && type dwz >/dev/null 2>&1 \
+if $run_dwz \
&& [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug`"
if [ -n "${dwz_files}" ]; then
@@ -321,7 +337,12 @@ if $run_dwz && type dwz >/dev/null 2>&1 \
&& dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}"
[ -n "${dwz_max_die_limit}" ] \
&& dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}"
- ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+ if type dwz >/dev/null 2>&1; then
+ ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+ else
+ echo >&2 "*** ERROR: DWARF compression requested, but no dwz installed"
+ exit 2
+ fi
# Remove .dwz directory if empty
rmdir "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" 2>/dev/null
if [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" ]; then
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 1531700e1..a3123244c 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -532,3 +532,64 @@ usr/local/bin/hello2
],
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Check that a GDB index is included when requested.
+AT_SETUP([rpmbuild debuginfo gdb index included])
+AT_KEYWORDS([build] [debuginfo] [gdb])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+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 "_include_gdb_index 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that gdb-add-index has ran and a .gdb_index section has been added
+readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep gdb_index | cut -c8-17
+],
+[0],
+[.gdb_index
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a GDB index is NOT included when not requested.
+AT_SETUP([rpmbuild debuginfo no gdb index included])
+AT_KEYWORDS([build] [debuginfo] [gdb])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+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 "_include_gdb_index" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that gdb-add-index has not ran and no .gdb_index section has been added
+readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep gdb_index | cut -c8-17
+],
+[0],
+[],
+[ignore])
+AT_CLEANUP

View File

@ -1,804 +0,0 @@
From 5b29c09c31982a712844cb2bbcd0bfff09c457d1 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Thu, 16 Jun 2016 14:24:22 +0200
Subject: [PATCH] Add option to have unique debug file names across
version/release/arch.
Introduce a new macro _unique_debug_names that when set will pass
--unique-debug-arch "%{_arch}" to find-debuginfo.sh to create debuginfo
files which end in "-<ver>-<rel>.<arch>.debug" instead of simply ".debug".
Adds testcases for dwz and buildid with and without unique debug file names.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
(cherry picked from commit 45bfecbf7dd4249abc197a5fc908e4efcc3108ad)
---
build/files.c | 19 ++-
macros.debug | 3 +
macros.in | 9 +-
scripts/find-debuginfo.sh | 18 ++-
tests/rpmbuild.at | 168 +++++++++++++++++++-----
tests/rpmbuildid.at | 316 +++++++++++++++++++++++++++++++++++++++++++++-
6 files changed, 494 insertions(+), 39 deletions(-)
diff --git a/build/files.c b/build/files.c
index b010483e4..eb398562a 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1790,6 +1790,16 @@ static int generateBuildIDs(FileList fl)
}
}
+ /* In case we need ALLDEBUG links we might need the vra as
+ tagged onto the .debug file name. */
+ char *vra = NULL;
+ if (rc == 0 && needDbg && build_id_links == BUILD_IDS_ALLDEBUG) {
+ int unique_debug_names =
+ rpmExpandNumeric("%{?_unique_debug_names}");
+ if (unique_debug_names == 1)
+ vra = rpmExpand("-%{version}-%{release}.%{_arch}", NULL);
+ }
+
/* Now add a subdir and symlink for each buildid found. */
for (i = 0; i < nr_ids; i++) {
/* Don't add anything more when an error occured. But do
@@ -1884,15 +1894,17 @@ static int generateBuildIDs(FileList fl)
int pathlen = strlen(paths[i]);
int debuglen = strlen(".debug");
int prefixlen = strlen("/usr/lib/debug");
- if (pathlen > prefixlen
- && strcmp (paths[i] + pathlen - debuglen,
+ int vralen = vra == NULL ? 0 : strlen(vra);
+ if (pathlen > prefixlen + debuglen + vralen
+ && strcmp ((paths[i] + pathlen - debuglen),
".debug") == 0) {
free(linkpath);
free(targetpath);
char *targetstr = xstrdup (paths[i]
+ prefixlen);
int targetlen = pathlen - prefixlen;
- targetstr[targetlen - debuglen] = '\0';
+ int targetend = targetlen - debuglen - vralen;
+ targetstr[targetend] = '\0';
rasprintf(&linkpath, "%s/%s",
buildidsubdir, &ids[i][2]);
rasprintf(&targetpath, "../../../../..%s",
@@ -1911,6 +1923,7 @@ static int generateBuildIDs(FileList fl)
free(paths[i]);
free(ids[i]);
}
+ free(vra);
free(paths);
free(ids);
}
diff --git a/macros.debug b/macros.debug
index d273c0876..ee0cc9ebe 100644
--- a/macros.debug
+++ b/macros.debug
@@ -1,4 +1,7 @@
# macros to include to generate debuginfo
+# Note don't define/enable a feature here if it is already the default in
+# macros.in. Otherwise it cannot simply be --undefined on the command line
+# in the tests (it needs to be undefined multiple times then).
%_enable_debug_packages 1
%_include_minidebuginfo 1
diff --git a/macros.in b/macros.in
index c845f5841..68bf39194 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} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{version}-%{release}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_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}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@@ -488,6 +488,13 @@ 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
+# 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
+# debuginfo files which end in -<ver>-<rel>.<arch>.debug
+# Requires _unique_build_ids.
+%_unique_debug_names 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 8e608134f..3653c4848 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -64,6 +64,9 @@ dwz_max_die_limit=
# Version and release of the spec. Given by --ver-rel
ver_rel=
+# Arch given by --unique-debug-arch
+unique_debug_arch=
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -87,6 +90,10 @@ while [ $# -gt 0 ]; do
ver_rel=$2
shift
;;
+ --unique-debug-arch)
+ unique_debug_arch=$2
+ shift
+ ;;
-g)
strip_g=true
;;
@@ -125,6 +132,11 @@ while [ $# -gt 0 ]; do
shift
done
+if test -z "$ver_rel" -a -n "$unique_debug_arch"; then
+ echo >&2 "*** ERROR: --unique-debug-arch (${unique_debug_arch}) needs --ver-rel (${ver_rel})"
+ exit 2
+fi
+
i=0
while ((i < nout)); do
outs[$i]="$BUILDDIR/${outs[$i]}"
@@ -232,7 +244,11 @@ debug_link()
get_debugfn()
{
dn=$(dirname "${1#$RPM_BUILD_ROOT}")
- bn=$(basename "$1" .debug).debug
+ if test -n "${unique_debug_arch}"; then
+ bn=$(basename "$1" .debug)-${ver_rel}.${unique_debug_arch}.debug
+ else
+ bn=$(basename "$1" .debug).debug
+ fi
debugdn=${debugdir}${dn}
debugfn=${debugdn}/${bn}
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index a3123244c..0a2c01efe 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -386,8 +386,9 @@ 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
# so dwz has enough slightly similar debug data.
+# Test the case without unique debug file names.
AT_SETUP([rpmbuild debuginfo dwz])
-AT_KEYWORDS([build] [debuginfo])
+AT_KEYWORDS([build] [debuginfo] [dwz])
AT_CHECK([
rm -rf ${TOPDIR}
AS_MKDIR_P(${TOPDIR}/SOURCES)
@@ -397,63 +398,170 @@ cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/he
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_debug_names" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# The debuginfo package should contain a .debug file for each binary
# and a dwz multi file that contains the shared debuginfo between them.
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
| cpio -diu
-test -f ./usr/lib/debug/usr/local/bin/hello.debug || exit 1
-test -f ./usr/lib/debug/usr/local/bin/hello2.debug || exit 1
-test -f ./usr/lib/debug/.dwz/hello2-1.0-1.* || exit 1
+
+hello_file_debug=./usr/lib/debug/usr/local/bin/hello.debug
+hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2.debug
+hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
+test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
+test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
+test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
# Make sure the main package binaries contain the correct build-ids
# linking them to the debug packages.
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
| cpio -diu
-id1=$(file ./usr/local/bin/hello | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2=$(file ./usr/local/bin/hello2 | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id1debug=$(file ./usr/lib/debug/usr/local/bin/hello.debug \
- | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2debug=$(file ./usr/lib/debug/usr/local/bin/hello2.debug \
- | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-idmulti=$(file ./usr/lib/debug/.dwz/hello2-1.0-1.* \
- | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-
-test "$id1" = "$id1debug" || exit 1
-test "$id2" = "$id2debug" || exit 1
+hello_file=./usr/local/bin/hello
+hello2_file=./usr/local/bin/hello2
+test -f $hello_file || echo "no hello file: $hello_file"
+test -f $hello2_file || echo "no hello2 file: $hello2_file"
+
+id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
+test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
+
+# The build-id files should link to the .debug files.
+id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
+canonid1file=$(readlink -f ${id1file})
+canonfile1=$(readlink -f $hello_file)
+canonid1debug=$(readlink -f ${id1file}.debug)
+canondebug1=$(readlink -f $hello_file_debug)
+
+test "$canonid1file" = "$canonfile1" \
+ || echo "canonid1file: $canonid1file != $canonfile1"
+test "$canonid1debug" = "$canondebug1" \
+ || echo "canonid1debug: $canonid1debug != $canondebug1"
+
+id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
+canonid2file=$(readlink -f ${id2file})
+canonfile2=$(readlink -f $hello2_file)
+canonid2debug=$(readlink -f ${id2file}.debug)
+canondebug2=$(readlink -f $hello2_file_debug)
+
+test "$canonid2file" = "$canonfile2" \
+ || echo "canonid2: $canonid2file != $canonfile2"
+test "$canonid2debug" = "$canondebug2" \
+ || echo "canonid2debug: $canonid2debug" != "$canondebug2"
+
+# Both .debug files should point to the dwz multi file.
+# It would be nice to also test that they contain the correct dwz build-id
+# but that is a bit hard to grep out of the section data.
+multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
+ | grep '[ 0]' | cut -c13-)
+multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
+ | grep '[ 0]' | cut -c13-)
+
+test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
+
+canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
+canonmultifile=$(readlink -f $hello_multi_file)
+
+test "$canonmultiref" = "$canonmultifile" \
+ || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
+],
+[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
+# so dwz has enough slightly similar debug data.
+# Test with unique debug file names.
+AT_SETUP([rpmbuild debuginfo dwz unique debug names])
+AT_KEYWORDS([build] [debuginfo] [dwz])
+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 --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_debug_names 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# The debuginfo package should contain a .debug file for each binary
+# and a dwz multi file that contains the shared debuginfo between them.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+
+hello_file_debug=./usr/lib/debug/usr/local/bin/hello-*.debug
+hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2-*.debug
+hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
+test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
+test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
+test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
+
+# Make sure the main package binaries contain the correct build-ids
+# linking them to the debug packages.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
+ | cpio -diu
+hello_file=./usr/local/bin/hello
+hello2_file=./usr/local/bin/hello2
+test -f $hello_file || echo "no hello file: $hello_file"
+test -f $hello2_file || echo "no hello2 file: $hello2_file"
+
+id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
+test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
# The build-id files should link to the .debug files.
id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
canonid1file=$(readlink -f ${id1file})
-canonfile1=$(readlink -f ./usr/local/bin/hello)
+canonfile1=$(readlink -f $hello_file)
canonid1debug=$(readlink -f ${id1file}.debug)
-canondebug1=$(readlink -f ./usr/lib/debug/usr/local/bin/hello.debug)
+canondebug1=$(readlink -f $hello_file_debug)
-test "$canonid1file" = "$canonfile1" || exit 1
-test "$canonid1debug" = "$canondebug1" || exit 1
+test "$canonid1file" = "$canonfile1" \
+ || echo "canonid1file: $canonid1file != $canonfile1"
+test "$canonid1debug" = "$canondebug1" \
+ || echo "canonid1debug: $canonid1debug != $canondebug1"
id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
-canonid2file=$(readlink -f ${id1file})
-canonfile2=$(readlink -f ./usr/local/bin/hello)
-canonid2debug=$(readlink -f ${id1file}.debug)
-canondebug2=$(readlink -f ./usr/lib/debug/usr/local/bin/hello.debug)
+canonid2file=$(readlink -f ${id2file})
+canonfile2=$(readlink -f $hello2_file)
+canonid2debug=$(readlink -f ${id2file}.debug)
+canondebug2=$(readlink -f $hello2_file_debug)
-test "$canonid2file" = "$canonfile2" || exit 1
-test "$canonid2debug" = "$canondebug2" || exit 1
+test "$canonid2file" = "$canonfile2" \
+ || echo "canonid2: $canonid2file != $canonfile2"
+test "$canonid2debug" = "$canondebug2" \
+ || echo "canonid2debug: $canonid2debug" != "$canondebug2"
# Both .debug files should point to the dwz multi file.
# It would be nice to also test that they contain the correct dwz build-id
# but that is a bit hard to grep out of the section data.
-multiref1=$(readelf --string-dump=.gnu_debugaltlink ./usr/lib/debug/usr/local/bin/hello.debug | grep '[ 0]' | cut -c13-)
-multiref2=$(readelf --string-dump=.gnu_debugaltlink ./usr/lib/debug/usr/local/bin/hello2.debug | grep '[ 0]' | cut -c13-)
+multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
+ | grep '[ 0]' | cut -c13-)
+multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
+ | grep '[ 0]' | cut -c13-)
-test "$multiref1" = "$multiref2" || exit 1
+test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
-canonmultifile=$(readlink -f ./usr/lib/debug/.dwz/hello2-1.0-1.*)
+canonmultifile=$(readlink -f $hello_multi_file)
-test "$canonmultiref" = "$canonmultifile" || exit 1
+test "$canonmultiref" = "$canonmultifile" \
+ || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
],
[0],
[],
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index 1da63022d..ede1181e1 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -54,7 +54,8 @@ hello debuginfo build-id files: 0
AT_CLEANUP
# ------------------------------
-# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks
+# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks.
+# Without unique debug file names.
AT_SETUP([rpmbuild buildid alldebug])
AT_KEYWORDS([build] [debuginfo] [buildid])
AT_CHECK([
@@ -69,6 +70,7 @@ run rpmbuild \
--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="_build_id_links alldebug" \
+ --undefine "_unique_debug_names" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be zero build-id files in the main package
@@ -114,7 +116,100 @@ test "$canon_main_file" = "$canon_main_id_file" \
# And check the same for the debug file.
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
-test -f "${debug_file}" || echo "No debug file ${debug_file}"
+test -f ${debug_file} || echo "No debug file ${debug_file}"
+
+# Extract the build-id from the .debug file
+id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test ${id_main} = ${id_debug} || echo "unequal main and debug id"
+
+id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
+test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
+
+canon_debug_file=$(readlink -f ${debug_file})
+
+test -f "$canon_debug_file" \
+ || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
+
+canon_debug_id_file=$(readlink -f ${id_debug_file})
+
+test -f "$canon_debug_id_file" \
+ || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
+
+test "$canon_debug_file" = "$canon_debug_id_file" \
+ || echo "debug and build-id not linked"
+],
+[0],
+[hello build-id files: 0
+hello debuginfo build-id files: 3
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks.
+# With unique debug file names.
+AT_SETUP([rpmbuild buildid alldebug unique debug names])
+AT_KEYWORDS([build] [debuginfo] [buildid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Build, contains one ELF which should have a buildid.
+run rpmbuild \
+ --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="_build_id_links alldebug" \
+ --define="_unique_debug_names 1" \
+ --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
+
+# There should be zero build-id files in the main package
+# Main and debug should be in the debuginfo package,
+# plus the .build-id/xx subdir, 3 in total.
+echo -n "hello build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+echo -n "hello debuginfo build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+# Extract the both packages to check the build-id files link to the
+# main and .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
+ | cpio -diu
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+
+# Check there is a build-id symlink for the main file.
+main_file=./usr/local/bin/hello
+test -f "${main_file}" || echo "No main file ${main_file}"
+
+# Extract the build-id from the main file
+id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
+test -L "$id_main_file" || echo "No build-id file $id_main_file"
+
+canon_main_file=$(readlink -f ${main_file})
+
+test -f "$canon_main_file" \
+ || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
+
+canon_main_id_file=$(readlink -f ${id_main_file})
+
+test -f "$canon_main_id_file" \
+ || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
+
+test "$canon_main_file" = "$canon_main_id_file" \
+ || echo "main and build-id file not linked"
+
+# And check the same for the debug file.
+debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
+test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
@@ -146,6 +241,7 @@ AT_CLEANUP
# ------------------------------
# Check if rpmbuild "separate" generates main and debuginfo buildid symlinks
+# Without unique debug file names
AT_SETUP([rpmbuild buildid separate])
AT_KEYWORDS([build] [debuginfo] [buildid])
AT_CHECK([
@@ -160,6 +256,7 @@ run rpmbuild \
--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="_build_id_links separate" \
+ --undefine "_unique_debug_names" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be one build-id files in the main and debuginfo package
@@ -204,7 +301,99 @@ test "$canon_main_file" = "$canon_main_id_file" \
# And check the same for the debug file.
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
-test -f "${debug_file}" || echo "No debug file ${debug_file}"
+test -f ${debug_file} || echo "No debug file ${debug_file}"
+
+# Extract the build-id from the .debug file
+id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test ${id_main} = ${id_debug} || echo "unequal main and debug id"
+
+id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
+test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
+
+canon_debug_file=$(readlink -f ${debug_file})
+
+test -f "$canon_debug_file" \
+ || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
+
+canon_debug_id_file=$(readlink -f ${id_debug_file})
+
+test -f "$canon_debug_id_file" \
+ || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
+
+test "$canon_debug_file" = "$canon_debug_id_file" \
+ || echo "debug and build-id not linked"
+],
+[0],
+[hello build-id files: 2
+hello debuginfo build-id files: 2
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild "separate" generates main and debuginfo buildid symlinks
+# With unique debug file names
+AT_SETUP([rpmbuild buildid separate unique debug names])
+AT_KEYWORDS([build] [debuginfo] [buildid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Build, contains one ELF which should have a buildid.
+run rpmbuild \
+ --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="_build_id_links separate" \
+ --define="_unique_debug_names 1" \
+ --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
+
+# There should be one build-id files in the main and debuginfo package
+# plus the .build-id/xx subdir, 2 in total.
+echo -n "hello build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+echo -n "hello debuginfo build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+# Extract the both packages to check the build-id files link to the
+# main and .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
+ | cpio -diu
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+
+# Check there is a build-id symlink for the main file.
+main_file=./usr/local/bin/hello
+test -f "${main_file}" || echo "No main file ${main_file}"
+
+# Extract the build-id from the main file
+id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
+test -L "$id_main_file" || echo "No build-id file $id_main_file"
+
+canon_main_file=$(readlink -f ${main_file})
+
+test -f "$canon_main_file" \
+ || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
+
+canon_main_id_file=$(readlink -f ${id_main_file})
+
+test -f "$canon_main_id_file" \
+ || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
+
+test "$canon_main_file" = "$canon_main_id_file" \
+ || echo "main and build-id file not linked"
+
+# And check the same for the debug file.
+debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
+test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
@@ -236,6 +425,7 @@ AT_CLEANUP
# ------------------------------
# Check if rpmbuild "compat" generates main and debuginfo buildid symlinks
+# Without unique debug file names
AT_SETUP([rpmbuild buildid compat])
AT_KEYWORDS([build] [debuginfo] [buildid])
AT_CHECK([
@@ -250,6 +440,7 @@ run rpmbuild \
--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="_build_id_links compat" \
+ --undefine "_unique_debug_names" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be one build-id files in the main and debuginfo package.
@@ -295,7 +486,112 @@ test "$canon_main_file" = "$canon_main_id_file" \
# And check the same for the debug file.
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
-test -f "${debug_file}" || echo "No debug file ${debug_file}"
+test -f ${debug_file} || echo "No debug file ${debug_file}"
+
+# Extract the build-id from the .debug file
+id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test ${id_main} = ${id_debug} || echo "unequal main and debug id"
+
+id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
+test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
+
+canon_debug_file=$(readlink -f ${debug_file})
+
+test -f "$canon_debug_file" \
+ || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
+
+canon_debug_id_file=$(readlink -f ${id_debug_file})
+
+test -f "$canon_debug_id_file" \
+ || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
+
+test "$canon_debug_file" = "$canon_debug_id_file" \
+ || echo "debug and build-id not linked"
+
+# The compat link should also point to the same (indirectly).
+id_compat_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
+test -L "$id_compat_file" || echo "No build-id compat file $id_compat_file"
+
+canon_compat_file=$(readlink -f ${id_compat_file})
+
+test -f "$canon_compat_file" \
+ || echo "Cannot resolve compat file ${id_compat_file} -> ${canon_compat_file}"
+
+test "$canon_compat_file" = "$canon_main_file" \
+ || echo "compat and build-id not linked"
+],
+[0],
+[hello build-id files: 2
+hello debuginfo build-id files: 3
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild "compat" generates main and debuginfo buildid symlinks
+# With unique debug file names
+AT_SETUP([rpmbuild buildid compat unique debug names])
+AT_KEYWORDS([build] [debuginfo] [buildid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Build, contains one ELF which should have a buildid.
+run rpmbuild \
+ --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="_build_id_links compat" \
+ --define="_unique_debug_names 1" \
+ --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
+
+# There should be one build-id files in the main and debuginfo package.
+# the debuginfo package has one extra main build-id compat symlink
+# plus the .build-id/xx subdir, 2 in total in main, 3 in total in debug
+echo -n "hello build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+echo -n "hello debuginfo build-id files: "
+run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | grep /.build-id/ | wc --lines
+
+# Extract the both packages to check the build-id files link to the
+# main and .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
+ | cpio -diu
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+
+# Check there is a build-id symlink for the main file.
+main_file=./usr/local/bin/hello
+test -f "${main_file}" || echo "No main file ${main_file}"
+
+# Extract the build-id from the main file
+id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
+test -L "$id_main_file" || echo "No build-id file $id_main_file"
+
+canon_main_file=$(readlink -f ${main_file})
+
+test -f "$canon_main_file" \
+ || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
+
+canon_main_id_file=$(readlink -f ${id_main_file})
+
+test -f "$canon_main_id_file" \
+ || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
+
+test "$canon_main_file" = "$canon_main_id_file" \
+ || echo "main and build-id file not linked"
+
+# And check the same for the debug file.
+debug_file=./usr/lib/debug/usr/local/bin/hello-*debug
+test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
@@ -784,8 +1080,12 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
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[.*]=\(.*\),.*/\1/')
+# Make sure we generate a new one
+rm $hello_file
+
# 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 \
@@ -797,6 +1097,7 @@ 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[.*]=\(.*\),.*/\1/')
if test "$id1" == "$id2"; then echo "equal $id1"; else echo "unequal"; fi
@@ -823,6 +1124,7 @@ 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" \
-ba "${abs_srcdir}"/data/SPECS/hello.spec
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
@@ -831,19 +1133,25 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
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[.*]=\(.*\),.*/\1/')
+# Make sure we generate a new one
+rm $hello_file
+
# 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" \
-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[.*]=\(.*\),.*/\1/')
if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi

View File

@ -1,28 +0,0 @@
From a040e812b39d1fcc6aa69ca6aa5ff2fe4316a018 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Mon, 3 Oct 2016 12:36:46 +0300
Subject: [PATCH] Fix behavior when %_build_id_links is undefined
Commit bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 tries to behave sanely
and use compat setting when %_build_id_links is undefined, but
rpmExpand() never returns NULL so the original check is incorrect.
Check for empty string instead.
(cherry picked from commit 2ea72daabe3f0c4bef628d5a16768f293ffab3df)
---
build/files.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/files.c b/build/files.c
index eb398562a..6215bf85c 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1648,7 +1648,7 @@ static int generateBuildIDs(FileList fl)
/* How are we supposed to create the build-id links? */
char *build_id_links_macro = rpmExpand("%{?_build_id_links}", NULL);
int build_id_links;
- if (build_id_links_macro == NULL) {
+ if (*build_id_links_macro == '\0') {
rpmlog(RPMLOG_WARNING,
_("_build_id_links macro not set, assuming 'compat'\n"));
build_id_links = BUILD_IDS_COMPAT;

View File

@ -1,139 +0,0 @@
From 932c2170e961d393569992b2f9c3ab8ee415f01b Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Wed, 9 Nov 2016 09:16:48 +0200
Subject: [PATCH] Fix debuginfo etc when subpackages have different versions
(RhBug:1051407)
Rpm has always been a bit dazed and confused when it comes to specs
with sub-packages having different version etc from the main package.
Many things work fine in that case .. except .. when they dont. Debuginfo
picking up wrong versions (RhBug:1051407) is just one example, there
are countless more in bugzilla wrt buildroot paths and whatnot.
The simple and sane solution would be not piling on them macros
from sub-packages, but that would surely break somebodys precious
spec tricks.
The ugly but brutally simple and compatible solution to this all is to
create separate set of macros when on the main package, this lets users
in and out of rpm pick which one (latest or main) they want. To hopefully
avoid stomping on anybodys toes, use uppercasing for the macro name (other
variants like %pkg_release are awfully commonly used). Pile 'em on, yay!
(cherry picked from commit ccdb1aa5c675d917b1ba8d026c44fd95bab79e6c)
Conflicts:
build/parsePreamble.c
macros.in
---
build/files.c | 2 +-
build/parsePreamble.c | 11 ++++++++++-
macros.in | 18 +++++++++---------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/build/files.c b/build/files.c
index 6215bf85c..2ede463a1 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1797,7 +1797,7 @@ static int generateBuildIDs(FileList fl)
int unique_debug_names =
rpmExpandNumeric("%{?_unique_debug_names}");
if (unique_debug_names == 1)
- vra = rpmExpand("-%{version}-%{release}.%{_arch}", NULL);
+ vra = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL);
}
/* Now add a subdir and symlink for each buildid found. */
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 933f7340f..6be440369 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -909,8 +909,17 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
goto exit;
}
- if (macro)
+ if (macro) {
addMacro(spec->macros, macro, NULL, field, RMIL_SPEC);
+ /* Add a separate uppercase macro for tags from the main package */
+ if (pkg == spec->packages) {
+ char *m = xstrdup(macro);
+ for (char *p = m; *p; ++p)
+ *p = rtoupper(*p);
+ addMacro(spec->macros, m, NULL, field, RMIL_SPEC);
+ free(m);
+ }
+ }
rc = RPMRC_OK;
exit:
return rc;
diff --git a/macros.in b/macros.in
index 68bf39194..4d9028254 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} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{version}-%{release}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_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}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@@ -232,7 +232,7 @@ package or when debugging this package.\
%_buildrootdir %{_topdir}/BUILDROOT
# Build root path, where %install installs the package during build.
-%buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
+%buildroot %{_buildrootdir}/%{NAME}-%{VERSION}-%{RELEASE}.%{_arch}
# Directory where temporaray files can be created.
%_tmppath %{_var}/tmp
@@ -484,7 +484,7 @@ package or when debugging this package.\
# Whether build-ids should be made unique between package version/releases
# when generating debuginfo packages. If set to 1 this will pass
-# --ver-rel "%{version}-%{release}" to find-debuginfo.sh which will pass it
+# --ver-rel "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will pass it
# onto debugedit --build-id-seed to be used to prime the build-id note hash.
%_unique_build_ids 1
@@ -705,9 +705,9 @@ package or when debugging this package.\
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\
RPM_DOC_DIR=\"%{_docdir}\"\
export RPM_DOC_DIR\
- RPM_PACKAGE_NAME=\"%{name}\"\
- RPM_PACKAGE_VERSION=\"%{version}\"\
- RPM_PACKAGE_RELEASE=\"%{release}\"\
+ RPM_PACKAGE_NAME=\"%{NAME}\"\
+ RPM_PACKAGE_VERSION=\"%{VERSION}\"\
+ RPM_PACKAGE_RELEASE=\"%{RELEASE}\"\
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\
LANG=C\
export LANG\
@@ -1146,7 +1146,7 @@ done \
%__scm_setup_hg(q)\
%{__hg} init %{-q} .\
%{__hg} add %{-q} .\
-%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{name}-%{version} base"
+%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
%__scm_apply_hg(qp:m:)\
%{__hg} import - %{-p:-p%{-p*}} %{-q} -m %{-m*} --user "%{__scm_author}"
@@ -1158,7 +1158,7 @@ done \
%{__git} config user.email "%{__scm_usermail}"\
%{__git} add .\
%{__git} commit %{-q} -a\\\
- --author "%{__scm_author}" -m "%{name}-%{version} base"
+ --author "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
%__scm_apply_git(qp:m:)\
%{__git} apply --index %{-p:-p%{-p*}} -\
@@ -1181,7 +1181,7 @@ done \
%{__bzr} init %{-q}\
%{__bzr} whoami --branch "%{__scm_author}"\
%{__bzr} add .\
-%{__bzr} commit %{-q} -m "%{name}-%{version} base"
+%{__bzr} commit %{-q} -m "%{NAME}-%{VERSION} base"
# bzr doesn't seem to have its own command to apply patches?
%__scm_apply_bzr(qp:m:)\

View File

@ -1,49 +0,0 @@
From 29f756e3fba09f6a66515970978367829862f35c Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 5 Jan 2017 12:13:54 +0200
Subject: [PATCH] Only process regular files when generating build-ids
Versioned shared libraries typically have several symlinks pointing
to them directly and indirectly. When %_build_id_links is set to compat or
separate this causes bogus warnings about duplicate build-ids.
It looks commit bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 intends to skip
symlinks since it filters on S_ISREG(), but since uses fstat()
on already open()'ed file it ends up stat()'ing the symlink target.
Flip stat() + open() around and use lstat() instead to fix it.
(cherry picked from commit 1ce844ab263bf49ee6d5145ed09e73f2c17924cc)
---
build/files.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/build/files.c b/build/files.c
index 2ede463a1..ca041764f 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1678,11 +1678,10 @@ static int generateBuildIDs(FileList fl)
int needMain = 0;
int needDbg = 0;
for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
- int fd;
- fd = open (flp->diskPath, O_RDONLY);
- if (fd >= 0) {
- struct stat sbuf;
- if (fstat (fd, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
+ struct stat sbuf;
+ if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
+ int fd = open (flp->diskPath, O_RDONLY);
+ if (fd >= 0) {
Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
if (elf != NULL && elf_kind(elf) == ELF_K_ELF) {
const void *build_id;
@@ -1748,8 +1747,8 @@ static int generateBuildIDs(FileList fl)
}
elf_end (elf);
}
+ close (fd);
}
- close (fd);
}
}

View File

@ -1,40 +0,0 @@
From 1b34b839b788264ffcd3ab90a0612cad3b843f7f Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Wed, 10 Aug 2016 13:58:30 +0200
Subject: [PATCH] configure.ac: use LIBDW always conditionally
References: https://bugzilla.redhat.com/show_bug.cgi?id=1365278
Reported-and-tested-by: Neal Gompa <ngompa13@gmail.com>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit a82119bf352400ee891105820b804bf946d5c6ee)
---
configure.ac | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8890c3c32..33c8f344f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -361,7 +361,8 @@ AM_CONDITIONAL(WITH_ARCHIVE,[test "$with_archive" = yes])
#=================
# Check for elfutils libdw library with dwelf_elf_gnu_build_id.
-AS_IF([test "$WITH_LIBELF" = yes],[
+WITH_LIBDW_LIB=
+AS_IF([test "$WITH_LIBELF" != yes],[
AC_CHECK_HEADERS([elfutils/libdwelf.h],[
AC_CHECK_LIB(dw, dwelf_elf_gnu_build_id, [
AC_DEFINE(HAVE_LIBDW, 1,
@@ -370,9 +371,9 @@ AS_IF([test "$WITH_LIBELF" = yes],[
WITH_LIBDW=yes
])
])
- AC_SUBST(WITH_LIBDW_LIB)
- AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW" = yes])
])
+AC_SUBST(WITH_LIBDW_LIB)
+AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW" = yes])
#=================
# Process --with/without-external-db

View File

@ -1,28 +0,0 @@
From f41a0a8c6839e3962e10a7bd3aad39127a764748 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Wed, 24 Aug 2016 17:06:34 +0200
Subject: [PATCH] Fix libdw configure check.
commit a82119 "configure.ac: use LIBDW always conditionally" contained
a typo that caused WITH_LIBDW_LIB never to be set when you were using
libelf. Fixed by reverting the "!=" to "=" again.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
(cherry picked from commit 10633641ec17081cca6332c3fb4abeea3df4059f)
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 33c8f344f..9596a97b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,7 +362,7 @@ AM_CONDITIONAL(WITH_ARCHIVE,[test "$with_archive" = yes])
#=================
# Check for elfutils libdw library with dwelf_elf_gnu_build_id.
WITH_LIBDW_LIB=
-AS_IF([test "$WITH_LIBELF" != yes],[
+AS_IF([test "$WITH_LIBELF" = yes],[
AC_CHECK_HEADERS([elfutils/libdwelf.h],[
AC_CHECK_LIB(dw, dwelf_elf_gnu_build_id, [
AC_DEFINE(HAVE_LIBDW, 1,

File diff suppressed because it is too large Load Diff

View File

@ -1,289 +0,0 @@
From 0febf191cc874a822f045c24587d412e4d0ec33c Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 28 Feb 2017 21:34:34 +0100
Subject: [PATCH] Add option to have unique debug source dirs across
version/release/arch.
Introduce a new macro _unique_debug_srcs that when set will pass
--unique-debug-src-base "%{name}" to find-debuginfo.sh which will
move sources into a unique "<name>-<ver>-<rel>.<arch>" directory
under /usr/src/debug/ and makes debugedit rewrite the source paths
in the debuginfo to use that unique directory name.
Traditionally the debug src dir was named after the builddir which
was defined through the %setup macro which used the -n name argument
to define the builddir name and source archive to use. The builddir
might not be unique though between package versions.
Now that debugedit doesn't have strict base and dest dir length
restrictions for rewriting the source dir paths this can now be made
more flexible.
The added testcases show the difference between the old and new way.
The hello2.spec file defines the name of the package as hello2, but
uses the %setup marcro with -n hello-1.0 to use the hello-1.0.tar.gz
archive. This would traditionally result in a hello-1.0 builddir
which would be moved under /usr/src/debug. Possibly conflicting
with any other package (version) that used the same builddir name.
When defining _unique_debug_srcs to 1 that builddir will be moved
to <name>-<ver>-<rel>.<arch> instead (hello2-1.0-1.<arch>).
The testcases check that both the actual package source filess under
/usr/debug/src/ and the source paths as found in the .debug files are
under the traditional or new unique directory names depending on whether
the new _unique_debug_srcs macro is defined.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit b32e980611c45a46e95fa8864b6faf0c0d732ddb)
Conflicts:
macros.in
scripts/find-debuginfo.sh
---
macros.in | 8 ++++-
scripts/find-debuginfo.sh | 35 ++++++++++++++++++---
tests/rpmbuild.at | 80 +++++++++++++++++++++++++++++++++++++++++++++++
tests/rpmbuildid.at | 5 +++
4 files changed, 123 insertions(+), 5 deletions(-)
diff --git a/macros.in b/macros.in
index 4d9028254..e48ef60c8 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} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{VERSION}-%{RELEASE}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_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}"\
%{nil}
# Template for debug information sub-package.
@@ -495,6 +495,12 @@ package or when debugging this package.\
# Requires _unique_build_ids.
%_unique_debug_names 1
+# Whether the /usr/debug/src/<package> directories should be unique between
+# package version, release and architecture. If set to 1 this will pass
+# --unique-debug-src-base "%{name}" to find-debuginfo.sh to name the
+# directory under /usr/debug/src as <name>-<ver>-<rel>.<arch>
+%_unique_debug_srcs 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 3653c4848..1420ef6cd 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -67,6 +67,9 @@ ver_rel=
# Arch given by --unique-debug-arch
unique_debug_arch=
+# Base given by --unique-debug-src-base
+unique_debug_src_base=
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -94,6 +97,10 @@ while [ $# -gt 0 ]; do
unique_debug_arch=$2
shift
;;
+ --unique-debug-src-base)
+ unique_debug_src_base=$2
+ shift
+ ;;
-g)
strip_g=true
;;
@@ -137,6 +144,11 @@ if test -z "$ver_rel" -a -n "$unique_debug_arch"; then
exit 2
fi
+if test -z "$unique_debug_arch" -a -n "$unique_debug_src_base"; then
+ echo >&2 "*** ERROR: --unique-debug-src-base (${unique_debug_src_base}) needs --unique-debug-arch (${unique_debug_arch})"
+ exit 2
+fi
+
i=0
while ((i < nout)); do
outs[$i]="$BUILDDIR/${outs[$i]}"
@@ -291,7 +303,14 @@ while read nlinks inum f; do
if [ ! -z "$ver_rel" ]; then
build_id_seed="--build-id-seed=$ver_rel"
fi
- id=$(${lib_rpm_dir}/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \
+ # See also cpio SOURCEFILE copy. Directories must match up.
+ debug_base_name="$RPM_BUILD_DIR"
+ debug_dest_name="/usr/src/debug"
+ if [ ! -z "$unique_debug_src_base" ]; then
+ debug_base_name="$BUILDDIR"
+ debug_dest_name="/usr/src/debug/${unique_debug_src_base}-${ver_rel}.${unique_debug_arch}"
+ fi
+ id=$(${lib_rpm_dir}/debugedit -b $debug_base_name -d $debug_dest_name \
-i $build_id_seed -l "$SOURCEFILE" "$f") || exit
if [ $nlinks -gt 1 ]; then
eval linkedid_$inum=\$id
@@ -388,11 +407,19 @@ do
done
if [ -s "$SOURCEFILE" ]; then
- mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug"
+ # See also debugedit invocation. Directories must match up.
+ debug_base_name="$RPM_BUILD_DIR"
+ debug_dest_name="/usr/src/debug"
+ if [ ! -z "$unique_debug_src_base" ]; then
+ debug_base_name="$BUILDDIR"
+ debug_dest_name="/usr/src/debug/${unique_debug_src_base}-${ver_rel}.${unique_debug_arch}"
+ fi
+
+ mkdir -p "${RPM_BUILD_ROOT}${debug_dest_name}"
LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(<internal>|<built-in>)$' |
- (cd "$RPM_BUILD_DIR"; cpio -pd0mL "${RPM_BUILD_ROOT}/usr/src/debug")
+ (cd "${debug_base_name}"; cpio -pd0mL "${RPM_BUILD_ROOT}${debug_dest_name}")
# stupid cpio creates new directories in mode 0700, fixup
- find "${RPM_BUILD_ROOT}/usr/src/debug" -type d -print0 |
+ find "${RPM_BUILD_ROOT}${debug_dest_name}" -type d -print0 |
xargs --no-run-if-empty -0 chmod a+rx
fi
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 0a2c01efe..a46822f52 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -399,6 +399,7 @@ 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_debug_names" \
+ --undefine "_unique_debug_srcs" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# The debuginfo package should contain a .debug file for each binary
@@ -701,3 +702,82 @@ readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
[],
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Check that a debug source is in a "unique" directory when requested.
+AT_SETUP([rpmbuild debuginfo unique debug src dir])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Note that the spec defines hello2 as name, but the source is hello-1.0.
+# Disable dwz to make debuginfo path rewrite checking easier.
+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 "_find_debuginfo_dwz_opts" \
+ --define "_unique_debug_srcs 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that the source path is "unique"
+# Drop the final arch prefix to make the test arch-independent.
+ls ./usr/src/debug/ | cut -f1,2 -d\.
+
+# Check that the source path has been rewritten in the .debug file.
+# Drop the final arch prefix to make the test arch-independent.
+readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep comp_dir | cut -f5- -d/ | cut -f1,2 -d\.
+],
+[0],
+[hello2-1.0-1
+hello2-1.0-1
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a debug source is NOT in a "unique" directory when not requested.
+# It will be in the "build directory" name under /usr/src/debug.
+AT_SETUP([rpmbuild debuginfo no unique debug src dir])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Note that the spec defines hello2 as name, but the source is hello-1.0.
+# Disable dwz to make debuginfo path rewrite checking easier.
+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 "_find_debuginfo_dwz_opts" \
+ --undefine "_unique_debug_srcs" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that the source path is "unique"
+ls ./usr/src/debug/
+
+# Check that the source path has been rewritten in the .debug file.
+readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep comp_dir | cut -f5- -d/
+],
+[0],
+[hello-1.0
+hello-1.0
+],
+[ignore])
+AT_CLEANUP
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index ede1181e1..15c06202f 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -71,6 +71,7 @@ run rpmbuild \
--rcfile=${abs_top_builddir}/rpmrc \
--define="_build_id_links alldebug" \
--undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be zero build-id files in the main package
@@ -257,6 +258,7 @@ run rpmbuild \
--rcfile=${abs_top_builddir}/rpmrc \
--define="_build_id_links separate" \
--undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be one build-id files in the main and debuginfo package
@@ -441,6 +443,7 @@ run rpmbuild \
--rcfile=${abs_top_builddir}/rpmrc \
--define="_build_id_links compat" \
--undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
--quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
# There should be one build-id files in the main and debuginfo package.
@@ -1125,6 +1128,7 @@ run rpmbuild --quiet \
--rcfile=${abs_top_builddir}/rpmrc \
--undefine="_unique_build_ids" \
--undefine="_unique_debug_names" \
+ --undefine="_unique_debug_srcs" \
-ba "${abs_srcdir}"/data/SPECS/hello.spec
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
@@ -1145,6 +1149,7 @@ run rpmbuild --quiet \
--rcfile=${abs_top_builddir}/rpmrc \
--undefine="_unique_build_ids" \
--undefine="_unique_debug_names" \
+ --undefine="_unique_debug_srcs" \
-ba "${abs_srcdir}"/data/SPECS/hello-r2.spec
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \

View File

@ -1,50 +0,0 @@
From 590081d625b22b5845015949ecb184989377c928 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 9 Mar 2017 09:34:01 +0100
Subject: [PATCH] generateBuildIDs: Don't warn or error for object files
without build-id.
Only loadable ELF images (executables, shared libraries, kernel modules)
should have build-ids. So don't warn or error out when an object file is
found without one.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit e6bdf7a807ea5ca30bc467345dd1e07198945603)
---
build/files.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/build/files.c b/build/files.c
index ca041764f..274b38c62 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1682,8 +1682,10 @@ static int generateBuildIDs(FileList fl)
if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
int fd = open (flp->diskPath, O_RDONLY);
if (fd >= 0) {
+ GElf_Ehdr ehdr;
Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
- if (elf != NULL && elf_kind(elf) == ELF_K_ELF) {
+ if (elf != NULL && elf_kind(elf) == ELF_K_ELF
+ && gelf_getehdr(elf, &ehdr) != NULL) {
const void *build_id;
ssize_t len = dwelf_elf_gnu_build_id (elf, &build_id);
/* len == -1 means error. Zero means no
@@ -1732,9 +1734,14 @@ static int generateBuildIDs(FileList fl)
_("error reading build-id in %s: %s\n"),
flp->diskPath, elf_errmsg (-1));
} else if (len == 0) {
- rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
- _("Missing build-id in %s\n"),
- flp->diskPath);
+ /* Only ET_EXEC, ET_DYN or kernel modules
+ have build-ids. */
+ if (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN
+ || (ehdr.e_type == ET_REL
+ && rpmFileHasSuffix (flp->diskPath, ".ko")))
+ rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
+ _("Missing build-id in %s\n"),
+ flp->diskPath);
} else {
rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
(len < 16

View File

@ -1,33 +0,0 @@
From 5bc9efa303efe933b02cc8679ef3134668839831 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 9 Mar 2017 15:52:12 +0100
Subject: [PATCH] build/files.c: Unset __debug_package implies missing
build-ids aren't fatal.
Historically we have only checked build_ids when __debug_package was
defined. So don't terminate the build if __debug_package is unset, even
when _missing_build_ids_terminate_build is. Only warn.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 22260d3580fcdafa5579128401adf1a05d36f316)
---
build/files.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/build/files.c b/build/files.c
index 274b38c62..b19abf299 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1672,7 +1672,11 @@ static int generateBuildIDs(FileList fl)
if (build_id_links == BUILD_IDS_NONE || rc != 0)
return rc;
- int terminate = rpmExpandNumeric("%{?_missing_build_ids_terminate_build}");
+ /* Historically we have only checked build_ids when __debug_package
+ was defined. So don't terminate the build if __debug_package is
+ unset, even when _missing_build_ids_terminate_build is. */
+ int terminate = (rpmExpandNumeric("%{?_missing_build_ids_terminate_build}")
+ && rpmExpandNumeric("%{?__debug_package}"));
/* Collect and check all build-ids for ELF files in this package. */
int needMain = 0;

View File

@ -1,67 +0,0 @@
From fa61c840ba6be18c6579b247605634c1e2a320f8 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 9 Mar 2017 22:13:01 +0100
Subject: [PATCH] generateBuildIDs: Fix error handling.
commit e6bdf7 made it so that we don't give a warning or error message
for non-kernel ET_REL object files with missing or bad build-ids. But
we still (unintentionally) failed generateBuildIDs which made us skip
generating the cpioList causing an obscure failure message.
Move the sanity check earlier so we don't process such object files at
all. And if there is any real error from generateBuildIDs give a clear
error message and explicitly set processingFailed.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 5bd77379eee167fbdb8d139dc9ab2da74f2a544f)
---
build/files.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/build/files.c b/build/files.c
index b19abf299..fef0c6960 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1686,10 +1686,16 @@ static int generateBuildIDs(FileList fl)
if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
int fd = open (flp->diskPath, O_RDONLY);
if (fd >= 0) {
+ /* Only real ELF files, that are ET_EXEC, ET_DYN or
+ kernel modules (ET_REL files with names ending in .ko)
+ should have build-ids. */
GElf_Ehdr ehdr;
Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
if (elf != NULL && elf_kind(elf) == ELF_K_ELF
- && gelf_getehdr(elf, &ehdr) != NULL) {
+ && gelf_getehdr(elf, &ehdr) != NULL
+ && (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN
+ || (ehdr.e_type == ET_REL
+ && rpmFileHasSuffix (flp->diskPath, ".ko")))) {
const void *build_id;
ssize_t len = dwelf_elf_gnu_build_id (elf, &build_id);
/* len == -1 means error. Zero means no
@@ -1738,11 +1744,6 @@ static int generateBuildIDs(FileList fl)
_("error reading build-id in %s: %s\n"),
flp->diskPath, elf_errmsg (-1));
} else if (len == 0) {
- /* Only ET_EXEC, ET_DYN or kernel modules
- have build-ids. */
- if (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN
- || (ehdr.e_type == ET_REL
- && rpmFileHasSuffix (flp->diskPath, ".ko")))
rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
_("Missing build-id in %s\n"),
flp->diskPath);
@@ -2354,8 +2355,11 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
goto exit;
#if HAVE_LIBDW
- if (generateBuildIDs (&fl) != 0)
+ if (generateBuildIDs (&fl) != 0) {
+ rpmlog(RPMLOG_ERR, _("Generating build-id links failed\n"));
+ fl.processingFailed = 1;
goto exit;
+ }
#endif
/* Verify that file attributes scope over hardlinks correctly. */

View File

@ -1,191 +0,0 @@
From 651264c51dfb13bf78bb969a429719f301497631 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 15 Mar 2017 20:07:29 +0100
Subject: [PATCH] Make sure to reset file attributes for generated build-id
directories.
[Note this patch is currently being tested in Fedora. See bug below.]
When creating the build-id directories we should reset the file attributes
to the defaults. Otherwise if the file list contained an %attr or %defattr
the directories would come out with the wrong mode.
Includes a testcase based on a spec by Igor Gnatenko that fails before
and Check that build-id directories are created with the right permissions
even if the spec file sets attrs explicitly.
https://bugzilla.redhat.com/show_bug.cgi?id=1432372
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit b91dc6106e360f13ff365dfac247191942039152)
---
build/files.c | 21 +++++++++++++++++++
tests/Makefile.am | 2 ++
tests/data/SOURCES/hello.c | 8 +++++++
tests/data/SPECS/hello-attr-buildid.spec | 27 ++++++++++++++++++++++++
tests/rpmbuildid.at | 36 ++++++++++++++++++++++++++++++++
5 files changed, 94 insertions(+)
create mode 100644 tests/data/SOURCES/hello.c
create mode 100644 tests/data/SPECS/hello-attr-buildid.spec
diff --git a/build/files.c b/build/files.c
index fef0c6960..728a44ba2 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1770,6 +1770,7 @@ static int generateBuildIDs(FileList fl)
char *mainiddir = NULL;
char *debugiddir = NULL;
if (rc == 0) {
+ char *attrstr;
/* Add .build-id directories to hold the subdirs/symlinks. */
#define BUILD_ID_DIR "/usr/lib/.build-id"
#define DEBUG_ID_DIR "/usr/lib/debug/.build-id"
@@ -1777,6 +1778,18 @@ static int generateBuildIDs(FileList fl)
mainiddir = rpmGetPath(fl->buildRoot, BUILD_ID_DIR, NULL);
debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
+ /* Make sure to reset all file flags to defaults.
+ Uses parseForAttr to reset ar, arFlags, and specdFlags.
+ Note that parseForAttr pokes at the attrstr, so we cannot
+ just pass a static string. */
+ fl->def.verifyFlags = RPMVERIFY_ALL;
+ fl->cur.verifyFlags = RPMVERIFY_ALL;
+ fl->def.specdFlags |= SPECD_VERIFY;
+ fl->cur.specdFlags |= SPECD_VERIFY;
+ attrstr = xstrdup ("%defattr(-,root,root)");
+ parseForAttr(fl->pool, attrstr, 1, &fl->def);
+ free (attrstr);
+
/* Supported, but questionable. */
if (needMain && needDbg)
rpmlog(RPMLOG_WARNING,
@@ -1786,8 +1799,12 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(mainiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, mainiddir);
} else {
+ rasprintf (&attrstr, "%s %s", "%attr(-,root,root) ",
+ mainiddir);
+ parseForAttr(fl->pool, attrstr, 0, &fl->cur);
fl->cur.isDir = 1;
rc = addFile(fl, mainiddir, NULL);
+ free (attrstr);
}
}
@@ -1795,8 +1812,12 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(debugiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, debugiddir);
} else {
+ rasprintf (&attrstr, "%s %s", "%attr(-,root,root) ",
+ debugiddir);
+ parseForAttr(fl->pool, attrstr, 0, &fl->cur);
fl->cur.isDir = 1;
rc = addFile(fl, debugiddir, NULL);
+ free (attrstr);
}
}
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 10555ce9a..d9586da1d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -68,6 +68,8 @@ EXTRA_DIST += data/RPMS/hello-2.0-1.i686.rpm
EXTRA_DIST += data/RPMS/hello-2.0-1.x86_64.rpm
EXTRA_DIST += data/SRPMS/foo-1.0-1.src.rpm
EXTRA_DIST += data/SRPMS/hello-1.0-1.src.rpm
+EXTRA_DIST += data/SOURCES/hello.c
+EXTRA_DIST += data/SPECS/hello-attr-buildid.spec
# testsuite voodoo
AUTOTEST = $(AUTOM4TE) --language=autotest
diff --git a/tests/data/SOURCES/hello.c b/tests/data/SOURCES/hello.c
new file mode 100644
index 000000000..020484eed
--- /dev/null
+++ b/tests/data/SOURCES/hello.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main (void)
+{
+ printf ("Hello, world!\n");
+ return 0;
+}
diff --git a/tests/data/SPECS/hello-attr-buildid.spec b/tests/data/SPECS/hello-attr-buildid.spec
new file mode 100644
index 000000000..cdab95fff
--- /dev/null
+++ b/tests/data/SPECS/hello-attr-buildid.spec
@@ -0,0 +1,27 @@
+Name: test
+Version: 1.0
+Release: 1
+Summary: Test
+
+License: Public Domain
+URL: https://fedoraproject.org
+Source: hello.c
+
+%description
+%{summary}.
+
+%prep
+%autosetup -c -D -T
+cp -a %{S:0} .
+
+%build
+gcc -g hello.c -o hello
+
+%install
+mkdir -p %{buildroot}%{_bindir}
+install -D -p -m 0755 -t %{buildroot}%{_bindir} hello
+
+%files
+%attr(644,root,root) %{_bindir}/hello
+
+%changelog
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index 15c06202f..1cae26dbf 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -1166,3 +1166,39 @@ if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi
],
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Check that build-id directories are created with the right permissions
+# even if the spec file sets attrs explicitly.
+AT_SETUP([rpmbuild buildid attrs])
+AT_KEYWORDS([build] [debuginfo] [buildid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+# Build, contains one ELF which should have a buildid.
+run rpmbuild \
+ --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="_build_id_links compat" \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --quiet -ba "${abs_srcdir}"/data/SPECS/hello-attr-buildid.spec
+
+run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
+ ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm \
+ | grep "build-id d"
+
+run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
+ ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm \
+ | grep "build-id d"
+],
+[0],
+[/usr/lib/.build-id drwxr-xr-x
+/usr/lib/debug/.build-id drwxr-xr-x
+],
+[ignore])
+AT_CLEANUP

View File

@ -1,126 +0,0 @@
From 20636f4358db0cb85f2251333190626dc2e4ee02 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 19 May 2017 23:11:39 +0200
Subject: [PATCH] rpmbuild: Reset attrFlags in generateBuildIDs.
Debuginfo directories and files could be marked as configuration files
if the file list ended with a config file.
Patch by Panu Matilainen. Testcase by me.
https://bugzilla.redhat.com/show_bug.cgi?id=1449732
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 9d942049cf929d5a053c239cdd64f5b97d182c14)
Conflicts:
tests/Makefile.am
---
build/files.c | 2 ++
tests/Makefile.am | 1 +
tests/data/SPECS/hello-config-buildid.spec | 30 ++++++++++++++++++++++++++++
tests/rpmbuildid.at | 32 ++++++++++++++++++++++++++++++
4 files changed, 65 insertions(+)
create mode 100644 tests/data/SPECS/hello-config-buildid.spec
diff --git a/build/files.c b/build/files.c
index 728a44ba2..6c0ca39ef 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1782,6 +1782,8 @@ static int generateBuildIDs(FileList fl)
Uses parseForAttr to reset ar, arFlags, and specdFlags.
Note that parseForAttr pokes at the attrstr, so we cannot
just pass a static string. */
+ fl->cur.attrFlags = 0;
+ fl->def.attrFlags = 0;
fl->def.verifyFlags = RPMVERIFY_ALL;
fl->cur.verifyFlags = RPMVERIFY_ALL;
fl->def.specdFlags |= SPECD_VERIFY;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d9586da1d..83586ec67 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,6 +70,7 @@ EXTRA_DIST += data/SRPMS/foo-1.0-1.src.rpm
EXTRA_DIST += data/SRPMS/hello-1.0-1.src.rpm
EXTRA_DIST += data/SOURCES/hello.c
EXTRA_DIST += data/SPECS/hello-attr-buildid.spec
+EXTRA_DIST += data/SPECS/hello-config-buildid.spec
# testsuite voodoo
AUTOTEST = $(AUTOM4TE) --language=autotest
diff --git a/tests/data/SPECS/hello-config-buildid.spec b/tests/data/SPECS/hello-config-buildid.spec
new file mode 100644
index 000000000..ca2d30db3
--- /dev/null
+++ b/tests/data/SPECS/hello-config-buildid.spec
@@ -0,0 +1,30 @@
+Name: test
+Version: 1.0
+Release: 1
+Summary: Test
+
+License: Public Domain
+URL: https://fedoraproject.org
+Source: hello.c
+
+%description
+%{summary}.
+
+%prep
+%autosetup -c -D -T
+cp -a %{S:0} .
+
+%build
+gcc -g hello.c -o hello
+
+%install
+mkdir -p %{buildroot}/bin
+install -D -p -m 0755 -t %{buildroot}/bin hello
+mkdir -p %{buildroot}/etc
+echo "settings" > %{buildroot}/etc/config.file
+
+%files
+%attr(644,root,root) /bin/hello
+%config(noreplace) /etc/config.file
+
+%changelog
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index 1cae26dbf..a0e39782c 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -1202,3 +1202,35 @@ run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
],
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Check that build-id directories are created with the right attributes
+# even if the spec file sets config explicitly.
+AT_SETUP([rpmbuild buildid config attrs])
+AT_KEYWORDS([build] [debuginfo] [buildid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+# Build, contains one ELF which should have a buildid.
+run rpmbuild \
+ --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="_build_id_links compat" \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --quiet -ba "${abs_srcdir}"/data/SPECS/hello-config-buildid.spec
+
+# Should contain one config file.
+run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm
+# Should not contain config files.
+run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm
+],
+[0],
+[/etc/config.file
+],
+[ignore])
+AT_CLEANUP

View File

@ -1,34 +0,0 @@
From 8e74618100580a1370b9045296c4d2d37340735f Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 16 Mar 2017 22:53:54 +0100
Subject: [PATCH] debugedit: Fix edit_dwarf2_line replace_dirs -> replace_files
typo.
We wouldn't replace the changed file names if replace_dirs was false,
but replace_files was true. This could overrun the new debug_line data
buffer if the original file name was larger than the replacement. It
wasn't found before because often when we need to replace files we
also would have to replace dirs.
This fixes the kubernetes build in fedora.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit dc759bc655ff1c18a08d77dd31dedfe3ae1025b0)
---
tools/debugedit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 4798c6370..87a423fdb 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1185,7 +1185,7 @@ edit_dwarf2_line (DSO *dso)
{
const char *file = (const char *) optr;
const char *file_path = NULL;
- if (t->replace_dirs)
+ if (t->replace_files)
{
file_path = skip_dir_prefix (file, base_dir);
if (file_path != NULL)

View File

@ -1,42 +0,0 @@
From 430f012c5794873a84db81b93c5858ca96ea4559 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 17 Mar 2017 11:14:00 +0100
Subject: [PATCH] build/files.c (processPackageFiles): Don't call
generateBuildIDs for noarch.
We don't want to do build-id processing for noarch packages. It might be
that noarch packages do contain architecture depended files, but those are
already handled by processBinaryFiles.
This fixes the building of openbios in fedora.
https://bugzilla.redhat.com/show_bug.cgi?id=1433129
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 5e82c7e8a8fc05195cdf622d0a120b9e70a9371b)
---
build/files.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/build/files.c b/build/files.c
index 6c0ca39ef..9e58ae547 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2378,10 +2378,14 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
goto exit;
#if HAVE_LIBDW
- if (generateBuildIDs (&fl) != 0) {
- rpmlog(RPMLOG_ERR, _("Generating build-id links failed\n"));
- fl.processingFailed = 1;
- goto exit;
+ /* Check build-ids and add build-ids links for files to package list. */
+ const char *arch = headerGetString(pkg->header, RPMTAG_ARCH);
+ if (!rstreq(arch, "noarch")) {
+ if (generateBuildIDs (&fl) != 0) {
+ rpmlog(RPMLOG_ERR, _("Generating build-id links failed\n"));
+ fl.processingFailed = 1;
+ goto exit;
+ }
}
#endif

View File

@ -1,117 +0,0 @@
From 5598e24ef8aef14727ff72eea71ec460200bc2e3 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 17 Mar 2017 21:03:35 +0100
Subject: [PATCH] debugedit: Fix cross-endian build-id reading and updating
section data.
debugedit doesn't read raw mmap data any longer. Which made the complex
way to read the build-id unnecessary (and it was broken for cross-endian).
Just use gelf_getnote to read the notes.
Also in some special cases when only the debug_info or build_id data
was updated, but no section changed size and we had to preserve the
allocated section headers we could hit a bug in elfutils that could
trash some section data in case there were gaps between non-dirty and
dirty sections. See https://sourceware.org/bugzilla/show_bug.cgi?id=21199
Add a workaround for that issue.
This fixes the kompose package build on fedora ppc64.
And makes it possible to replicate that issue on x86_64.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit a6e767600309bdb1f8af33b44563a1187fb0dbc4)
---
tools/debugedit.c | 63 +++++++++++++++++++++++++++----------------------------
1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 87a423fdb..0f373162d 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -2581,40 +2581,25 @@ main (int argc, char *argv[])
break;
case SHT_NOTE:
if (do_build_id
- && build_id == NULL && (dso->shdr[i].sh_flags & SHF_ALLOC))
+ && build_id == 0 && (dso->shdr[i].sh_flags & SHF_ALLOC))
{
/* Look for a build-ID note here. */
+ size_t off = 0;
+ GElf_Nhdr nhdr;
+ size_t name_off;
+ size_t desc_off;
Elf_Data *data = elf_getdata (elf_getscn (dso->elf, i), NULL);
- Elf32_Nhdr nh;
- Elf_Data dst =
- {
- .d_version = EV_CURRENT, .d_type = ELF_T_NHDR,
- .d_buf = &nh, .d_size = sizeof nh
- };
- Elf_Data src = dst;
- src.d_buf = data->d_buf;
- assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
- while ((char *) data->d_buf + data->d_size -
- (char *) src.d_buf > (int) sizeof nh
- && elf32_xlatetom (&dst, &src, dso->ehdr.e_ident[EI_DATA]))
- {
- Elf32_Word len = sizeof nh + nh.n_namesz;
- len = (len + 3) & ~3;
-
- if (nh.n_namesz == sizeof "GNU" && nh.n_type == 3
- && !memcmp ((char *) src.d_buf + sizeof nh, "GNU", sizeof "GNU"))
- {
- build_id = data;
- build_id_offset = (char *) src.d_buf + len -
- (char *) data->d_buf;
- build_id_size = nh.n_descsz;
- break;
- }
-
- len += nh.n_descsz;
- len = (len + 3) & ~3;
- src.d_buf = (char *) src.d_buf + len;
- }
+ while ((off = gelf_getnote (data, off,
+ &nhdr, &name_off, &desc_off)) > 0)
+ if (nhdr.n_type == NT_GNU_BUILD_ID
+ && nhdr.n_namesz == sizeof "GNU"
+ && (memcmp ((char *)data->d_buf + name_off, "GNU",
+ sizeof "GNU") == 0))
+ {
+ build_id = data;
+ build_id_offset = desc_off;
+ build_id_size = nhdr.n_descsz;
+ }
}
break;
default:
@@ -2622,6 +2607,20 @@ main (int argc, char *argv[])
}
}
+ /* Normally we only need to explicitly update the section headers
+ and data when any section data changed size. But because of a bug
+ in elfutils before 0.169 we will have to update and write out all
+ section data if any data has changed (when ELF_F_LAYOUT was
+ set). https://sourceware.org/bugzilla/show_bug.cgi?id=21199 */
+ bool need_update = need_strp_update || need_stmt_update;
+
+#if !_ELFUTILS_PREREQ (0, 169)
+ /* string replacements or build_id updates don't change section size. */
+ need_update = (need_update
+ || need_string_replacement
+ || (do_build_id && build_id != NULL));
+#endif
+
/* We might have changed the size of some debug sections. If so make
sure the section headers are updated and the data offsets are
correct. We set ELF_F_LAYOUT above because we don't want libelf
@@ -2631,7 +2630,7 @@ main (int argc, char *argv[])
anything for the phdrs allocated sections. Keep the offset of
allocated sections so they are at the same place in the file. Add
unallocated ones after the allocated ones. */
- if (dso->phnum != 0 && (need_strp_update || need_stmt_update))
+ if (dso->phnum != 0 && need_update)
{
Elf *elf = dso->elf;
GElf_Off last_offset;

View File

@ -1,57 +0,0 @@
From 8cd45c82a968404929e00dce65644f81e906591b Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 3 Mar 2017 23:51:13 +0100
Subject: [PATCH] tests/tpmbuild.at: Make file sed regexp more strict to
extract BuildID.
In some testcases we extract the BuildID with the file command.
Unfortunately the file command output changed slightly between versions.
Make the sed regexp more strict by only matching a hex-string.
Also properly "escape" [ and ] which inside an AT_CHECK should be [[ and ]].
Tested against file versions 5.11, 5.29 and 5.30.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit f0a581925ad4c948dc58cc8f9a55399ad8de351e)
---
tests/rpmbuild.at | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index a46822f52..dcbdd2cad 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -423,11 +423,11 @@ hello2_file=./usr/local/bin/hello2
test -f $hello_file || echo "no hello file: $hello_file"
test -f $hello2_file || echo "no hello2 file: $hello2_file"
-id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id1debug=$(file $hello_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-idmulti=$(file $hello_multi_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
@@ -516,11 +516,11 @@ hello2_file=./usr/local/bin/hello2
test -f $hello_file || echo "no hello file: $hello_file"
test -f $hello2_file || echo "no hello2 file: $hello2_file"
-id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id1debug=$(file $hello_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
-idmulti=$(file $hello_multi_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"

View File

@ -1,219 +0,0 @@
From 58f2b095c0d1507ad09990669f1ae03f6f1d931f Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 20 Mar 2017 09:55:44 +0100
Subject: [PATCH] tests/rpmbuildid.at: Make file sed regexp more strict to
extract BuildID.
Like commit f0a5819 for rpmbuild.at. In the case of rpmbuildid.at the
sed expression looked to work, but only matched by accident. Make the sed
regexp more strict by only matching a hex-string. And properly "escape"
[ and ] which inside an AT_CHECK should be [[ and ]].
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 60f958ab41f854f8839fe04f1a67d1752ad7eda0)
---
tests/rpmbuildid.at | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
index a0e39782c..158ce122d 100644
--- a/tests/rpmbuildid.at
+++ b/tests/rpmbuildid.at
@@ -97,7 +97,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -120,7 +120,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello.debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -190,7 +190,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -213,7 +213,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -283,7 +283,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -306,7 +306,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello.debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -375,7 +375,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -398,7 +398,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -469,7 +469,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -492,7 +492,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello.debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -574,7 +574,7 @@ main_file=./usr/local/bin/hello
test -f "${main_file}" || echo "No main file ${main_file}"
# Extract the build-id from the main file
-id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
test -L "$id_main_file" || echo "No build-id file $id_main_file"
@@ -597,7 +597,7 @@ debug_file=./usr/lib/debug/usr/local/bin/hello-*debug
test -f ${debug_file} || echo "No debug file ${debug_file}"
# Extract the build-id from the .debug file
-id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
@@ -662,7 +662,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# alldebug not here...
id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
@@ -732,7 +732,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# alldebug not here...
id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
@@ -799,7 +799,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# separate build-ids split...
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
@@ -866,7 +866,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# separate build-ids split...
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
@@ -930,7 +930,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# compat build-ids split...
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
@@ -1009,7 +1009,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
hello_file=./usr/local/bin/hello
# Extract the build-id from the main file
-id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# compat build-ids split...
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
@@ -1084,7 +1084,7 @@ 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[.*]=\(.*\),.*/\1/')
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# Make sure we generate a new one
rm $hello_file
@@ -1101,7 +1101,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
# Extract the build-id from the main file
test -f $hello_file || echo "No $hello_file"
-id2=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
if test "$id1" == "$id2"; then echo "equal $id1"; else echo "unequal"; fi
],
@@ -1138,7 +1138,7 @@ 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[.*]=\(.*\),.*/\1/')
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
# Make sure we generate a new one
rm $hello_file
@@ -1157,7 +1157,7 @@ rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
# Extract the build-id from the main file
test -f $hello_file || echo "No $hello_file"
-id2=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi
],

View File

@ -1,59 +0,0 @@
From c21bf3aefdcfb22bc3f41888ef090c6d5a45baec Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 20 Mar 2017 11:52:00 +0100
Subject: [PATCH] build/files.c: Only check build-ids for executable files in
the main package.
generateBuildIDs should mimic what find-debuginfo.sh does. Only check
build-ids for executable files in non-debuginfo packages. This moves the
isDbg check up so the is executeble check can be done when the file is
part of the main package.
This fixes the build of qemu and uboot-tools in fedora. Both ship
non-executable ELF bios files in architecture specific packages.
https://bugzilla.redhat.com/show_bug.cgi?id=1433837
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit c9035d464a6ac3853b5dc705e0df1734ce915cd4)
---
build/files.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/build/files.c b/build/files.c
index 9e58ae547..9f7def78c 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1684,6 +1684,19 @@ static int generateBuildIDs(FileList fl)
for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
struct stat sbuf;
if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
+ /* We determine whether this is a main or
+ debug ELF based on path. */
+ #define DEBUGPATH "/usr/lib/debug/"
+ int isDbg = strncmp (flp->cpioPath,
+ DEBUGPATH, strlen (DEBUGPATH)) == 0;
+
+ /* For the main package files mimic what find-debuginfo.sh does.
+ Only check build-ids for executable files. Debug files are
+ always non-executable. */
+ if (!isDbg
+ && (sbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
+ continue;
+
int fd = open (flp->diskPath, O_RDONLY);
if (fd >= 0) {
/* Only real ELF files, that are ET_EXEC, ET_DYN or
@@ -1705,12 +1718,8 @@ static int generateBuildIDs(FileList fl)
is 128 bits) and 64 bytes (largest sha3 is 512
bits), common is 20 bytes (sha1 is 160 bits). */
if (len >= 16 && len <= 64) {
- /* We determine whether this is a main or
- debug ELF based on path. */
- #define DEBUGPATH "/usr/lib/debug/"
int addid = 0;
- if (strncmp (flp->cpioPath,
- DEBUGPATH, strlen (DEBUGPATH)) == 0) {
+ if (isDbg) {
needDbg = 1;
addid = 1;
}

View File

@ -1,48 +0,0 @@
From 419ae36f2c0dad195737982b446fcace507d0814 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 21 Mar 2017 16:57:44 +0100
Subject: [PATCH] debugedit: Fix off-by-one adding DW_FORM_string replacement
slashes.
We would put one too many slashes in between the new dest_dir and file name
part of the replacement of a DW_FORM_string in the .debug_info. If there
was file part then we would overwrite the first character of the name. If
there was no file part at all then this would overwrite the zero terminator
and cause a crash reading the rest of the data.
A crash did happen while building the docker package on fedora s390x.
https://bugzilla.redhat.com/show_bug.cgi?id=1434347
The reason neither issue would normally trigger is because if we do detect
that the dest_dir is larger than the base_dir we refuse to replace anything.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tools/debugedit.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 0f373162d..b618dceb5 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1507,12 +1507,16 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
comp_dir, base_dir, dest_dir);
else
{
- /* Add one or more slashes in between to
- fill up all space (replacement must be
- of the same length). */
+ /* Add zero (if no file part), one or more
+ slashes in between the new dest_dir and the
+ file name to fill up all space (replacement
+ DW_FORM_string must be of the same length).
+ We don't need to copy the old file name (if
+ any) or the zero terminator, because those
+ are already at the end of the string. */
memcpy (ptr, dest_dir, dest_len);
memset (ptr + dest_len, '/',
- orig_len - new_len + 1);
+ orig_len - new_len);
}
}
}

View File

@ -1,174 +0,0 @@
From 6328e1e0da3ba26885f095ccbd83d223d5830527 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 5 Jan 2017 13:47:28 +0200
Subject: [PATCH] Unbreak short-circuited binary builds
Commit bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 broke short-circuited
binary builds (which can be handy for testing when working on large
packages), eg:
rpmbuild -bi foo.spec; rpmbuild -bb --short-circuit foo.spec
The problem is that in a short-circuited build all the links already
exist and point to the right place, but the code doesn't realize this
and creates new links instead, which leaves the old links unowned
in the buildroot which ultimately causes the build to fail with
"Installed (but unpackaged) file(s) found" for the previously created
build-id links.
When checking for pre-existing links see if they already point to
the right file and in that case just reuse it instead of creating new ones.
Keep track of duplicate build-ids found by noticing existing links that
point to different targets. But don't do this for compat links, they should
just point to the last (duplicate) main build-id symlink found.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit eea78b023539875309b7d38e4c8924f647644924)
---
build/files.c | 71 ++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 51 insertions(+), 20 deletions(-)
diff --git a/build/files.c b/build/files.c
index 9f7def78c..2f02587f0 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1565,11 +1565,12 @@ exit:
static int addNewIDSymlink(FileList fl,
char *targetpath, char *idlinkpath,
- int isDbg, int isCompat)
+ int isDbg, int *dups)
{
const char *linkerr = _("failed symlink");
int rc = 0;
int nr = 0;
+ int exists = 0;
char *origpath, *linkpath;
if (isDbg)
@@ -1579,6 +1580,26 @@ static int addNewIDSymlink(FileList fl,
origpath = linkpath;
while (faccessat(AT_FDCWD, linkpath, F_OK, AT_SYMLINK_NOFOLLOW) == 0) {
+ /* We don't care about finding dups for compat links, they are
+ OK as is. Otherwise we will need to double check if
+ existing link points to the correct target. */
+ if (dups == NULL)
+ {
+ exists = 1;
+ break;
+ }
+
+ char ltarget[PATH_MAX];
+ ssize_t llen;
+ /* In short-circuited builds the link might already exist */
+ if ((llen = readlink(linkpath, ltarget, sizeof(ltarget)-1)) != -1) {
+ ltarget[llen] = '\0';
+ if (rstreq(ltarget, targetpath)) {
+ exists = 1;
+ break;
+ }
+ }
+
if (nr > 0)
free(linkpath);
nr++;
@@ -1586,21 +1607,16 @@ static int addNewIDSymlink(FileList fl,
isDbg ? ".debug" : "");
}
- char *symtarget = targetpath;
- if (nr > 0 && isCompat)
- rasprintf (&symtarget, "%s.%d", targetpath, nr);
-
- if (symlink(symtarget, linkpath) < 0) {
+ if (!exists && symlink(targetpath, linkpath) < 0) {
rc = 1;
rpmlog(RPMLOG_ERR, "%s: %s -> %s: %m\n",
- linkerr, linkpath, symtarget);
+ linkerr, linkpath, targetpath);
} else {
fl->cur.isDir = 0;
rc = addFile(fl, linkpath, NULL);
}
- /* Don't warn (again) if this is a compat id-link, we retarget it. */
- if (nr > 0 && !isCompat) {
+ if (nr > 0) {
/* Lets see why there are multiple build-ids. If the original
targets are hard linked, then it is OK, otherwise warn
something fishy is going on. Would be nice to call
@@ -1629,8 +1645,8 @@ static int addNewIDSymlink(FileList fl,
free(origpath);
if (nr > 0)
free(linkpath);
- if (nr > 0 && isCompat)
- free(symtarget);
+ if (dups != NULL)
+ *dups = nr;
return rc;
}
@@ -1872,6 +1888,7 @@ static int generateBuildIDs(FileList fl)
|| (rc = addFile(fl, buildidsubdir, NULL)) == 0) {
char *linkpattern, *targetpattern;
char *linkpath, *targetpath;
+ int dups = 0;
if (isDbg) {
linkpattern = "%s/%s";
targetpattern = "../../../../..%s";
@@ -1883,7 +1900,7 @@ static int generateBuildIDs(FileList fl)
buildidsubdir, &ids[i][2]);
rasprintf(&targetpath, targetpattern, paths[i]);
rc = addNewIDSymlink(fl, targetpath, linkpath,
- isDbg, 0);
+ isDbg, &dups);
/* We might want to have a link from the debug
build_ids dir to the main one. We create it
@@ -1906,16 +1923,30 @@ static int generateBuildIDs(FileList fl)
&& build_id_links == BUILD_IDS_COMPAT) {
/* buildidsubdir already points to the
debug buildid. We just need to setup
- the symlink to the main one. */
+ the symlink to the main one. There
+ might be duplicate IDs, those are found
+ by the addNewIDSymlink above. Target
+ the last found duplicate, if any. */
free(linkpath);
free(targetpath);
- rasprintf(&linkpath, "%s/%s",
- buildidsubdir, &ids[i][2]);
- rasprintf(&targetpath,
- "../../../.build-id%s/%s",
- subdir, &ids[i][2]);
+ if (dups == 0)
+ {
+ rasprintf(&linkpath, "%s/%s",
+ buildidsubdir, &ids[i][2]);
+ rasprintf(&targetpath,
+ "../../../.build-id%s/%s",
+ subdir, &ids[i][2]);
+ }
+ else
+ {
+ rasprintf(&linkpath, "%s/%s.%d",
+ buildidsubdir, &ids[i][2], dups);
+ rasprintf(&targetpath,
+ "../../../.build-id%s/%s.%d",
+ subdir, &ids[i][2], dups);
+ }
rc = addNewIDSymlink(fl, targetpath, linkpath,
- 0, 1);
+ 0, NULL);
}
if (rc == 0 && isDbg
@@ -1953,7 +1984,7 @@ static int generateBuildIDs(FileList fl)
rasprintf(&targetpath, "../../../../..%s",
targetstr);
rc = addNewIDSymlink(fl, targetpath,
- linkpath, 0, 0);
+ linkpath, 0, &dups);
free(targetstr);
}
}

View File

@ -1,39 +0,0 @@
From 349489c3219e31efd552d87e255b06a864d1c034 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sun, 16 Apr 2017 18:16:02 +0200
Subject: [PATCH] find-debuginfo.sh: Only add minisymtab for executables or
shared libraries.
It only makes sense to add a minisymtab for executables and shared
libraries. Other executable ELF files (like kernel modules) don't need it.
Since those don't have a dynsym section trying to add it will fail and
produce confusing errors from nm.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 3790a6872749a9601be6044be7d8fb0951131376)
---
scripts/find-debuginfo.sh | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 1420ef6cd..f1ffcd7d8 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -347,7 +347,16 @@ while read nlinks inum f; do
fi
# strip -g implies we have full symtab, don't add mini symtab in that case.
- $strip_g || ($include_minidebug && add_minidebug "${debugfn}" "$f")
+ # It only makes sense to add a minisymtab for executables and shared
+ # libraries. Other executable ELF files (like kernel modules) don't need it.
+ if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
+ skip_mini=true
+ case "$(file -bi "$f")" in
+ application/x-sharedlib*) skip_mini=false ;;
+ application/x-executable*) skip_mini=false ;;
+ esac
+ $skip_mini || add_minidebug "${debugfn}" "$f"
+ fi
echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"

View File

@ -1,282 +0,0 @@
From 525282b9a8b78c2890c752e45c4dc7dcf25f42cb Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
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.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 6e9fd97f6dba9e04cfd33225b610272b964cc5fc)
Conflicts:
macros.in
scripts/find-debuginfo.sh
---
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 e48ef60c8..c5b1a0b26 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} %{?_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.
@@ -488,6 +488,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 f1ffcd7d8..1d3dc0623 100644
--- 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=
@@ -107,6 +111,9 @@ while [ $# -gt 0 ]; do
-m)
include_minidebug=true
;;
+ -n)
+ no_recompute_build_id=true
+ ;;
-i)
include_gdb_index=true
;;
@@ -149,6 +156,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 @@ while read nlinks inum f; do
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 158ce122d..4fab3d5dc 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 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. */

View File

@ -1,35 +0,0 @@
From ba8f2239de528f02d272aed71599a4a560ddd238 Mon Sep 17 00:00:00 2001
From: Robin Lee <cheeselee@fedoraproject.org>
Date: Sat, 8 Apr 2017 21:21:39 +0800
Subject: [PATCH] Fix non-standard inherented modes of directories in debuginfo
In case that binary compiled from source generated in /tmp, a
/usr/src/debug/tmp directory will be created with the same mode as
/tmp, a.k.a 777, which should be avoided.
Fixes: rhbz#641022
(cherry picked from commit c707ab26362e795d3f9dba4eb87dc7ed99a28bcb)
---
scripts/find-debuginfo.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
mode change 100644 => 100755 scripts/find-debuginfo.sh
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
old mode 100644
new mode 100755
index 1d3dc0623..5087c4050
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -443,9 +443,10 @@ if [ -s "$SOURCEFILE" ]; then
mkdir -p "${RPM_BUILD_ROOT}${debug_dest_name}"
LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(<internal>|<built-in>)$' |
(cd "${debug_base_name}"; cpio -pd0mL "${RPM_BUILD_ROOT}${debug_dest_name}")
- # stupid cpio creates new directories in mode 0700, fixup
+ # stupid cpio creates new directories in mode 0700,
+ # and non-standard modes may be inherented from original directories, fixup
find "${RPM_BUILD_ROOT}${debug_dest_name}" -type d -print0 |
- xargs --no-run-if-empty -0 chmod a+rx
+ xargs --no-run-if-empty -0 chmod 0755
fi
if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then

View File

@ -1,78 +0,0 @@
From 387acd5cb74c968b4751a1c2c731964fc1ab6c3f Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 21 Apr 2017 17:33:26 +0200
Subject: [PATCH] debugedit: Only output comp_dir under build dir (once).
The fix for rhbz#444310 (commit c1a5eb - Include empty CU current dirs)
was a little greedy. It would also include comp_dirs outside the build
root. Those are unnecessary and we don't have a good way to store them.
Such dirs (e.g. /tmp) would then show up at the root of /usr/src/debug.
Fix this by including only comp_dirs under base_dir. Also only output
all dirs once (during phase zero) and don't output empty dirs (which
was harmless but would produce a warning from cpio).
This still includes all empty dirs from the original rhbz#444310
nodir testcase and it is an alternative fix for rhbz#641022
(commit c707ab).
Both fixes are necessary in case of an unexpected mode for a directory
actually in the build root that we want to include in the source list.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit e795899780337dea751d85db8f381eff3fe75275)
---
tools/debugedit.c | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 8444e030e..bf115136c 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1680,30 +1680,23 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
/* Ensure the CU current directory will exist even if only empty. Source
filenames possibly located in its parent directories refer relatively to
it and the debugger (GDB) cannot safely optimize out the missing
- CU current dir subdirectories. */
- if (comp_dir && list_file_fd != -1)
+ CU current dir subdirectories. Only do this once in phase one. And
+ only do this for dirs under our build/base_dir. Don't output the
+ empty string (in case the comp_dir == base_dir). */
+ if (phase == 0 && base_dir && comp_dir && list_file_fd != -1)
{
- const char *p = NULL;
- size_t size;
-
- if (base_dir)
- {
- p = skip_dir_prefix (comp_dir, base_dir);
- if (p == NULL && dest_dir != NULL)
- p = skip_dir_prefix (comp_dir, dest_dir);
- }
-
- if (p == NULL)
- p = comp_dir;
-
- size = strlen (p) + 1;
- while (size > 0)
- {
- ssize_t ret = write (list_file_fd, p, size);
- if (ret == -1)
- break;
- size -= ret;
- p += ret;
+ const char *p = skip_dir_prefix (comp_dir, base_dir);
+ if (p != NULL && p[0] != '\0')
+ {
+ size_t size = strlen (p) + 1;
+ while (size > 0)
+ {
+ ssize_t ret = write (list_file_fd, p, size);
+ if (ret == -1)
+ break;
+ size -= ret;
+ p += ret;
+ }
}
}

View File

@ -1,111 +0,0 @@
From 534fae47e4d05fd27c277c9e04ad238e608289f5 Mon Sep 17 00:00:00 2001
From: Michal Marek <mmarek@suse.com>
Date: Sat, 10 Sep 2016 23:13:24 +0200
Subject: [PATCH] find-debuginfo.sh: Split directory traversal and debuginfo
extraction
This siplifies the handling of hardlinks a bit and allows a later patch
to parallelize the debuginfo extraction.
Signed-off-by: Michal Marek <mmarek@suse.com>
(cherry picked from commit 038bfe01796f751001e02de41c5d8678f511f366)
Conflicts:
scripts/find-debuginfo.sh
---
scripts/find-debuginfo.sh | 53 ++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 19 deletions(-)
mode change 100755 => 100644 scripts/find-debuginfo.sh
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
old mode 100755
new mode 100644
index 5087c4050..097b749bb
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -283,32 +283,36 @@ set -o pipefail
strict_error=ERROR
$strict || strict_error=WARNING
-# Strip ELF binaries
+temp=$(mktemp -d ${TMPDIR:-/tmp}/find-debuginfo.XXXXXX)
+trap 'rm -rf "$temp"' EXIT
+
+# Build a list of unstripped ELF files and their hardlinks
+touch "$temp/primary"
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
\( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
-print |
file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' |
xargs --no-run-if-empty stat -c '%h %D_%i %n' |
while read nlinks inum f; do
- get_debugfn "$f"
- [ -f "${debugfn}" ] && continue
-
- # If this file has multiple links, keep track and make
- # the corresponding .debug files all links to one file too.
if [ $nlinks -gt 1 ]; then
- eval linked=\$linked_$inum
- if [ -n "$linked" ]; then
- eval id=\$linkedid_$inum
- link=$debugfn
- get_debugfn "$linked"
- echo "hard linked $link to $debugfn"
- mkdir -p "$(dirname "$link")" && ln -nf "$debugfn" "$link"
+ var=seen_$inum
+ if test -n "${!var}"; then
+ echo "$inum $f" >>"$temp/linked"
continue
else
- eval linked_$inum=\$f
- echo "file $f has $[$nlinks - 1] other hard links"
+ read "$var" < <(echo 1)
fi
fi
+ echo "$nlinks $inum $f" >>"$temp/primary"
+done
+
+# Strip ELF binaries
+do_file()
+{
+ local nlinks=$1 inum=$2 f=$3 id link linked
+
+ get_debugfn "$f"
+ [ -f "${debugfn}" ] && return
echo "extracting debug info from $f"
build_id_seed=
@@ -328,9 +332,6 @@ while read nlinks inum f; do
fi
id=$(${lib_rpm_dir}/debugedit -b $debug_base_name -d $debug_dest_name \
$no_recompute -i $build_id_seed -l "$SOURCEFILE" "$f") || exit
- if [ $nlinks -gt 1 ]; then
- eval linkedid_$inum=\$id
- fi
if [ -z "$id" ]; then
echo >&2 "*** ${strict_error}: No build ID note found in $f"
$strict && exit 2
@@ -376,7 +377,21 @@ while read nlinks inum f; do
echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
-done || exit
+ # If this file has multiple links, make the corresponding .debug files
+ # all links to one file too.
+ if [ $nlinks -gt 1 ]; then
+ grep "^$inum " "$temp/linked" | while read inum linked; do
+ link=$debugfn
+ get_debugfn "$linked"
+ echo "hard linked $link to $debugfn"
+ mkdir -p "$(dirname "$debugfn")" && ln -nf "$link" "$debugfn"
+ done
+ fi
+}
+
+while read nlinks inum f; do
+ do_file "$nlinks" "$inum" "$f"
+done <"$temp/primary"
# Invoke the DWARF Compressor utility.
if $run_dwz \

View File

@ -1,34 +0,0 @@
From 3e0419ebc11494d9848decfdfb4909cbce9448b7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 28 Jun 2017 14:21:32 +0200
Subject: [PATCH] find-debuginfo.sh: Use 'return', not 'continue', to break out
do_file().
commit 038bfe "Split directory traversal and debuginfo extraction"
put the core of a while loop into its own function 'do_file()'.
That means that instead of using 'continue' to break out early it now
needs to use 'return'. Otherwise the script will give errors like:
continue: only meaningful in a `for', `while', or `until' loop
https://bugzilla.redhat.com/show_bug.cgi?id=1465170
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit a08e154459d160ff9a9a5576266e685ab85bfc5d)
---
scripts/find-debuginfo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 097b749bb..c435a02e4 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -351,7 +351,7 @@ do_file()
# just has its file names collected and adjusted.
case "$dn" in
/usr/lib/debug/*)
- continue ;;
+ return ;;
esac
mkdir -p "${debugdn}"

View File

@ -1,122 +0,0 @@
From aede94115e077e87504b03bf668ef375290200ad Mon Sep 17 00:00:00 2001
From: Michal Marek <mmarek@suse.com>
Date: Sat, 10 Sep 2016 23:13:25 +0200
Subject: [PATCH] find-debuginfo.sh: Process files in parallel
Add a -j <n> option, which, when used, will spawn <n> processes to do the
debuginfo extraction in parallel. A pipe is used to dispatch the files among
the processes.
Signed-off-by: Michal Marek <mmarek@suse.com>
(cherry picked from commit 1b338aa84d4c67fefa957352a028eaca1a45d1f6)
Conflicts:
macros.in
scripts/find-debuginfo.sh
---
macros.in | 2 +-
scripts/find-debuginfo.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/macros.in b/macros.in
index c5b1a0b26..93e360c79 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} %{?_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}"\
+ %{_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.
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index c435a02e4..d8b718bdf 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -74,6 +74,9 @@ unique_debug_arch=
# Base given by --unique-debug-src-base
unique_debug_src_base=
+# Number of parallel jobs to spawn
+n_jobs=1
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -137,6 +140,13 @@ while [ $# -gt 0 ]; do
-r)
strip_r=true
;;
+ -j)
+ n_jobs=$2
+ shift
+ ;;
+ -j*)
+ n_jobs=${1#-j}
+ ;;
*)
BUILDDIR=$1
shift
@@ -389,9 +399,56 @@ do_file()
fi
}
-while read nlinks inum f; do
- do_file "$nlinks" "$inum" "$f"
-done <"$temp/primary"
+# 16^6 - 1 or about 16 milion files
+FILENUM_DIGITS=6
+run_job()
+{
+ local jobid=$1 filenum
+ local SOURCEFILE=$temp/debugsources.$jobid ELFBINSFILE=$temp/elfbins.$jobid
+
+ >"$SOURCEFILE"
+ >"$ELFBINSFILE"
+ # can't use read -n <n>, because it reads bytes one by one, allowing for
+ # races
+ while :; do
+ filenum=$(dd bs=$(( FILENUM_DIGITS + 1 )) count=1 status=none)
+ if test -z "$filenum"; then
+ break
+ fi
+ do_file $(sed -n "$(( 0x$filenum )) p" "$temp/primary")
+ done
+ echo 0 >"$temp/res.$jobid"
+}
+
+n_files=$(wc -l <"$temp/primary")
+if [ $n_jobs -gt $n_files ]; then
+ n_jobs=$n_files
+fi
+if [ $n_jobs -le 1 ]; then
+ while read nlinks inum f; do
+ do_file "$nlinks" "$inum" "$f"
+ done <"$temp/primary"
+else
+ for ((i = 1; i <= n_files; i++)); do
+ printf "%0${FILENUM_DIGITS}x\\n" $i
+ done | (
+ exec 3<&0
+ for ((i = 0; i < n_jobs; i++)); do
+ # The shell redirects stdin to /dev/null for background jobs. Work
+ # around this by duplicating fd 0
+ run_job $i <&3 &
+ done
+ wait
+ )
+ for f in "$temp"/res.*; do
+ res=$(< "$f")
+ if [ "$res" != "0" ]; then
+ exit 1
+ fi
+ done
+ cat "$temp"/debugsources.* >"$SOURCEFILE"
+ cat "$temp"/elfbins.* >"$ELFBINSFILE"
+fi
# Invoke the DWARF Compressor utility.
if $run_dwz \

View File

@ -1,172 +0,0 @@
From ac275c650fee13ec0fd204bf2b05fbff01a053cd Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Tue, 28 Mar 2017 14:20:50 +0200
Subject: [PATCH] Untangle unique build options in find-debuginfo.sh
Rename --ver-rel option to --build-id-seed, so that it reflects what
it does, not how it is used.
Remove implcit usage of the old --ver-rel option for --unique-debug-arch
and --unique-debug-src-base, instead already call find-debuginfo.sh with
the version included.
Rename --unique-debug-arch to --unique-debug-suffix because it now
also contains the package version.
(cherry picked from commit 4842adfd91c3b37744c66d9f01c0112468fdbf37)
---
macros.in | 13 +++++++++++-
scripts/find-debuginfo.sh | 53 ++++++++++++++++-------------------------------
2 files changed, 30 insertions(+), 36 deletions(-)
diff --git a/macros.in b/macros.in
index 93e360c79..b5bf26ac9 100644
--- a/macros.in
+++ b/macros.in
@@ -180,7 +180,18 @@
# the script. See the script for details.
#
%__debug_install_post \
- %{_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}"\
+ %{_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:--build-id-seed "%{VERSION}-%{RELEASE}"} \\\
+ %{?_unique_debug_names:--unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}"} \\\
+ %{?_unique_debug_srcs:--unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}"} \\\
+ %{?_find_debuginfo_dwz_opts} \\\
+ %{?_find_debuginfo_opts} \\\
+ "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index d8b718bdf..cd2931c0d 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -6,7 +6,7 @@
# [-o debugfiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
-# [--ver-rel VERSION-RELEASE]
+# [--build-id-seed VERSION-RELEASE]
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
# [builddir]
#
@@ -30,7 +30,7 @@
# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
# provide detailed limits. See dwz(1) -l and -L option for details.
#
-# If --ver-rel VERSION-RELEASE is given then debugedit is called to
+# If --build-id-seed VERSION-RELEASE is given then debugedit is called to
# update the build-ids it finds adding the VERSION-RELEASE string as
# seed to recalculate the build-id hash. This makes sure the
# build-ids in the ELF files are unique between versions and releases
@@ -65,11 +65,11 @@ run_dwz=false
dwz_low_mem_die_limit=
dwz_max_die_limit=
-# Version and release of the spec. Given by --ver-rel
-ver_rel=
+# build id seed given by the --build-id-seed option
+build_id_seed=
# Arch given by --unique-debug-arch
-unique_debug_arch=
+unique_debug_suffix=
# Base given by --unique-debug-src-base
unique_debug_src_base=
@@ -96,12 +96,12 @@ while [ $# -gt 0 ]; do
dwz_max_die_limit=$2
shift
;;
- --ver-rel)
- ver_rel=$2
+ --build-id-seed)
+ build_id_seed=$2
shift
;;
- --unique-debug-arch)
- unique_debug_arch=$2
+ --unique-debug-suffix)
+ unique_debug_suffix=$2
shift
;;
--unique-debug-src-base)
@@ -156,18 +156,8 @@ while [ $# -gt 0 ]; do
shift
done
-if test -z "$ver_rel" -a -n "$unique_debug_arch"; then
- echo >&2 "*** ERROR: --unique-debug-arch (${unique_debug_arch}) needs --ver-rel (${ver_rel})"
- exit 2
-fi
-
-if test -z "$unique_debug_arch" -a -n "$unique_debug_src_base"; then
- echo >&2 "*** ERROR: --unique-debug-src-base (${unique_debug_src_base}) needs --unique-debug-arch (${unique_debug_arch})"
- 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"
+if test -n "$build_id_seed" -a "$no_recompute_build_id" = "true"; then
+ echo >&2 "*** ERROR: --build-id-seed (unique build-ids) and -n (do not recompute build-id) cannot be used together"
exit 2
fi
@@ -278,12 +268,7 @@ debug_link()
get_debugfn()
{
dn=$(dirname "${1#$RPM_BUILD_ROOT}")
- if test -n "${unique_debug_arch}"; then
- bn=$(basename "$1" .debug)-${ver_rel}.${unique_debug_arch}.debug
- else
- bn=$(basename "$1" .debug).debug
- fi
-
+ bn=$(basename "$1" .debug)${unique_debug_suffix}.debug
debugdn=${debugdir}${dn}
debugfn=${debugdn}/${bn}
}
@@ -325,23 +310,21 @@ do_file()
[ -f "${debugfn}" ] && return
echo "extracting debug info from $f"
- build_id_seed=
- if [ ! -z "$ver_rel" ]; then
- build_id_seed="--build-id-seed=$ver_rel"
- fi
# See also cpio SOURCEFILE copy. Directories must match up.
debug_base_name="$RPM_BUILD_DIR"
debug_dest_name="/usr/src/debug"
if [ ! -z "$unique_debug_src_base" ]; then
debug_base_name="$BUILDDIR"
- debug_dest_name="/usr/src/debug/${unique_debug_src_base}-${ver_rel}.${unique_debug_arch}"
+ debug_dest_name="/usr/src/debug/${unique_debug_src_base}"
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 \
- $no_recompute -i $build_id_seed -l "$SOURCEFILE" "$f") || exit
+ id=$(${lib_rpm_dir}/debugedit -b "$debug_base_name" -d "$debug_dest_name" \
+ $no_recompute -i \
+ ${build_id_seed:+--build-id-seed="$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
@@ -509,7 +492,7 @@ if [ -s "$SOURCEFILE" ]; then
debug_dest_name="/usr/src/debug"
if [ ! -z "$unique_debug_src_base" ]; then
debug_base_name="$BUILDDIR"
- debug_dest_name="/usr/src/debug/${unique_debug_src_base}-${ver_rel}.${unique_debug_arch}"
+ debug_dest_name="/usr/src/debug/${unique_debug_src_base}"
fi
mkdir -p "${RPM_BUILD_ROOT}${debug_dest_name}"

View File

@ -1,122 +0,0 @@
From 01145b9b68b89d0d4d6d5a77d9af70dba7dbc9a3 Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Tue, 28 Mar 2017 14:21:40 +0200
Subject: [PATCH] Support debugsource subpackages
This can be enabled by setting the _debugsource_packages macro.
(cherry picked from commit 538cecf0f1fe127dc416afce7a7ee6f94fdb1ad7)
---
macros.in | 28 +++++++++++++++++++++++++---
scripts/find-debuginfo.sh | 17 ++++++++++++++++-
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/macros.in b/macros.in
index b5bf26ac9..d104ad5a7 100644
--- a/macros.in
+++ b/macros.in
@@ -191,13 +191,12 @@
%{?_unique_debug_srcs:--unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}"} \\\
%{?_find_debuginfo_dwz_opts} \\\
%{?_find_debuginfo_opts} \\\
+ %{?_debugsource_packages:-S debugsourcefiles.list} \\\
"%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
-%debug_package \
-%ifnarch noarch\
-%global __debug_package 1\
+%_debuginfo_template \
%package debuginfo\
Summary: Debug information for package %{name}\
Group: Development/Debug\
@@ -208,6 +207,26 @@ Debug information is useful when developing applications that use this\
package or when debugging this package.\
%files debuginfo -f debugfiles.list\
%defattr(-,root,root)\
+%{nil}
+
+%_debugsource_template \
+%package debugsource\
+Summary: Debug sources for package %{name}\
+Group: Development/Debug\
+AutoReqProv: 0\
+%description debugsource\
+This package provides debug sources for package %{name}.\
+Debug sources are useful when developing applications that use this\
+package or when debugging this package.\
+%files debugsource -f debugsourcefiles.list\
+%defattr(-,root,root)\
+%{nil}
+
+%debug_package \
+%ifnarch noarch\
+%global __debug_package 1\
+%_debuginfo_template\
+%{?_debugsource_packages:%_debugsource_template}\
%endif\
%{nil}
@@ -517,6 +536,9 @@ package or when debugging this package.\
# directory under /usr/debug/src as <name>-<ver>-<rel>.<arch>
%_unique_debug_srcs 1
+# Whether rpm should put debug source files into its own subpackage
+#%_debugsource_packages 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 cd2931c0d..bede833d7 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -4,6 +4,7 @@
#
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
# [-o debugfiles.list]
+# [-S debugsourcefiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
# [--build-id-seed VERSION-RELEASE]
@@ -79,6 +80,7 @@ n_jobs=1
BUILDDIR=.
out=debugfiles.list
+srcout=
nout=0
while [ $# -gt 0 ]; do
case "$1" in
@@ -147,6 +149,10 @@ while [ $# -gt 0 ]; do
-j*)
n_jobs=${1#-j}
;;
+ -S)
+ srcout=$2
+ shift
+ ;;
*)
BUILDDIR=$1
shift
@@ -512,10 +518,19 @@ if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
(cd "${RPM_BUILD_ROOT}/usr"
test ! -d lib/debug || find lib/debug ! -type d
- test ! -d src/debug || find src/debug -mindepth 1 -maxdepth 1
+ test ! -d src/debug -o -n "$srcout" || find src/debug -mindepth 1 -maxdepth 1
) | sed 's,^,/usr/,' >> "$LISTFILE"
fi
+if [ -n "$srcout" ]; then
+ > "$srcout"
+ if [ -d "${RPM_BUILD_ROOT}/usr/src/debug" ]; then
+ (cd "${RPM_BUILD_ROOT}/usr"
+ find src/debug -mindepth 1 -maxdepth 1
+ ) | sed 's,^,/usr/,' >> "$srcout"
+ fi
+fi
+
# Append to $1 only the lines from stdin not already in the file.
append_uniq()
{

View File

@ -1,476 +0,0 @@
From bc5c404e7415108f15a8cd5e8514a74b43a7755a Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Fri, 24 Mar 2017 15:35:23 +0100
Subject: [PATCH] Support debuginfo subpackages
We do this by filtering the debuginfo files generated by find-debuginfo.sh
with the files from the (sub)packages.
This commit is heavily based on a patch by Richard Biener.
(cherry picked from commit 980749fdce055254ca92ee7e2595b16750b699a2)
Conflicts:
build/files.c
---
build/files.c | 285 ++++++++++++++++++++++++++++++++++++++++++++--
build/parsePreamble.c | 10 +-
build/parseSpec.c | 2 +-
build/rpmbuild_internal.h | 17 +++
macros.in | 3 +
5 files changed, 304 insertions(+), 13 deletions(-)
diff --git a/build/files.c b/build/files.c
index 2f02587f0..779a2a102 100644
--- a/build/files.c
+++ b/build/files.c
@@ -40,6 +40,16 @@
#define SKIPWHITE(_x) {while(*(_x) && (risspace(*_x) || *(_x) == ',')) (_x)++;}
#define SKIPNONWHITE(_x){while(*(_x) &&!(risspace(*_x) || *(_x) == ',')) (_x)++;}
+/* the following defines must be in sync with the equally hardcoded paths from
+ * scripts/find-debuginfo.sh
+ */
+#define BUILD_ID_DIR "/usr/lib/.build-id"
+#define DEBUG_SRC_DIR "/usr/src/debug"
+#define DEBUG_LIB_DIR "/usr/lib/debug"
+#define DEBUG_LIB_PREFIX "/usr/lib/debug/"
+#define DEBUG_ID_DIR "/usr/lib/debug/.build-id"
+#define DEBUG_DWZ_DIR "/usr/lib/debug/.dwz"
+
/**
*/
enum specfFlags_e {
@@ -1702,9 +1712,8 @@ static int generateBuildIDs(FileList fl)
if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
/* We determine whether this is a main or
debug ELF based on path. */
- #define DEBUGPATH "/usr/lib/debug/"
int isDbg = strncmp (flp->cpioPath,
- DEBUGPATH, strlen (DEBUGPATH)) == 0;
+ DEBUG_LIB_PREFIX, strlen (DEBUG_LIB_PREFIX)) == 0;
/* For the main package files mimic what find-debuginfo.sh does.
Only check build-ids for executable files. Debug files are
@@ -1797,8 +1806,6 @@ static int generateBuildIDs(FileList fl)
if (rc == 0) {
char *attrstr;
/* Add .build-id directories to hold the subdirs/symlinks. */
- #define BUILD_ID_DIR "/usr/lib/.build-id"
- #define DEBUG_ID_DIR "/usr/lib/debug/.build-id"
mainiddir = rpmGetPath(fl->buildRoot, BUILD_ID_DIR, NULL);
debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
@@ -1864,8 +1871,8 @@ static int generateBuildIDs(FileList fl)
/* Don't add anything more when an error occured. But do
cleanup. */
if (rc == 0) {
- int isDbg = strncmp (paths[i], DEBUGPATH,
- strlen (DEBUGPATH)) == 0;
+ int isDbg = strncmp (paths[i], DEBUG_LIB_PREFIX,
+ strlen (DEBUG_LIB_PREFIX)) == 0;
char *buildidsubdir;
char subdir[4];
@@ -1967,7 +1974,7 @@ static int generateBuildIDs(FileList fl)
which don't end in ".debug". */
int pathlen = strlen(paths[i]);
int debuglen = strlen(".debug");
- int prefixlen = strlen("/usr/lib/debug");
+ int prefixlen = strlen(DEBUG_LIB_DIR);
int vralen = vra == NULL ? 0 : strlen(vra);
if (pathlen > prefixlen + debuglen + vralen
&& strcmp ((paths[i] + pathlen - debuglen),
@@ -2621,24 +2628,273 @@ exit:
return rc;
}
+static rpmTag copyTagsFromMainDebug[] = {
+ RPMTAG_ARCH,
+ RPMTAG_SUMMARY,
+ RPMTAG_DESCRIPTION,
+ RPMTAG_GROUP,
+ /* see addTargets */
+ RPMTAG_OS,
+ RPMTAG_PLATFORM,
+ RPMTAG_OPTFLAGS,
+};
+
+/* this is a hack: patch the summary and the description to include
+ * the correct package name */
+static void patchDebugPackageString(Package dbg, rpmTag tag, Package pkg, Package mainpkg)
+{
+ const char *oldname, *newname, *old;
+ char *oldsubst = NULL, *newsubst = NULL, *p;
+ oldname = headerGetString(mainpkg->header, RPMTAG_NAME);
+ newname = headerGetString(pkg->header, RPMTAG_NAME);
+ rasprintf(&oldsubst, "package %s", oldname);
+ rasprintf(&newsubst, "package %s", newname);
+ old = headerGetString(dbg->header, tag);
+ p = old ? strstr(old, oldsubst) : NULL;
+ if (p) {
+ char *new = NULL;
+ rasprintf(&new, "%.*s%s%s", (int)(p - old), old, newsubst, p + strlen(oldsubst));
+ headerDel(dbg->header, tag);
+ headerPutString(dbg->header, tag, new);
+ _free(new);
+ }
+ _free(oldsubst);
+ _free(newsubst);
+}
+
+/* create a new debuginfo subpackage for package pkg from the
+ * main debuginfo package */
+static Package cloneDebuginfoPackage(rpmSpec spec, Package pkg, Package maindbg)
+{
+ const char *name = headerGetString(pkg->header, RPMTAG_NAME);
+ char *dbgname = NULL;
+ Package dbg;
+
+ rasprintf(&dbgname, "%s-%s", name, "debuginfo");
+ dbg = newPackage(dbgname, spec->pool, &spec->packages);
+ headerPutString(dbg->header, RPMTAG_NAME, dbgname);
+ copyInheritedTags(dbg->header, pkg->header);
+ headerDel(dbg->header, RPMTAG_GROUP);
+ headerCopyTags(maindbg->header, dbg->header, copyTagsFromMainDebug);
+ dbg->autoReq = maindbg->autoReq;
+ dbg->autoProv = maindbg->autoProv;
+
+ /* patch summary and description strings */
+ patchDebugPackageString(dbg, RPMTAG_SUMMARY, pkg, spec->packages);
+ patchDebugPackageString(dbg, RPMTAG_DESCRIPTION, pkg, spec->packages);
+
+ /* Add self-provides (normally done by addTargets) */
+ addPackageProvides(dbg);
+ dbg->ds = rpmdsThis(dbg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
+
+ _free(dbgname);
+ return dbg;
+}
+
+/* add a directory to the file list */
+static void argvAddDir(ARGV_t *filesp, const char *dir)
+{
+ char *line = NULL;
+ rasprintf(&line, "%%dir %s", dir);
+ argvAdd(filesp, line);
+ _free(line);
+}
+
+/* collect the debug files for package pkg and put them into
+ * a (possibly new) debuginfo subpackage */
+static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
+ Package maindbg, char *buildroot, char *uniquearch)
+{
+ rpmfi fi;
+ ARGV_t files = NULL;
+ Package dbg = NULL;
+ char *path = NULL;
+ size_t buildrootlen = strlen(buildroot);
+
+ /* ignore noarch subpackages */
+ if (rstreq(headerGetString(pkg->header, RPMTAG_ARCH), "noarch"))
+ return;
+
+ if (!uniquearch)
+ uniquearch = "";
+
+ fi = rpmfilesIter(pkg->cpioList, RPMFI_ITER_FWD);
+ /* Check if the current package has files with debug info
+ and add them to the file list */
+ fi = rpmfiInit(fi, 0);
+ while (rpmfiNext(fi) >= 0) {
+ const char *name = rpmfiFN(fi);
+ int namel = strlen(name);
+
+ /* strip trailing .debug like in find-debuginfo.sh */
+ namel = strlen(name);
+ if (namel > 6 && !strcmp(name + namel - 6, ".debug"))
+ namel -= 6;
+
+ /* generate path */
+ rasprintf(&path, "%s%s%.*s%s.debug", buildroot, DEBUG_LIB_DIR, namel, name, uniquearch);
+
+ /* If that file exists we have debug information for it */
+ if (access(path, F_OK) == 0) {
+ /* Append the file list preamble */
+ if (!files) {
+ argvAdd(&files, "%defattr(-,root,root)");
+ argvAddDir(&files, DEBUG_LIB_DIR);
+ }
+ /* Add the files main debug-info file */
+ argvAdd(&files, path + buildrootlen);
+ }
+ path = _free(path);
+ }
+
+ if (files) {
+ /* we have collected some files. Now put them in a debuginfo
+ * package. If this is not the main package, clone the main
+ * debuginfo package */
+ if (pkg == spec->packages)
+ maindbg->fileList = files;
+ else {
+ Package dbg = cloneDebuginfoPackage(spec, pkg, maindbg);
+ dbg->fileList = files;
+ }
+ }
+}
+
+/* add the debug dwz files to package pkg.
+ * return 1 if something was added, 0 otherwise. */
+static int addDebugDwz(Package pkg, char *buildroot)
+{
+ int ret = 0;
+ char *path = NULL;
+ struct stat sbuf;
+
+ rasprintf(&path, "%s%s", buildroot, DEBUG_DWZ_DIR);
+ if (lstat(path, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) {
+ if (!pkg->fileList) {
+ argvAdd(&pkg->fileList, "%defattr(-,root,root)");
+ argvAddDir(&pkg->fileList, DEBUG_LIB_DIR);
+ }
+ argvAdd(&pkg->fileList, DEBUG_DWZ_DIR);
+ ret = 1;
+ }
+ path = _free(path);
+ return ret;
+}
+
+/* add the debug source files to package pkg.
+ * return 1 if something was added, 0 otherwise. */
+static int addDebugSrc(Package pkg, char *buildroot)
+{
+ int ret = 0;
+ char *path = NULL;
+ DIR *d;
+ struct dirent *de;
+
+ /* not needed if we have an extra debugsource subpackage */
+ if (rpmExpandNumeric("%{?_debugsource_packages}"))
+ return 0;
+
+ rasprintf(&path, "%s%s", buildroot, DEBUG_SRC_DIR);
+ d = opendir(path);
+ path = _free(path);
+ if (d) {
+ while ((de = readdir(d)) != NULL) {
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+ continue;
+ rasprintf(&path, "%s/%s", DEBUG_SRC_DIR, de->d_name);
+ if (!pkg->fileList)
+ argvAdd(&pkg->fileList, "%defattr(-,root,root)");
+ argvAdd(&pkg->fileList, path);
+ path = _free(path);
+ ret = 1;
+ }
+ closedir(d);
+ }
+ return ret;
+}
+
+/* find the main debuginfo package. We do this simply by
+ * searching for a package with the right name. */
+static Package findDebuginfoPackage(rpmSpec spec)
+{
+ Package pkg = NULL;
+ if (lookupPackage(spec, "debuginfo", PART_SUBNAME, &pkg))
+ return NULL;
+ return pkg && pkg->fileList ? pkg : NULL;
+}
+
+/* add a requires for package "to" into package "from". */
+static void addPackageRequires(Package from, Package to)
+{
+ const char *name;
+ char *evr, *isaprov;
+ name = headerGetString(to->header, RPMTAG_NAME);
+ evr = headerGetAsString(to->header, RPMTAG_EVR);
+ isaprov = rpmExpand(name, "%{?_isa}", NULL);
+ addReqProv(from, RPMTAG_REQUIRENAME, isaprov, evr, RPMSENSE_EQUAL, 0);
+ free(isaprov);
+ free(evr);
+}
+
rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
int installSpecialDoc, int test)
{
Package pkg;
rpmRC rc = RPMRC_OK;
+ char *buildroot;
+ char *uniquearch = NULL;
+ Package maindbg = NULL; /* the (existing) main debuginfo package */
+ Package deplink = NULL; /* create requires to this package */
#if HAVE_LIBDW
elf_version (EV_CURRENT);
#endif
check_fileList = newStringBuf();
genSourceRpmName(spec);
+ buildroot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL);
+ if (rpmExpandNumeric("%{?_debuginfo_subpackages}")) {
+ maindbg = findDebuginfoPackage(spec);
+ if (maindbg) {
+ /* move debuginfo package to back */
+ if (maindbg->next) {
+ Package *pp;
+ /* dequeue */
+ for (pp = &spec->packages; *pp != maindbg; pp = &(*pp)->next)
+ ;
+ *pp = maindbg->next;
+ maindbg->next = 0;
+ /* enqueue at tail */
+ for (; *pp; pp = &(*pp)->next)
+ ;
+ *pp = maindbg;
+ }
+ /* delete unsplit file list, we will re-add files back later */
+ maindbg->fileFile = argvFree(maindbg->fileFile);
+ maindbg->fileList = argvFree(maindbg->fileList);
+ if (rpmExpandNumeric("%{?_unique_debug_names}"))
+ uniquearch = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL);
+ }
+ }
+
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
char *nvr;
const char *a;
int header_color;
int arch_color;
+ if (pkg == maindbg) {
+ /* if there is just one debuginfo package, we put our extra stuff
+ * in it. Otherwise we put it in the main debug package */
+ Package extradbg = !maindbg->fileList && maindbg->next && !maindbg->next->next ?
+ maindbg->next : maindbg;
+ if (addDebugDwz(extradbg, buildroot))
+ deplink = extradbg;
+ if (addDebugSrc(extradbg, buildroot))
+ deplink = extradbg;
+ maindbg = NULL; /* all normal packages processed */
+ }
+
if (pkg->fileList == NULL)
continue;
@@ -2647,9 +2903,16 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
nvr = headerGetAsString(pkg->header, RPMTAG_NVRA);
rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), nvr);
free(nvr);
-
- if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK ||
- (rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK)
+
+ if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK)
+ goto exit;
+
+ if (maindbg)
+ filterDebuginfoPackage(spec, pkg, maindbg, buildroot, uniquearch);
+ else if (deplink && pkg != deplink)
+ addPackageRequires(pkg, deplink);
+
+ if ((rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK)
goto exit;
a = headerGetString(pkg->header, RPMTAG_ARCH);
@@ -2684,6 +2947,8 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
}
exit:
check_fileList = freeStringBuf(check_fileList);
+ _free(buildroot);
+ _free(uniquearch);
return rc;
}
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 6be440369..3bb833cff 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -544,6 +544,13 @@ static void fillOutMainPackage(Header h)
/**
*/
+void copyInheritedTags(Header h, Header fromh)
+{
+ headerCopyTags(fromh, h, (rpmTagVal *)copyTagsDuringParse);
+}
+
+/**
+ */
static rpmRC readIcon(Header h, const char * file)
{
char *fn = NULL;
@@ -1171,8 +1178,7 @@ int parsePreamble(rpmSpec spec, int initialPackage)
}
if (pkg != spec->packages) {
- headerCopyTags(spec->packages->header, pkg->header,
- (rpmTagVal *)copyTagsDuringParse);
+ copyInheritedTags(pkg->header, spec->packages->header);
}
if (checkForRequired(pkg->header, NVR)) {
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 9fff0e2c8..582060770 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spec)
}
/* Add extra provides to package. */
-static void addPackageProvides(Package pkg)
+void addPackageProvides(Package pkg)
{
const char *arch, *name;
char *evr, *isaprov;
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 7dd577f26..7ec05b9c9 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal tagN,
/** \ingroup rpmbuild
+ * Add self-provides to package.
+ * @param pkg package
+ */
+RPM_GNUC_INTERNAL
+void addPackageProvides(Package pkg);
+
+/** \ingroup rpmbuild
* Add rpmlib feature dependency.
* @param pkg package
* @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
@@ -453,6 +460,16 @@ int rpmlibNeedsFeature(Package pkg, const char * feature, const char * featureEV
RPM_GNUC_INTERNAL
rpmRC checkForEncoding(Header h, int addtag);
+
+
+/** \ingroup rpmbuild
+ * Copy tags inherited by subpackages from the source header to the target header
+ * @param h target header
+ * @param fromh source header
+ */
+RPM_GNUC_INTERNAL
+void copyInheritedTags(Header h, Header fromh);
+
#ifdef __cplusplus
}
#endif
diff --git a/macros.in b/macros.in
index d104ad5a7..0c055a7fd 100644
--- a/macros.in
+++ b/macros.in
@@ -539,6 +539,9 @@ package or when debugging this package.\
# Whether rpm should put debug source files into its own subpackage
#%_debugsource_packages 1
+# Whether rpm should create extra debuginfo packages for each subpackage
+#%_debuginfo_subpackages 1
+
#
# Use internal dependency generator rather than external helpers?
%_use_internal_dependency_generator 1

View File

@ -1,67 +0,0 @@
From 9f826d903dabbc2ce199560e296224c320bb840f Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Wed, 29 Mar 2017 14:55:10 +0200
Subject: [PATCH] Also add directories to split debuginfo packages
This gets rid of the last difference between debuginfo subpackages
and normal debuginfo packages.
(cherry picked from commit a517554e36666f58724620347a4b8224471d2225)
---
build/files.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/build/files.c b/build/files.c
index 779a2a102..f27dcc7c1 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2707,8 +2707,9 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
{
rpmfi fi;
ARGV_t files = NULL;
- Package dbg = NULL;
- char *path = NULL;
+ ARGV_t dirs = NULL;
+ int lastdiridx = -1, dirsadded;
+ char *path = NULL, *p, *pmin;
size_t buildrootlen = strlen(buildroot);
/* ignore noarch subpackages */
@@ -2741,12 +2742,37 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
argvAdd(&files, "%defattr(-,root,root)");
argvAddDir(&files, DEBUG_LIB_DIR);
}
+
/* Add the files main debug-info file */
argvAdd(&files, path + buildrootlen);
+
+ /* Add the dir(s) */
+ dirsadded = 0;
+ pmin = path + buildrootlen + strlen(DEBUG_LIB_DIR);
+ while ((p = strrchr(path + buildrootlen, '/')) != NULL && p > pmin) {
+ *p = 0;
+ if (lastdiridx >= 0 && !strcmp(dirs[lastdiridx], path + buildrootlen))
+ break; /* already added this one */
+ argvAdd(&dirs, path + buildrootlen);
+ dirsadded++;
+ }
+ if (dirsadded)
+ lastdiridx = argvCount(dirs) - dirsadded; /* remember longest dir */
}
path = _free(path);
}
+ /* add collected directories to file list */
+ if (dirs) {
+ int i;
+ argvSort(dirs, NULL);
+ for (i = 0; dirs[i]; i++) {
+ if (!i || strcmp(dirs[i], dirs[i - 1]) != 0)
+ argvAddDir(&files, dirs[i]);
+ }
+ dirs = argvFree(dirs);
+ }
+
if (files) {
/* we have collected some files. Now put them in a debuginfo
* package. If this is not the main package, clone the main

View File

@ -1,54 +0,0 @@
From faaf3bbfc261f49eda996801b50996fb1066092f Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 28 Jun 2017 20:25:39 +0200
Subject: [PATCH] debugedit: skip_dir_prefix should check for dir separator.
To count as a real directory prefix the string matched should either
be equal to the given prefix or start with the prefix plus '/'.
skip_dir_prefix is always used with base_dir or dest_dir which don't
end with a slash themselves.
This really only is an issue if a package would put a directory named
similar to the package source dir (which cargo on fedora does, by adding
a directory named cargo-vendor in the builddir itself).
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 2ea5619e375f0717b755c8aa4a38254ea622b833)
---
tools/debugedit.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index bf115136c..682189929 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -662,7 +662,8 @@ canonicalize_path (const char *s, char *d)
/* Returns the rest of PATH if it starts with DIR_PREFIX, skipping any
/ path separators, or NULL if PATH doesn't start with
DIR_PREFIX. Might return the empty string if PATH equals DIR_PREFIX
- (modulo trailing slashes). Never returns path starting with '/'. */
+ (modulo trailing slashes). Never returns path starting with '/'.
+ Note that DIR_PREFIX itself should NOT end with a '/'. */
static const char *
skip_dir_prefix (const char *path, const char *dir_prefix)
{
@@ -670,12 +671,17 @@ skip_dir_prefix (const char *path, const char *dir_prefix)
if (strncmp (path, dir_prefix, prefix_len) == 0)
{
path += prefix_len;
+ /* Unless path == dir_prefix there should be at least one '/'
+ in the path (which we will skip). Otherwise the path has
+ a different (longer) directory prefix. */
+ if (*path != '\0' && !IS_DIR_SEPARATOR (*path))
+ return NULL;
while (IS_DIR_SEPARATOR (path[0]))
path++;
return path;
}
- return 0;
+ return NULL;
}
/* Most strings will be in the existing debug string table. But to

View File

@ -1,40 +0,0 @@
From b4d166652011f0d0e8573feb616283698f6cf848 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 28 Jun 2017 13:34:55 +0200
Subject: [PATCH] find-debuginfo.sh: Filter out all <built-in> like fake file
names.
There is no official way to mark an instruction range as being not
part of some actual source code, but as part of a compiler built-in
construct in DWARF. So different compilers have come up with fake
source file names like <built-in> or <__thread_local_inner macros>.
We already filtered out the strings "<internal>" and "<built-in>".
Just filter out all '(^|/)<[a-z _-]+>$'. They are fake files!
This is mainly to appease the rustc compiler which generates lots of
different variants to encode some instruction sequence is part of an
compiler generated macro expansion.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit ff239ff4b06c86485eccaf8f4ecadc9bceb34748)
---
scripts/find-debuginfo.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index bede833d7..eb62a158a 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -502,7 +502,11 @@ if [ -s "$SOURCEFILE" ]; then
fi
mkdir -p "${RPM_BUILD_ROOT}${debug_dest_name}"
- LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(<internal>|<built-in>)$' |
+ # Filter out anything compiler generated which isn't a source file.
+ # e.g. <internal>, <built-in>, <__thread_local_inner macros>.
+ # Some compilers generate them as if they are part of the working
+ # directory (which is why we match against ^ or /).
+ LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(^|/)<[a-z _-]+>$' |
(cd "${debug_base_name}"; cpio -pd0mL "${RPM_BUILD_ROOT}${debug_dest_name}")
# stupid cpio creates new directories in mode 0700,
# and non-standard modes may be inherented from original directories, fixup

View File

@ -1,54 +0,0 @@
From f22cb2890026544499ee4f1a309a44c71e0b8152 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 26 Jun 2017 17:38:30 +0200
Subject: [PATCH] find-debuginfo.sh: Don't create dwz multi file if there is
only one .debug.
dwz -m multi only works when there are multiple .debug input files.
With just one .debug file it doesn't really make sense to extract
the shared debug info into a separate file and dwz will complain:
dwz: Too few files for multifile optimization.
So only add -m multi if there is more than one .debug file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 0f162dc41f2051eab237bd223356d88e94a07580)
---
scripts/find-debuginfo.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index eb62a158a..3bfc15a79 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -442,8 +442,8 @@ fi
# Invoke the DWARF Compressor utility.
if $run_dwz \
&& [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
- dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug`"
- if [ -n "${dwz_files}" ]; then
+ readarray dwz_files < <(cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug)
+ if [ ${#dwz_files[@]} -gt 0 ]; then
dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
dwz_multifile_suffix=
dwz_multifile_idx=0
@@ -452,14 +452,16 @@ if $run_dwz \
dwz_multifile_suffix=".${dwz_multifile_idx}"
done
dwz_multfile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
- dwz_opts="-h -q -r -m .dwz/${dwz_multifile_name}"
+ dwz_opts="-h -q -r"
+ [ ${#dwz_files[@]} -gt 1 ] \
+ && dwz_opts="${dwz_opts} -m .dwz/${dwz_multifile_name}"
mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"
[ -n "${dwz_low_mem_die_limit}" ] \
&& dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}"
[ -n "${dwz_max_die_limit}" ] \
&& dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}"
if type dwz >/dev/null 2>&1; then
- ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+ ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts ${dwz_files[@]} )
else
echo >&2 "*** ERROR: DWARF compression requested, but no dwz installed"
exit 2

View File

@ -1,110 +0,0 @@
From 201b856c02aeb3c4fc6b3a8b96ce8817278f4fbf Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 26 Jun 2017 13:35:48 +0200
Subject: [PATCH] Update find-debuginfo.sh options and macros documentation.
This adds some missing documentation for rpm macros and find-debuginfo.sh
options that were recently added (or renamed). -j N, --build-id-seed SEED,
--unique-debug-suffix SUFFIX and --unique-debug-src-base BASE.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 173e5642a97c535f8bdaac5bf88854a103cc125b)
---
macros.in | 14 ++++++++------
scripts/find-debuginfo.sh | 28 ++++++++++++++++++++++------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/macros.in b/macros.in
index 0c055a7fd..2a114ccd7 100644
--- a/macros.in
+++ b/macros.in
@@ -514,8 +514,9 @@ package or when debugging this package.\
# Whether build-ids should be made unique between package version/releases
# when generating debuginfo packages. If set to 1 this will pass
-# --ver-rel "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will pass it
-# onto debugedit --build-id-seed to be used to prime the build-id note hash.
+# --build-id-seed "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will
+# pass it 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.
@@ -525,15 +526,16 @@ package or when debugging this package.\
# 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
-# debuginfo files which end in -<ver>-<rel>.<arch>.debug
+# --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch} find-debuginfo.sh
+# to create debuginfo files which end in -<ver>-<rel>.<arch>.debug
# Requires _unique_build_ids.
%_unique_debug_names 1
# Whether the /usr/debug/src/<package> directories should be unique between
# package version, release and architecture. If set to 1 this will pass
-# --unique-debug-src-base "%{name}" to find-debuginfo.sh to name the
-# directory under /usr/debug/src as <name>-<ver>-<rel>.<arch>
+# --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}" to
+# find-debuginfo.sh to name the directory under /usr/debug/src as
+# <name>-<ver>-<rel>.<arch>.
%_unique_debug_srcs 1
# Whether rpm should put debug source files into its own subpackage
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 3bfc15a79..185d25f96 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -3,11 +3,14 @@
#for inclusion in an rpm spec file.
#
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
+# [-j N]
# [-o debugfiles.list]
# [-S debugsourcefiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
-# [--build-id-seed VERSION-RELEASE]
+# [--build-id-seed SEED]
+# [--unique-debug-suffix SUFFIX]
+# [--unique-debug-src-base BASE]
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
# [builddir]
#
@@ -19,6 +22,9 @@
# The -i flag says to include a .gdb_index section in the .debug file.
# The -n flag says to not recompute the build-id.
#
+# The -j N option will spawn N processes to do the debuginfo extraction
+# in parallel.
+#
# A single -o switch before any -l or -p switches simply renames
# the primary output file from debugfiles.list to something else.
# A -o switch that follows a -p switch or some -l switches produces
@@ -31,11 +37,21 @@
# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
# provide detailed limits. See dwz(1) -l and -L option for details.
#
-# If --build-id-seed VERSION-RELEASE is given then debugedit is called to
-# update the build-ids it finds adding the VERSION-RELEASE string as
-# seed to recalculate the build-id hash. This makes sure the
-# build-ids in the ELF files are unique between versions and releases
-# of the same package.
+# If --build-id-seed SEED is given then debugedit is called to
+# update the build-ids it finds adding the SEED as seed to recalculate
+# the build-id hash. This makes sure the build-ids in the ELF files
+# are unique between versions and releases of the same package.
+# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
+#
+# If --unique-debug-suffix SUFFIX is given then the debug files created
+# for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
+# are unique between package version, release and architecture.
+# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
+#
+# If --unique-debug-src-base BASE is given then the source directory
+# will be called /usr/debug/src/<BASE>. This makes sure the debug source
+# directories are unique between package version, release and architecture.
+# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
#
# All file names in switches are relative to builddir (. if not given).
#

File diff suppressed because it is too large Load Diff

View File

@ -1,149 +0,0 @@
From 287cda21a5594ad41ffbd29eb01022f314637bdf Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Tue, 28 Feb 2017 10:57:56 +0100
Subject: [PATCH] Use RPMTAG_*NAME instead of RPMTAG_*FLAGS in parsePreamble.c
and parseRCPOT()
Using the FLGS tags is awkward and inconsistent with other part of the code
routinly use the NAME tags to denominate the type of dependencies.
This is also going to make using parseRCPOT() easier for the rpmfc code
that is also based on NAME tags.
(cherry picked from commit 9d5bbd9774d00f50749bb045217eaf91c87b6de0)
---
build/parsePreamble.c | 36 ++++++++++++++++++------------------
build/parseReqs.c | 37 +++++++++++--------------------------
build/rpmfc.c | 2 +-
3 files changed, 30 insertions(+), 45 deletions(-)
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 3bb833cff..bc639e86c 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -850,8 +850,8 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
if (parseNoSource(spec, field, tag))
goto exit;
break;
- case RPMTAG_ORDERFLAGS:
- case RPMTAG_REQUIREFLAGS:
+ case RPMTAG_ORDERNAME:
+ case RPMTAG_REQUIRENAME:
if (parseBits(lang, installScriptBits, &tagflags)) {
rpmlog(RPMLOG_ERR, _("line %d: Bad %s: qualifiers: %s\n"),
spec->lineNum, rpmTagGetName(tag), spec->line);
@@ -859,13 +859,13 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
}
/* fallthrough */
case RPMTAG_PREREQ:
- case RPMTAG_RECOMMENDFLAGS:
- case RPMTAG_SUGGESTFLAGS:
- case RPMTAG_SUPPLEMENTFLAGS:
- case RPMTAG_ENHANCEFLAGS:
- case RPMTAG_CONFLICTFLAGS:
- case RPMTAG_OBSOLETEFLAGS:
- case RPMTAG_PROVIDEFLAGS:
+ case RPMTAG_RECOMMENDNAME:
+ case RPMTAG_SUGGESTNAME:
+ case RPMTAG_SUPPLEMENTNAME:
+ case RPMTAG_ENHANCENAME:
+ case RPMTAG_CONFLICTNAME:
+ case RPMTAG_OBSOLETENAME:
+ case RPMTAG_PROVIDENAME:
if (parseRCPOT(spec, pkg, field, tag, 0, tagflags))
goto exit;
break;
@@ -970,15 +970,15 @@ static struct PreambleRec_s const preambleList[] = {
{RPMTAG_EXCLUDEOS, 0, 0, LEN_AND_STR("excludeos")},
{RPMTAG_EXCLUSIVEOS, 0, 0, LEN_AND_STR("exclusiveos")},
{RPMTAG_ICON, 0, 0, LEN_AND_STR("icon")},
- {RPMTAG_PROVIDEFLAGS, 0, 0, LEN_AND_STR("provides")},
- {RPMTAG_REQUIREFLAGS, 2, 0, LEN_AND_STR("requires")},
- {RPMTAG_RECOMMENDFLAGS, 0, 0, LEN_AND_STR("recommends")},
- {RPMTAG_SUGGESTFLAGS, 0, 0, LEN_AND_STR("suggests")},
- {RPMTAG_SUPPLEMENTFLAGS, 0, 0, LEN_AND_STR("supplements")},
- {RPMTAG_ENHANCEFLAGS, 0, 0, LEN_AND_STR("enhances")},
+ {RPMTAG_PROVIDENAME, 0, 0, LEN_AND_STR("provides")},
+ {RPMTAG_REQUIRENAME, 2, 0, LEN_AND_STR("requires")},
+ {RPMTAG_RECOMMENDNAME, 0, 0, LEN_AND_STR("recommends")},
+ {RPMTAG_SUGGESTNAME, 0, 0, LEN_AND_STR("suggests")},
+ {RPMTAG_SUPPLEMENTNAME, 0, 0, LEN_AND_STR("supplements")},
+ {RPMTAG_ENHANCENAME, 0, 0, LEN_AND_STR("enhances")},
{RPMTAG_PREREQ, 2, 1, LEN_AND_STR("prereq")},
- {RPMTAG_CONFLICTFLAGS, 0, 0, LEN_AND_STR("conflicts")},
- {RPMTAG_OBSOLETEFLAGS, 0, 0, LEN_AND_STR("obsoletes")},
+ {RPMTAG_CONFLICTNAME, 0, 0, LEN_AND_STR("conflicts")},
+ {RPMTAG_OBSOLETENAME, 0, 0, LEN_AND_STR("obsoletes")},
{RPMTAG_PREFIXES, 0, 0, LEN_AND_STR("prefixes")},
{RPMTAG_PREFIXES, 0, 0, LEN_AND_STR("prefix")},
{RPMTAG_BUILDROOT, 0, 0, LEN_AND_STR("buildroot")},
@@ -993,7 +993,7 @@ static struct PreambleRec_s const preambleList[] = {
{RPMTAG_DOCDIR, 0, 0, LEN_AND_STR("docdir")},
{RPMTAG_DISTTAG, 0, 0, LEN_AND_STR("disttag")},
{RPMTAG_BUGURL, 0, 0, LEN_AND_STR("bugurl")},
- {RPMTAG_ORDERFLAGS, 2, 0, LEN_AND_STR("orderwithrequires")},
+ {RPMTAG_ORDERNAME, 2, 0, LEN_AND_STR("orderwithrequires")},
{RPMTAG_REMOVEPATHPOSTFIXES,0, 0, LEN_AND_STR("removepathpostfixes")},
{0, 0, 0, 0}
};
diff --git a/build/parseReqs.c b/build/parseReqs.c
index a443505e4..bd728ed2d 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -132,33 +132,18 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
switch (tagN) {
default:
- case RPMTAG_REQUIREFLAGS:
- nametag = RPMTAG_REQUIRENAME;
+ case RPMTAG_REQUIRENAME:
tagflags |= RPMSENSE_ANY;
- break;
- case RPMTAG_RECOMMENDFLAGS:
- nametag = RPMTAG_RECOMMENDNAME;
- break;
- case RPMTAG_SUGGESTFLAGS:
- nametag = RPMTAG_SUGGESTNAME;
- break;
- case RPMTAG_SUPPLEMENTFLAGS:
- nametag = RPMTAG_SUPPLEMENTNAME;
- break;
- case RPMTAG_ENHANCEFLAGS:
- nametag = RPMTAG_ENHANCENAME;
- break;
- case RPMTAG_PROVIDEFLAGS:
- nametag = RPMTAG_PROVIDENAME;
- break;
- case RPMTAG_OBSOLETEFLAGS:
- nametag = RPMTAG_OBSOLETENAME;
- break;
- case RPMTAG_CONFLICTFLAGS:
- nametag = RPMTAG_CONFLICTNAME;
- break;
- case RPMTAG_ORDERFLAGS:
- nametag = RPMTAG_ORDERNAME;
+ /* fall through */
+ case RPMTAG_RECOMMENDNAME:
+ case RPMTAG_SUGGESTNAME:
+ case RPMTAG_SUPPLEMENTNAME:
+ case RPMTAG_ENHANCENAME:
+ case RPMTAG_PROVIDENAME:
+ case RPMTAG_OBSOLETENAME:
+ case RPMTAG_CONFLICTNAME:
+ case RPMTAG_ORDERNAME:
+ nametag = tagN;
break;
case RPMTAG_PREREQ:
/* XXX map legacy PreReq into Requires(pre,preun) */
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 73915015a..ce192fa9c 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1297,7 +1297,7 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
}
/* Parse dependencies into header */
- rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), tag, 0, tagflags);
+ rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), dm->ntag ? dm->ntag != -1 : RPMTAG_REQUIRENAME, 0, tagflags);
freeStringBuf(sb_stdout);
if (rc) {

View File

@ -1,33 +0,0 @@
From 4fb394a677c17a33c7e3f3455a1a6c109200b87e Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Tue, 28 Feb 2017 17:42:21 +0100
Subject: [PATCH] Fix check for weak deps in external dependency generator
(cherry picked from commit 43d230884365d90d42184a0000f44bb33e5f1ab8)
---
build/rpmfc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index ce192fa9c..921814ad1 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1267,12 +1267,12 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
tagflags = RPMSENSE_FIND_PROVIDES;
break;
case RPMTAG_REQUIREFLAGS:
- case RPMTAG_RECOMMENDNAME:
- case RPMTAG_SUGGESTNAME:
- case RPMTAG_SUPPLEMENTNAME:
- case RPMTAG_ENHANCENAME:
- case RPMTAG_CONFLICTNAME:
- case RPMTAG_OBSOLETENAME:
+ case RPMTAG_RECOMMENDFLAGS:
+ case RPMTAG_SUGGESTFLAGS:
+ case RPMTAG_SUPPLEMENTFLAGS:
+ case RPMTAG_ENHANCEFLAGS:
+ case RPMTAG_CONFLICTFLAGS:
+ case RPMTAG_OBSOLETEFLAGS:
if (fc->skipReq)
continue;
tagflags = RPMSENSE_FIND_REQUIRES;

View File

@ -1,56 +0,0 @@
From 9a316cbeb61549b3004692c9dd8437b9fa805e74 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Thu, 9 Mar 2017 12:12:32 +0100
Subject: [PATCH] Fix check whether to allow rich deps in a given tag
Broken with 9d5bbd9774d00f50749bb045217eaf91c87b6de0
(cherry picked from commit e4349ef7292578a7286bfca2e68a150422e65c3c)
---
build/parseReqs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/build/parseReqs.c b/build/parseReqs.c
index bd728ed2d..6c2aead4e 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -129,6 +129,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
rpmTagVal nametag = RPMTAG_NOT_FOUND;
rpmsenseFlags Flags;
rpmRC rc = RPMRC_FAIL; /* assume failure */
+ int allow_richdeps = 0;
switch (tagN) {
default:
@@ -139,9 +140,11 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
case RPMTAG_SUGGESTNAME:
case RPMTAG_SUPPLEMENTNAME:
case RPMTAG_ENHANCENAME:
+ case RPMTAG_CONFLICTNAME:
+ allow_richdeps = 1;
+ /* fall through */
case RPMTAG_PROVIDENAME:
case RPMTAG_OBSOLETENAME:
- case RPMTAG_CONFLICTNAME:
case RPMTAG_ORDERNAME:
nametag = tagN;
break;
@@ -149,6 +152,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
/* XXX map legacy PreReq into Requires(pre,preun) */
nametag = RPMTAG_REQUIRENAME;
tagflags |= (RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_PREUN);
+ allow_richdeps = 1;
break;
case RPMTAG_TRIGGERPREIN:
nametag = RPMTAG_TRIGGERNAME;
@@ -209,9 +213,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
if (r[0] == '(') {
struct parseRCPOTRichData data;
- if (nametag != RPMTAG_REQUIRENAME && nametag != RPMTAG_CONFLICTNAME &&
- nametag != RPMTAG_RECOMMENDNAME && nametag != RPMTAG_SUPPLEMENTNAME &&
- nametag != RPMTAG_SUGGESTNAME && nametag != RPMTAG_ENHANCENAME) {
+ if (!allow_richdeps) {
rasprintf(&emsg, _("No rich dependencies allowed for this type"));
goto exit;
}

View File

@ -1,26 +0,0 @@
From 27c263a877dd4bfac12ae716038dfbb0a305625b Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Thu, 9 Mar 2017 14:02:10 +0100
Subject: [PATCH] Re-enable rich dependecies for build requires and conflicts
(cherry picked from commit cb3dc0b43bd9a119196a527504d03d57d0785092)
---
build/parseReqs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/build/parseReqs.c b/build/parseReqs.c
index 6c2aead4e..4d500c1df 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -174,9 +174,11 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
case RPMTAG_BUILDREQUIRES:
nametag = RPMTAG_REQUIRENAME;
tagflags |= RPMSENSE_ANY;
+ allow_richdeps = 1;
break;
case RPMTAG_BUILDCONFLICTS:
nametag = RPMTAG_CONFLICTNAME;
+ allow_richdeps = 1;
break;
case RPMTAG_FILETRIGGERIN:
nametag = RPMTAG_FILETRIGGERNAME;

View File

@ -1,275 +0,0 @@
From c1ed362facbab3d08b5576950d4c6a68cfae9e75 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Sat, 25 Feb 2017 12:28:16 +0100
Subject: [PATCH] add support for rich dependencies from dependency generators
Mostly achieved by replacing custom parser with the parseRCPOT().
Closes: https://github.com/rpm-software-management/rpm/issues/167
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
(cherry picked from commit 8f509d669b9ae79c86dd510c5a4bc5109f60d733)
Conflicts:
build/rpmfc.c
---
build/parsePreamble.c | 4 +--
build/parseReqs.c | 9 +++--
build/parseScript.c | 2 +-
build/reqprov.c | 8 +++++
build/rpmbuild_internal.h | 12 ++++++-
build/rpmfc.c | 90 ++++++++++++++---------------------------------
6 files changed, 54 insertions(+), 71 deletions(-)
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index bc639e86c..6b3705598 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -866,13 +866,13 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
case RPMTAG_CONFLICTNAME:
case RPMTAG_OBSOLETENAME:
case RPMTAG_PROVIDENAME:
- if (parseRCPOT(spec, pkg, field, tag, 0, tagflags))
+ if (parseRCPOT(spec, pkg, field, tag, 0, tagflags, addReqProvPkg, NULL))
goto exit;
break;
case RPMTAG_BUILDPREREQ:
case RPMTAG_BUILDREQUIRES:
case RPMTAG_BUILDCONFLICTS:
- if (parseRCPOT(spec, spec->sourcePackage, field, tag, 0, tagflags))
+ if (parseRCPOT(spec, spec->sourcePackage, field, tag, 0, tagflags, addReqProvPkg, NULL))
goto exit;
break;
case RPMTAG_EXCLUDEARCH:
diff --git a/build/parseReqs.c b/build/parseReqs.c
index 4d500c1df..554ff49a5 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -121,7 +121,7 @@ static rpmRC parseRCPOTRichCB(void *cbdata, rpmrichParseType type,
}
rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
- int index, rpmsenseFlags tagflags)
+ int index, rpmsenseFlags tagflags, addReqProvFunction cb, void *cbdata)
{
const char *r, *re, *v, *ve;
char *emsg = NULL;
@@ -131,6 +131,9 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
rpmRC rc = RPMRC_FAIL; /* assume failure */
int allow_richdeps = 0;
+ if (!cbdata)
+ cbdata = pkg;
+
switch (tagN) {
default:
case RPMTAG_REQUIRENAME:
@@ -225,7 +228,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
freeStringBuf(data.sb);
goto exit;
}
- if (addReqProv(pkg, nametag, getStringBuf(data.sb), NULL, Flags, index)) {
+ if (cb && cb(cbdata, nametag, getStringBuf(data.sb), NULL, Flags, index) != RPMRC_OK) {
rasprintf(&emsg, _("invalid dependency"));
freeStringBuf(data.sb);
goto exit;
@@ -300,7 +303,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
goto exit;
}
- if (addReqProv(pkg, nametag, N, EVR, Flags, index)) {
+ if (cb && cb(cbdata, nametag, N, EVR, Flags, index) != RPMRC_OK) {
rasprintf(&emsg, _("invalid dependency"));
goto exit;
}
diff --git a/build/parseScript.c b/build/parseScript.c
index 64fd89693..849e40244 100644
--- a/build/parseScript.c
+++ b/build/parseScript.c
@@ -398,7 +398,7 @@ int parseScript(rpmSpec spec, int parsePart)
priority);
/* Generate the trigger tags */
- if (parseRCPOT(spec, pkg, reqargs, reqtag, index, tagflags))
+ if (parseRCPOT(spec, pkg, reqargs, reqtag, index, tagflags, addReqProvPkg, NULL))
goto exit;
} else {
struct rpmtd_s td;
diff --git a/build/reqprov.c b/build/reqprov.c
index 7422db65f..5fa0a1c6b 100644
--- a/build/reqprov.c
+++ b/build/reqprov.c
@@ -34,6 +34,14 @@ int addReqProv(Package pkg, rpmTagVal tagN,
return 0;
}
+rpmRC addReqProvPkg(void *cbdata, rpmTagVal tagN,
+ const char * N, const char *EVR, rpmsenseFlags Flags,
+ int index)
+{
+ Package pkg = cbdata;
+ return addReqProv(pkg, tagN, N, EVR, Flags, index) ? RPMRC_FAIL : RPMRC_OK;
+}
+
int rpmlibNeedsFeature(Package pkg, const char * feature, const char * featureEVR)
{
char *reqname = NULL;
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 7ec05b9c9..1c3332faf 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -283,6 +283,10 @@ int parseScript(rpmSpec spec, int parsePart);
RPM_GNUC_INTERNAL
rpmRC rpmCharCheck(rpmSpec spec, const char *field, const char *whitelist);
+typedef rpmRC (*addReqProvFunction) (void *cbdata, rpmTagVal tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags,
+ int index);
+
/** \ingroup rpmbuild
* Parse dependency relations from spec file and/or autogenerated output buffer.
* @param spec spec file control structure
@@ -291,11 +295,13 @@ rpmRC rpmCharCheck(rpmSpec spec, const char *field, const char *whitelist);
* @param tagN tag, identifies type of dependency
* @param index (0 always)
* @param tagflags dependency flags already known from context
+ * @param cb Callback for adding dependency (nullable)
+ * @param cbdata Callback data (@pkg if NULL)
* @return RPMRC_OK on success, RPMRC_FAIL on failure
*/
RPM_GNUC_INTERNAL
rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char * field, rpmTagVal tagN,
- int index, rpmsenseFlags tagflags);
+ int index, rpmsenseFlags tagflags, addReqProvFunction cb, void *cbdata);
/** \ingroup rpmbuild
* Evaluate boolean expression.
@@ -440,6 +446,10 @@ int addReqProv(Package pkg, rpmTagVal tagN,
const char * N, const char * EVR, rpmsenseFlags Flags,
uint32_t index);
+RPM_GNUC_INTERNAL
+rpmRC addReqProvPkg(void *cbdata, rpmTagVal tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags,
+ int index);
/** \ingroup rpmbuild
* Add self-provides to package.
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 921814ad1..7fa8227d0 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -447,44 +447,27 @@ static ARGV_t runCmd(const char *nsdep, const char *depname,
return output;
}
-static const char *parseDep(char **depav, int depac,
- const char **N, const char **EVR, rpmsenseFlags *Flags)
+struct addReqProvDataFc {
+ rpmfc fc;
+ const char *namespace;
+ regex_t *exclude;
+};
+
+static rpmRC addReqProvFc(void *cbdata, rpmTagVal tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags,
+ int index)
{
- const char *err = NULL;
-
- switch (depac) {
- case 1: /* only a name */
- *N = depav[0];
- *EVR = "";
- break;
- case 3: /* name, range and version */
- for (const char *s = depav[1]; *s; s++) {
- switch(*s) {
- default:
- err = _("bad operator");
- break;
- case '=':
- *Flags |= RPMSENSE_EQUAL;
- break;
- case '<':
- *Flags |= RPMSENSE_LESS;
- break;
- case '>':
- *Flags |= RPMSENSE_GREATER;
- break;
- }
- }
- if (!err) {
- *N = depav[0];
- *EVR = depav[2];
- }
- break;
- default:
- err = _("bad format");
- break;
- }
+ struct addReqProvDataFc *data = cbdata;
+ rpmfc fc = data->fc;
+ const char *namespace = data->namespace;
+ regex_t *exclude = data->exclude;
+
+ rpmds ds = rpmdsSingleNS(fc->pool, tagN, namespace, N, EVR, Flags);
+ /* Add to package and file dependencies unless filtered */
+ if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0)
+ rpmfcAddFileDep(&fc->fileDeps, ds, index);
- return err;
+ return RPMRC_OK;
}
/**
@@ -522,35 +505,14 @@ static int rpmfcHelper(rpmfc fc, int ix,
namespace = rpmfcAttrMacro(nsdep, NULL, "namespace");
exclude = rpmfcAttrReg(depname, NULL, "exclude");
+ struct addReqProvDataFc data;
+ data.fc = fc;
+ data.namespace = namespace;
+ data.exclude = exclude;
+
for (int i = 0; i < pac; i++) {
- char ** depav = NULL;
- int xx, depac = 0;
- const char *N = NULL;
- const char *EVR = NULL;
- const char *err = NULL;
- rpmsenseFlags Flags = dsContext;
-
- if ((xx = poptParseArgvString(pav[i], &depac, (const char ***)&depav)))
- err = poptStrerror(xx);
-
- if (!err)
- err = parseDep(depav, depac, &N, &EVR, &Flags);
-
- if (!err) {
- rpmds ds = rpmdsSingleNS(fc->pool, tagN, namespace, N, EVR, Flags);
-
- /* Add to package and file dependencies unless filtered */
- if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0) {
- //rpmdsMerge(packageDependencies(fc->pkg, tagN), ds);
- rpmfcAddFileDep(&fc->fileDeps, ds, ix);
- }
- } else {
- rpmlog(RPMLOG_ERR, _("invalid dependency (%s): %s\n"),
- err, pav[i]);
+ if (parseRCPOT(NULL, fc->pkg, pav[i], tagN, 0, dsContext, addReqProvFc, &data))
rc++;
- }
-
- free(depav);
}
argvFree(pav);
@@ -1297,7 +1259,7 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
}
/* Parse dependencies into header */
- rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), dm->ntag ? dm->ntag != -1 : RPMTAG_REQUIRENAME, 0, tagflags);
+ rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), dm->ntag ? dm->ntag != -1 : RPMTAG_REQUIRENAME, 0, tagflags, addReqProvPkg, NULL);
freeStringBuf(sb_stdout);
if (rc) {

View File

@ -1,26 +0,0 @@
From d6a1e94f18d2f73e7b03025d891aa7e407cb169a Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Wed, 31 May 2017 10:42:03 +0200
Subject: [PATCH] Pass proper file index when recording generated dependencies
Resolves regression introduced with 8f509d6
Fixes #224
(cherry picked from commit dab75e7f26a08cc6798e4df177adb2dd8d40035c)
---
build/rpmfc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 7fa8227d0..72f29ddf5 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -511,7 +511,7 @@ static int rpmfcHelper(rpmfc fc, int ix,
data.exclude = exclude;
for (int i = 0; i < pac; i++) {
- if (parseRCPOT(NULL, fc->pkg, pav[i], tagN, 0, dsContext, addReqProvFc, &data))
+ if (parseRCPOT(NULL, fc->pkg, pav[i], tagN, ix, dsContext, addReqProvFc, &data))
rc++;
}

View File

@ -1,99 +0,0 @@
From c24003b77926967589546681ef893e4e11f6b77f Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Fri, 19 May 2017 11:01:12 +0300
Subject: [PATCH] Consolidate %defattr/%attr(-,root,root) generation to helper
function
(cherry picked from commit b71d63ef598cb5bf504265a18166d782fb017569)
---
build/files.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/build/files.c b/build/files.c
index f27dcc7c1..e93efebd7 100644
--- a/build/files.c
+++ b/build/files.c
@@ -193,6 +193,16 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
*nar = *oar; /* struct assignment */
}
+static char *mkattr(const char *fn)
+{
+ char *s = NULL;
+ if (fn)
+ rasprintf(&s, "%s(-,%s,%s) %s", "%attr", "root", "root", fn);
+ else
+ rasprintf(&s, "%s(-,%s,%s)", "%defattr", "root", "root");
+ return s;
+}
+
static void copyFileEntry(FileEntry src, FileEntry dest)
{
/* Copying struct makes just shallow copy */
@@ -1820,7 +1830,7 @@ static int generateBuildIDs(FileList fl)
fl->cur.verifyFlags = RPMVERIFY_ALL;
fl->def.specdFlags |= SPECD_VERIFY;
fl->cur.specdFlags |= SPECD_VERIFY;
- attrstr = xstrdup ("%defattr(-,root,root)");
+ attrstr = mkattr(NULL);
parseForAttr(fl->pool, attrstr, 1, &fl->def);
free (attrstr);
@@ -1833,8 +1843,7 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(mainiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, mainiddir);
} else {
- rasprintf (&attrstr, "%s %s", "%attr(-,root,root) ",
- mainiddir);
+ attrstr = mkattr(mainiddir);
parseForAttr(fl->pool, attrstr, 0, &fl->cur);
fl->cur.isDir = 1;
rc = addFile(fl, mainiddir, NULL);
@@ -1846,8 +1855,7 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(debugiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, debugiddir);
} else {
- rasprintf (&attrstr, "%s %s", "%attr(-,root,root) ",
- debugiddir);
+ attrstr = mkattr(debugiddir);
parseForAttr(fl->pool, attrstr, 0, &fl->cur);
fl->cur.isDir = 1;
rc = addFile(fl, debugiddir, NULL);
@@ -2739,8 +2747,10 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
if (access(path, F_OK) == 0) {
/* Append the file list preamble */
if (!files) {
- argvAdd(&files, "%defattr(-,root,root)");
+ char *attr = mkattr(NULL);
+ argvAdd(&files, attr);
argvAddDir(&files, DEBUG_LIB_DIR);
+ free(attr);
}
/* Add the files main debug-info file */
@@ -2797,8 +2807,10 @@ static int addDebugDwz(Package pkg, char *buildroot)
rasprintf(&path, "%s%s", buildroot, DEBUG_DWZ_DIR);
if (lstat(path, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) {
if (!pkg->fileList) {
- argvAdd(&pkg->fileList, "%defattr(-,root,root)");
+ char *attr = mkattr(NULL);
+ argvAdd(&pkg->fileList, attr);
argvAddDir(&pkg->fileList, DEBUG_LIB_DIR);
+ free(attr);
}
argvAdd(&pkg->fileList, DEBUG_DWZ_DIR);
ret = 1;
@@ -2828,8 +2840,11 @@ static int addDebugSrc(Package pkg, char *buildroot)
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
continue;
rasprintf(&path, "%s/%s", DEBUG_SRC_DIR, de->d_name);
- if (!pkg->fileList)
- argvAdd(&pkg->fileList, "%defattr(-,root,root)");
+ if (!pkg->fileList) {
+ char *attr = mkattr(NULL);
+ argvAdd(&pkg->fileList, attr);
+ free(attr);
+ }
argvAdd(&pkg->fileList, path);
path = _free(path);
ret = 1;

View File

@ -1,255 +0,0 @@
From bc5990647ad94fcb4acdb68612e16fe514ee59b7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 29 Jun 2017 13:26:24 +0200
Subject: [PATCH] Extract package file list processing in separate functions.
Extract two functions resetPackageFilesDefaults() and addPackageFileList()
from processPackageFiles(). This will make it possible to add multiple
(generated) file lists to a package later.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 139d62d3b8068b0e39893babf13f0c3cc5329e75)
---
build/files.c | 170 ++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 107 insertions(+), 63 deletions(-)
diff --git a/build/files.c b/build/files.c
index e93efebd7..8baf85e9d 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2307,45 +2307,35 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
freeStringBuf(docScript);
free(mkdocdir);
}
-
-static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
- Package pkg, int installSpecialDoc, int test)
+
+/* Resets the default settings for files in the package list.
+ Used in processPackageFiles whenever a new set of files is added. */
+static void resetPackageFilesDefaults (struct FileList_s *fl,
+ rpmBuildPkgFlags pkgFlags)
{
struct AttrRec_s root_ar = { 0, 0, 0, 0, 0, 0 };
- struct FileList_s fl;
- ARGV_t fileNames = NULL;
- specialDir specialDoc = NULL;
- specialDir specialLic = NULL;
- pkg->cpioList = NULL;
+ root_ar.ar_user = rpmstrPoolId(fl->pool, "root", 1);
+ root_ar.ar_group = rpmstrPoolId(fl->pool, "root", 1);
+ dupAttrRec(&root_ar, &fl->def.ar); /* XXX assume %defattr(-,root,root) */
- for (ARGV_const_t fp = pkg->fileFile; fp && *fp != NULL; fp++) {
- if (readFilesManifest(spec, pkg, *fp))
- return RPMRC_FAIL;
- }
- /* Init the file list structure */
- memset(&fl, 0, sizeof(fl));
-
- fl.pool = rpmstrPoolLink(spec->pool);
- /* XXX spec->buildRoot == NULL, then xstrdup("") is returned */
- fl.buildRoot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL);
- fl.buildRootLen = strlen(fl.buildRoot);
+ fl->def.verifyFlags = RPMVERIFY_ALL;
- root_ar.ar_user = rpmstrPoolId(fl.pool, "root", 1);
- root_ar.ar_group = rpmstrPoolId(fl.pool, "root", 1);
- dupAttrRec(&root_ar, &fl.def.ar); /* XXX assume %defattr(-,root,root) */
-
- fl.def.verifyFlags = RPMVERIFY_ALL;
-
- fl.pkgFlags = pkgFlags;
+ fl->pkgFlags = pkgFlags;
+}
- { char *docs = rpmGetPath("%{?__docdir_path}", NULL);
- argvSplit(&fl.docDirs, docs, ":");
- free(docs);
- }
-
- for (ARGV_const_t fp = pkg->fileList; *fp != NULL; fp++) {
+/* Adds the given fileList to the package. If fromSpecFileList is not zero
+ then the specialDirs are also filled in and the files are sanitized
+ through processBinaryFile(). Otherwise no special files are processed
+ and the files are added directly through addFile(). */
+static void addPackageFileList (struct FileList_s *fl, Package pkg,
+ ARGV_t *fileList,
+ specialDir *specialDoc, specialDir *specialLic,
+ int fromSpecFileList)
+{
+ ARGV_t fileNames = NULL;
+ for (ARGV_const_t fp = *fileList; *fp != NULL; fp++) {
char buf[strlen(*fp) + 1];
const char *s = *fp;
SKIPSPACE(s);
@@ -2355,41 +2345,63 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
rstrlcpy(buf, s, sizeof(buf));
/* Reset for a new line in %files */
- FileEntryFree(&fl.cur);
+ FileEntryFree(&fl->cur);
/* turn explicit flags into %def'd ones (gosh this is hacky...) */
- fl.cur.specdFlags = ((unsigned)fl.def.specdFlags) >> 8;
- fl.cur.verifyFlags = fl.def.verifyFlags;
-
- if (parseForVerify(buf, 0, &fl.cur) ||
- parseForVerify(buf, 1, &fl.def) ||
- parseForAttr(fl.pool, buf, 0, &fl.cur) ||
- parseForAttr(fl.pool, buf, 1, &fl.def) ||
- parseForDev(buf, &fl.cur) ||
- parseForConfig(buf, &fl.cur) ||
- parseForLang(buf, &fl.cur) ||
- parseForCaps(buf, &fl.cur) ||
- parseForSimple(buf, &fl.cur, &fileNames))
+ fl->cur.specdFlags = ((unsigned)fl->def.specdFlags) >> 8;
+ fl->cur.verifyFlags = fl->def.verifyFlags;
+
+ if (parseForVerify(buf, 0, &fl->cur) ||
+ parseForVerify(buf, 1, &fl->def) ||
+ parseForAttr(fl->pool, buf, 0, &fl->cur) ||
+ parseForAttr(fl->pool, buf, 1, &fl->def) ||
+ parseForDev(buf, &fl->cur) ||
+ parseForConfig(buf, &fl->cur) ||
+ parseForLang(buf, &fl->cur) ||
+ parseForCaps(buf, &fl->cur) ||
+ parseForSimple(buf, &fl->cur, &fileNames))
{
- fl.processingFailed = 1;
+ fl->processingFailed = 1;
continue;
}
for (ARGV_const_t fn = fileNames; fn && *fn; fn++) {
- if (fl.cur.attrFlags & RPMFILE_SPECIALDIR) {
- rpmFlags oattrs = (fl.cur.attrFlags & ~RPMFILE_SPECIALDIR);
+
+ /* For file lists that don't come from a spec file list
+ processing is easy. There are no special files and the
+ file names don't need to be adjusted. */
+ if (!fromSpecFileList) {
+ if (fl->cur.attrFlags & RPMFILE_SPECIALDIR
+ || fl->cur.attrFlags & RPMFILE_DOCDIR
+ || fl->cur.attrFlags & RPMFILE_PUBKEY) {
+ rpmlog(RPMLOG_ERR,
+ _("Special file in generated file list: %s\n"),
+ *fn);
+ fl->processingFailed = 1;
+ continue;
+ }
+ if (fl->cur.attrFlags & RPMFILE_DIR)
+ fl->cur.isDir = 1;
+ addFile(fl, *fn, NULL);
+ continue;
+ }
+
+ /* File list does come from the spec, try to detect special
+ files and adjust the actual file names. */
+ if (fl->cur.attrFlags & RPMFILE_SPECIALDIR) {
+ rpmFlags oattrs = (fl->cur.attrFlags & ~RPMFILE_SPECIALDIR);
specialDir *sdp = NULL;
if (oattrs == RPMFILE_DOC) {
- sdp = &specialDoc;
+ sdp = specialDoc;
} else if (oattrs == RPMFILE_LICENSE) {
- sdp = &specialLic;
+ sdp = specialLic;
}
if (sdp == NULL || **fn == '/') {
rpmlog(RPMLOG_ERR,
_("Can't mix special %s with other forms: %s\n"),
(oattrs & RPMFILE_DOC) ? "%doc" : "%license", *fn);
- fl.processingFailed = 1;
+ fl->processingFailed = 1;
continue;
}
@@ -2397,32 +2409,65 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
if (*sdp == NULL) {
*sdp = specialDirNew(pkg->header, oattrs);
}
- addSpecialFile(*sdp, *fn, &fl.cur, &fl.def);
+ addSpecialFile(*sdp, *fn, &fl->cur, &fl->def);
continue;
}
/* this is now an artificial limitation */
if (fn != fileNames) {
rpmlog(RPMLOG_ERR, _("More than one file on a line: %s\n"),*fn);
- fl.processingFailed = 1;
+ fl->processingFailed = 1;
continue;
}
- if (fl.cur.attrFlags & RPMFILE_DOCDIR) {
- argvAdd(&(fl.docDirs), *fn);
- } else if (fl.cur.attrFlags & RPMFILE_PUBKEY) {
- (void) processMetadataFile(pkg, &fl, *fn, RPMTAG_PUBKEYS);
+ if (fl->cur.attrFlags & RPMFILE_DOCDIR) {
+ argvAdd(&(fl->docDirs), *fn);
+ } else if (fl->cur.attrFlags & RPMFILE_PUBKEY) {
+ (void) processMetadataFile(pkg, fl, *fn, RPMTAG_PUBKEYS);
} else {
- if (fl.cur.attrFlags & RPMFILE_DIR)
- fl.cur.isDir = 1;
- (void) processBinaryFile(pkg, &fl, *fn);
+ if (fl->cur.attrFlags & RPMFILE_DIR)
+ fl->cur.isDir = 1;
+ (void) processBinaryFile(pkg, fl, *fn);
}
}
- if (fl.cur.caps)
- fl.haveCaps = 1;
+ if (fl->cur.caps)
+ fl->haveCaps = 1;
+ }
+ argvFree(fileNames);
+}
+
+static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
+ Package pkg, int installSpecialDoc, int test)
+{
+ struct FileList_s fl;
+ specialDir specialDoc = NULL;
+ specialDir specialLic = NULL;
+
+ pkg->cpioList = NULL;
+
+ for (ARGV_const_t fp = pkg->fileFile; fp && *fp != NULL; fp++) {
+ if (readFilesManifest(spec, pkg, *fp))
+ return RPMRC_FAIL;
+ }
+ /* Init the file list structure */
+ memset(&fl, 0, sizeof(fl));
+
+ fl.pool = rpmstrPoolLink(spec->pool);
+ /* XXX spec->buildRoot == NULL, then xstrdup("") is returned */
+ fl.buildRoot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL);
+ fl.buildRootLen = strlen(fl.buildRoot);
+
+ resetPackageFilesDefaults (&fl, pkgFlags);
+
+ { char *docs = rpmGetPath("%{?__docdir_path}", NULL);
+ argvSplit(&fl.docDirs, docs, ":");
+ free(docs);
}
+ addPackageFileList (&fl, pkg, &pkg->fileList,
+ &specialDoc, &specialLic, 1);
+
/* Now process special docs and licenses if present */
if (specialDoc)
processSpecialDir(spec, pkg, &fl, specialDoc, installSpecialDoc, test);
@@ -2451,7 +2496,6 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
genCpioListAndHeader(&fl, pkg, 0);
exit:
- argvFree(fileNames);
FileListFree(&fl);
specialDirFree(specialDoc);
specialDirFree(specialLic);

View File

@ -1,190 +0,0 @@
From 97ad525723d0c9af382acadc823b6a744d5426cf Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 29 Jun 2017 13:26:25 +0200
Subject: [PATCH] Use a file list to add build-id files to pkgList.
Change the generation of build-id files to a file list using ARGV_t.
First go through the current package list and generate a files list.
Then add those files as if they were part of the original package file
list using the new resetPackageFilesDefaults() and addPackageFileList().
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 88b7f24547afbfec42bb727e28d929a815db971a)
---
build/files.c | 74 ++++++++++++++++++++++++++---------------------------------
1 file changed, 33 insertions(+), 41 deletions(-)
diff --git a/build/files.c b/build/files.c
index 8baf85e9d..e88a5d24d 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1576,6 +1576,15 @@ exit:
return rc;
}
+/* add a directory to the file list */
+static void argvAddDir(ARGV_t *filesp, const char *dir)
+{
+ char *line = NULL;
+ rasprintf(&line, "%%dir %s", dir);
+ argvAdd(filesp, line);
+ _free(line);
+}
+
#if HAVE_LIBDW
/* How build id links are generated. See macros.in for description. */
#define BUILD_IDS_NONE 0
@@ -1583,7 +1592,7 @@ exit:
#define BUILD_IDS_SEPARATE 2
#define BUILD_IDS_COMPAT 3
-static int addNewIDSymlink(FileList fl,
+static int addNewIDSymlink(ARGV_t *files,
char *targetpath, char *idlinkpath,
int isDbg, int *dups)
{
@@ -1632,8 +1641,7 @@ static int addNewIDSymlink(FileList fl,
rpmlog(RPMLOG_ERR, "%s: %s -> %s: %m\n",
linkerr, linkpath, targetpath);
} else {
- fl->cur.isDir = 0;
- rc = addFile(fl, linkpath, NULL);
+ rc = argvAdd(files, linkpath);
}
if (nr > 0) {
@@ -1671,7 +1679,7 @@ static int addNewIDSymlink(FileList fl,
return rc;
}
-static int generateBuildIDs(FileList fl)
+static int generateBuildIDs(FileList fl, ARGV_t *files)
{
int rc = 0;
int i;
@@ -1820,18 +1828,9 @@ static int generateBuildIDs(FileList fl)
mainiddir = rpmGetPath(fl->buildRoot, BUILD_ID_DIR, NULL);
debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
- /* Make sure to reset all file flags to defaults.
- Uses parseForAttr to reset ar, arFlags, and specdFlags.
- Note that parseForAttr pokes at the attrstr, so we cannot
- just pass a static string. */
- fl->cur.attrFlags = 0;
- fl->def.attrFlags = 0;
- fl->def.verifyFlags = RPMVERIFY_ALL;
- fl->cur.verifyFlags = RPMVERIFY_ALL;
- fl->def.specdFlags |= SPECD_VERIFY;
- fl->cur.specdFlags |= SPECD_VERIFY;
+ /* Make sure to reset all file flags to defaults. */
attrstr = mkattr(NULL);
- parseForAttr(fl->pool, attrstr, 1, &fl->def);
+ argvAdd(files, attrstr);
free (attrstr);
/* Supported, but questionable. */
@@ -1843,11 +1842,7 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(mainiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, mainiddir);
} else {
- attrstr = mkattr(mainiddir);
- parseForAttr(fl->pool, attrstr, 0, &fl->cur);
- fl->cur.isDir = 1;
- rc = addFile(fl, mainiddir, NULL);
- free (attrstr);
+ argvAddDir(files, mainiddir);
}
}
@@ -1855,11 +1850,7 @@ static int generateBuildIDs(FileList fl)
if ((rc = rpmioMkpath(debugiddir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, debugiddir);
} else {
- attrstr = mkattr(debugiddir);
- parseForAttr(fl->pool, attrstr, 0, &fl->cur);
- fl->cur.isDir = 1;
- rc = addFile(fl, debugiddir, NULL);
- free (attrstr);
+ argvAddDir(files, debugiddir);
}
}
}
@@ -1898,9 +1889,9 @@ static int generateBuildIDs(FileList fl)
&& (rc = rpmioMkpath(buildidsubdir, 0755, -1, -1)) != 0) {
rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, buildidsubdir);
} else {
- fl->cur.isDir = 1;
- if (!addsubdir
- || (rc = addFile(fl, buildidsubdir, NULL)) == 0) {
+ if (addsubdir)
+ argvAddDir (files, buildidsubdir);
+ if (rc == 0) {
char *linkpattern, *targetpattern;
char *linkpath, *targetpath;
int dups = 0;
@@ -1914,7 +1905,7 @@ static int generateBuildIDs(FileList fl)
rasprintf(&linkpath, linkpattern,
buildidsubdir, &ids[i][2]);
rasprintf(&targetpath, targetpattern, paths[i]);
- rc = addNewIDSymlink(fl, targetpath, linkpath,
+ rc = addNewIDSymlink(files, targetpath, linkpath,
isDbg, &dups);
/* We might want to have a link from the debug
@@ -1960,7 +1951,7 @@ static int generateBuildIDs(FileList fl)
"../../../.build-id%s/%s.%d",
subdir, &ids[i][2], dups);
}
- rc = addNewIDSymlink(fl, targetpath, linkpath,
+ rc = addNewIDSymlink(files, targetpath, linkpath,
0, NULL);
}
@@ -1998,7 +1989,7 @@ static int generateBuildIDs(FileList fl)
buildidsubdir, &ids[i][2]);
rasprintf(&targetpath, "../../../../..%s",
targetstr);
- rc = addNewIDSymlink(fl, targetpath,
+ rc = addNewIDSymlink(files, targetpath,
linkpath, 0, &dups);
free(targetstr);
}
@@ -2481,11 +2472,21 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
/* Check build-ids and add build-ids links for files to package list. */
const char *arch = headerGetString(pkg->header, RPMTAG_ARCH);
if (!rstreq(arch, "noarch")) {
- if (generateBuildIDs (&fl) != 0) {
+ /* Go through the current package list and generate a files list. */
+ ARGV_t idFiles = NULL;
+ if (generateBuildIDs (&fl, &idFiles) != 0) {
rpmlog(RPMLOG_ERR, _("Generating build-id links failed\n"));
fl.processingFailed = 1;
goto exit;
}
+
+ if (idFiles != NULL) {
+ resetPackageFilesDefaults (&fl, pkgFlags);
+ addPackageFileList (&fl, pkg, &idFiles, NULL, NULL, 0);
+ }
+
+ if (fl.processingFailed)
+ goto exit;
}
#endif
@@ -2743,15 +2744,6 @@ static Package cloneDebuginfoPackage(rpmSpec spec, Package pkg, Package maindbg)
return dbg;
}
-/* add a directory to the file list */
-static void argvAddDir(ARGV_t *filesp, const char *dir)
-{
- char *line = NULL;
- rasprintf(&line, "%%dir %s", dir);
- argvAdd(filesp, line);
- _free(line);
-}
-
/* collect the debug files for package pkg and put them into
* a (possibly new) debuginfo subpackage */
static void filterDebuginfoPackage(rpmSpec spec, Package pkg,

View File

@ -1,82 +0,0 @@
From 13369a562f5cba34779e238b2d6ae0b683ff3b1e Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 29 Jun 2017 13:26:26 +0200
Subject: [PATCH] Change mkattr to always create a %defattr with explicitly set
modes.
mkattr used "-" as default mode which would pick up the mode for files
as they were on disk. This could cause files generated by rpmbuild to
use a "non-standard" mode if umask was set by the user. Explitictly
use 755 for directories and 644 for files to make builds independent
of any umask settings.
This works as is for both files and directories, so no file argument
is necessary anymore.
https://bugzilla.redhat.com/show_bug.cgi?id=1452893
https://bugzilla.redhat.com/show_bug.cgi?id=1458839
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 261ba91172ca1536eaa1d76e9cde58643b66c8f3)
---
build/files.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/build/files.c b/build/files.c
index e88a5d24d..29274926c 100644
--- a/build/files.c
+++ b/build/files.c
@@ -193,13 +193,12 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
*nar = *oar; /* struct assignment */
}
-static char *mkattr(const char *fn)
+/* Creates a default $defattr string. Can be used with argvAdd().
+ Caller owns the new string which needs to be freed when done. */
+static char *mkattr(void)
{
char *s = NULL;
- if (fn)
- rasprintf(&s, "%s(-,%s,%s) %s", "%attr", "root", "root", fn);
- else
- rasprintf(&s, "%s(-,%s,%s)", "%defattr", "root", "root");
+ rasprintf(&s, "%s(644,%s,%s,755)", "%defattr", "root", "root");
return s;
}
@@ -1829,7 +1828,7 @@ static int generateBuildIDs(FileList fl, ARGV_t *files)
debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
/* Make sure to reset all file flags to defaults. */
- attrstr = mkattr(NULL);
+ attrstr = mkattr();
argvAdd(files, attrstr);
free (attrstr);
@@ -2783,7 +2782,7 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
if (access(path, F_OK) == 0) {
/* Append the file list preamble */
if (!files) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&files, attr);
argvAddDir(&files, DEBUG_LIB_DIR);
free(attr);
@@ -2843,7 +2842,7 @@ static int addDebugDwz(Package pkg, char *buildroot)
rasprintf(&path, "%s%s", buildroot, DEBUG_DWZ_DIR);
if (lstat(path, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) {
if (!pkg->fileList) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&pkg->fileList, attr);
argvAddDir(&pkg->fileList, DEBUG_LIB_DIR);
free(attr);
@@ -2877,7 +2876,7 @@ static int addDebugSrc(Package pkg, char *buildroot)
continue;
rasprintf(&path, "%s/%s", DEBUG_SRC_DIR, de->d_name);
if (!pkg->fileList) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&pkg->fileList, attr);
free(attr);
}

View File

@ -1,27 +0,0 @@
From e7462b81f69933f531ee6905681a24ac61e11bf6 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Fri, 7 Jul 2017 11:30:42 +0200
Subject: [PATCH] rpmfc: fix ternary operator
Fixes: 9d5bbd9774d00f50749bb045217eaf91c87b6de0
References: https://bugzilla.redhat.com/show_bug.cgi?id=1468476
Tested-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Signed-off-by: Florian Festi <ffesti@redhat.com>
(cherry picked from commit cbb062963b535186a461dfc9e03558a72ec8004d)
---
build/rpmfc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 72f29ddf5..271bfbea8 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1259,7 +1259,7 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
}
/* Parse dependencies into header */
- rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), dm->ntag ? dm->ntag != -1 : RPMTAG_REQUIRENAME, 0, tagflags, addReqProvPkg, NULL);
+ rc = parseRCPOT(NULL, fc->pkg, getStringBuf(sb_stdout), dm->ntag != -1 ? dm->ntag : RPMTAG_REQUIRENAME, 0, tagflags, addReqProvPkg, NULL);
freeStringBuf(sb_stdout);
if (rc) {

View File

@ -1,100 +0,0 @@
From 7bac47a54fef8fc01fa29865a9622677dbdfa28d Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Wed, 3 Aug 2016 11:14:05 +0200
Subject: [PATCH] let debuginfo packages provide the build-id
This patch lets debuginfo packages provide build-id like follows:
debuginfo(build-id) = c63cb23876c5fa85f36beaff58f8557e1bf22517
Originally this patch was written by Jan Blunck <jblunck@suse.de>.
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
(cherry picked from commit 95712183458748ea6cafebac1bdd5daa097d9bee)
---
fileattrs/Makefile.am | 4 ++--
fileattrs/debuginfo.attr | 2 ++
macros.in | 3 ++-
scripts/Makefile.am | 2 ++
scripts/debuginfo.prov | 14 ++++++++++++++
5 files changed, 22 insertions(+), 3 deletions(-)
create mode 100644 fileattrs/debuginfo.attr
create mode 100755 scripts/debuginfo.prov
diff --git a/fileattrs/Makefile.am b/fileattrs/Makefile.am
index e54395b3b..148d2ff0d 100644
--- a/fileattrs/Makefile.am
+++ b/fileattrs/Makefile.am
@@ -5,8 +5,8 @@ include $(top_srcdir)/rpm.am
fattrsdir = $(rpmconfigdir)/fileattrs
fattrs_DATA = \
- appdata.attr desktop.attr elf.attr font.attr libtool.attr perl.attr \
- perllib.attr pkgconfig.attr python.attr ocaml.attr script.attr \
+ appdata.attr debuginfo.attr desktop.attr elf.attr font.attr libtool.attr \
+ perl.attr perllib.attr pkgconfig.attr python.attr ocaml.attr script.attr \
mono.attr
EXTRA_DIST = $(fattrs_DATA)
diff --git a/fileattrs/debuginfo.attr b/fileattrs/debuginfo.attr
new file mode 100644
index 000000000..03f453843
--- /dev/null
+++ b/fileattrs/debuginfo.attr
@@ -0,0 +1,2 @@
+%__debuginfo_provides %{_rpmconfigdir}/debuginfo.prov
+%__debuginfo_path ^/usr/lib/debug/
diff --git a/macros.in b/macros.in
index 2a114ccd7..962b84ade 100644
--- a/macros.in
+++ b/macros.in
@@ -200,7 +200,8 @@
%package debuginfo\
Summary: Debug information for package %{name}\
Group: Development/Debug\
-AutoReqProv: 0\
+AutoReq: 0\
+AutoProv: 1\
%description debuginfo\
This package provides debug information for package %{name}.\
Debug information is useful when developing applications that use this\
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 036105d63..8e60c3ce7 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -10,6 +10,7 @@ EXTRA_DIST = \
brp-strip-shared brp-strip-static-archive \
check-files check-prereqs \
check-buildroot check-rpaths check-rpaths-worker \
+ debuginfo.prov \
find-debuginfo.sh find-lang.sh \
perl.prov perl.req pythondeps.sh \
rpmdb_loadcvt rpm.daily rpm.log rpm.supp rpm2cpio.sh \
@@ -29,6 +30,7 @@ rpmconfig_SCRIPTS = \
brp-strip-shared brp-strip-static-archive \
check-files check-prereqs \
check-buildroot check-rpaths check-rpaths-worker \
+ debuginfo.prov \
find-lang.sh find-requires find-provides \
perl.prov perl.req pythondeps.sh \
mono-find-requires mono-find-provides \
diff --git a/scripts/debuginfo.prov b/scripts/debuginfo.prov
new file mode 100755
index 000000000..a8636c976
--- /dev/null
+++ b/scripts/debuginfo.prov
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+while read instfile; do
+ case "$instfile" in
+ */usr/lib/debug/.build-id/*.debug)
+ if [ -f "$instfile" ]; then
+ BUILDID=$(echo "$instfile" | sed -ne 's|.*/usr/lib/debug/.build-id/\([0-9a-f]\+\)/\([0-9a-f]\+\)\.debug|\1\2|p')
+ if [ -n "$BUILDID" ]; then
+ echo "debuginfo(build-id) = $BUILDID"
+ fi
+ fi
+ ;;
+ esac
+done

View File

@ -1,81 +0,0 @@
From 85395ae424cf79bc05abe94472bdc11ea9239753 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 17 Jul 2017 12:58:26 +0200
Subject: [PATCH] find-debuginfo.sh: Add --keep-section and --remove-section
for eu-strip.
Use --keep-section SECTION or --remove-section SECTION to explicitly
keep a (non-allocated) section in the main executable or explicitly
remove it into the .debug file. SECTION is an extended wildcard pattern.
Both options can be given more than once.
https://bugzilla.redhat.com/show_bug.cgi?id=1465997
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit b388bfe936dd6d68d2f4efd1b4393bf8f8c13fe8)
---
scripts/find-debuginfo.sh | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 185d25f96..5ec52d3bc 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -3,6 +3,7 @@
#for inclusion in an rpm spec file.
#
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
+# [--keep-section SECTION] [--remove-section SECTION]
# [-j N]
# [-o debugfiles.list]
# [-S debugsourcefiles.list]
@@ -15,9 +16,14 @@
# [builddir]
#
# The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
+# The -r flag says to use eu-strip --reloc-debug-sections.
+# Use --keep-section SECTION or --remove-section SECTION to explicitly
+# keep a (non-allocated) section in the main executable or explicitly
+# remove it into the .debug file. SECTION is an extended wildcard pattern.
+# Both options can be given more than once.
+#
# 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 -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.
@@ -65,6 +71,9 @@ strip_g=false
# with -r arg, pass --reloc-debug-sections to eu-strip.
strip_r=false
+# keep or remove arguments to eu-strip.
+keep_remove_args=
+
# with -m arg, add minimal debuginfo to binary.
include_minidebug=false
@@ -158,6 +167,14 @@ while [ $# -gt 0 ]; do
-r)
strip_r=true
;;
+ --keep-section)
+ keep_remove_args="${keep_remove_args} --keep-section $2"
+ shift
+ ;;
+ --remove-section)
+ keep_remove_args="${keep_remove_args} --remove-section $2"
+ shift
+ ;;
-j)
n_jobs=$2
shift
@@ -215,7 +232,7 @@ strip_to_debug()
application/x-sharedlib*) g=-g ;;
application/x-executable*) g=-g ;;
esac
- eu-strip --remove-comment $r $g -f "$1" "$2" || exit
+ eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
chmod 444 "$1" || exit
}

View File

@ -1,46 +0,0 @@
From 1fb19a11f6d6a4c221f2e1c08fe246761a4d1e82 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 19 Jul 2017 14:53:53 +0200
Subject: [PATCH] find-debuginfo.sh: Remove non-allocated NOBITS sections from
minisymtab.
In the minisymtab section (the .gnu_debugdata embedded ELF image) we
do not need unallocated sections (except for the SYMTAB and STRTAB
sections we are creating). We already remove PROGBITS and NOTES. Also
remove NOBITS sections. They should not really take up much (any) space
but they still add to the section tables. These sections might be created
with the new --keep-section support (which puts the actual section in
the main ELF binary, and a NOBITS variant in the .debug file).
Also binutils objcopy seems to sometimes add them anyway filled with
zeros instead of marking them NOBITS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 860c04e0c3603f4697b7be5fe15ad325369f082c)
---
scripts/find-debuginfo.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 5ec52d3bc..b83e4c6db 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -247,12 +247,16 @@ add_minidebug()
local mini_debuginfo=`mktemp`
# In the minisymtab we don't need the .debug_ sections (already removed
- # by -S) but also not any other non-allocated PROGBITS or NOTE sections.
+ # by -S) but also not other non-allocated PROGBITS, NOTE or NOBITS sections.
# List and remove them explicitly. We do want to keep the allocated,
# symbol and NOBITS sections so cannot use --keep-only because that is
# too agressive. Field $2 is the section name, $3 is the section type
# and $8 are the section flags.
- local remove_sections=`readelf -W -S "$debuginfo" | awk '{ if (index($2,".debug_") != 1 && ($3 == "PROGBITS" || $3 == "NOTE") && index($8,"A") == 0) printf "--remove-section "$2" " }'`
+ local remove_sections=`readelf -W -S "$debuginfo" \
+ | awk '{ if (index($2,".debug_") != 1 \
+ && ($3 == "PROGBITS" || $3 == "NOTE" || $3 == "NOBITS") \
+ && index($8,"A") == 0) \
+ printf "--remove-section "$2" " }'`
# Extract the dynamic symbols from the main binary, there is no need to also have these
# in the normal symbol table

View File

@ -1,31 +0,0 @@
From ff1be07909a9e78295f416b3535dc6aaecbc0350 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 18 Sep 2015 15:29:25 +0200
Subject: [PATCH] Define PY_SSIZE_T_CLEAN
When PyArg_ParseTupleAndKeywords() is used with format argument "s#"
that means get a string and his length then the length is returned as
as a Py_ssize_t in python3 but as an int in python2, which casues
a problem because rpmfd_write() that uses PyArg_ParseTupleAndKeywords()
expects the length as a Py_ssize_t always. This problem affects big
endian systems with python2 as default. If PY_SSIZE_T_CLEAN is defined
then PyArg_ParseTupleAndKeywords() returns the length as a Py_ssize_t
in both python2 and python3.
(cherry picked from commit f0a58d1dced6215b7caaa70db17d54834e0cd44e)
---
python/rpmsystem-py.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
index 50e8770e8..c8423e3dc 100644
--- a/python/rpmsystem-py.h
+++ b/python/rpmsystem-py.h
@@ -5,6 +5,7 @@
#include <sys/types.h>
#endif
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <structmember.h>

View File

@ -1,23 +0,0 @@
From 788eaf73c9b09cc86724264f7558568374b6eb9f Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Wed, 23 Sep 2015 11:30:12 +0200
Subject: [PATCH] Fix error handling in rpmio Python binding test case
(cherry picked from commit 3c74e34e8d8c5b3db024dbe04a352e807ed2b627)
---
tests/rpmpython.at | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/rpmpython.at b/tests/rpmpython.at
index 949673bd8..eac31b20b 100644
--- a/tests/rpmpython.at
+++ b/tests/rpmpython.at
@@ -53,7 +53,7 @@ for iot in [ 'fpio', 'fdio', 'ufdio', 'gzdio' ]:
fd = rpm.fd(fn, 'r', iot)
rdata = fd.read()
if rdata != data:
- myprint('%s read fail (got %d bytes)' % (iot, len(rdata), rdata))
+ myprint('%s read fail (got %d bytes)\n%s' % (iot, len(rdata), rdata))
# compressed io types can't seek
if iot == 'ufdio':
fd.seek(0)

View File

@ -1,23 +0,0 @@
From ee2eec7c7922f8927b4850b385da26384ad05755 Mon Sep 17 00:00:00 2001
From: Jun Aruga <jaruga@redhat.com>
Date: Mon, 3 Jul 2017 17:07:56 +0200
Subject: [PATCH] Return error exit status when make check is failed.
(cherry picked from commit 45d9f54e9669ed44cc632247483f49a42725849b)
---
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 83586ec67..4ccc1a092 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -125,7 +125,7 @@ check_DATA += testing$(bindir)/rpmbuild
if HAVE_FAKECHROOT
check-local: $(check_DATA)
- $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) ||:
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
else
check-local:
echo "you need to have fakechroot installed"

View File

@ -1,32 +0,0 @@
From 56c2885d708bc3485cad2b14205224e082ff2d01 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 28 Jul 2017 07:42:38 +0200
Subject: [PATCH] find-debuginfo.sh: make sure that debugsourcefiles.list is
generated under the builddir
The %_debugsource_template expects the debugsourcefiles.list file
to be in the (current) build dir. Make sure that is always the case
even if find-debuginfo.sh was invoked in a different (sub) directory
by prepending $BUILDDIR to the output file as written in description
"All file names in switches are relative to builddir (. if not given).".
Closes: https://github.com/rpm-software-management/rpm/issues/279
Based-on-patch-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit 436b6ce0ddf33f90f8efd967f0457efce23bd71f)
---
scripts/find-debuginfo.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index b83e4c6db..af065cd23 100644
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -566,6 +566,7 @@ if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
fi
if [ -n "$srcout" ]; then
+ srcout="$BUILDDIR/$srcout"
> "$srcout"
if [ -d "${RPM_BUILD_ROOT}/usr/src/debug" ]; then
(cd "${RPM_BUILD_ROOT}/usr"

View File

@ -1,50 +0,0 @@
From c32af0184db82f74bf506873ec9a69970299dd18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Thu, 19 Nov 2015 13:38:19 +0000
Subject: [PATCH] Avoid redundant processing for RemovePathPostfixes
Only iterate over the file list if RemovePathPostfixes: has been specified.
Also don't bother reallocating the paths as the existing path modified in
place will suffice.
(cherry picked from commit 8e8571a7f33d1ecc5a0c0b62196fd79b26a6052e)
---
build/files.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/build/files.c b/build/files.c
index 29274926c..9b1d2cd98 100644
--- a/build/files.c
+++ b/build/files.c
@@ -980,29 +980,22 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
digestalgo);
digestalgo = defaultalgo;
}
-
+
/* Adjust paths if needed */
+ if (!isSrc && pkg->removePostfixes)
for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
- int changed = 0;
char * cpiopath = flp->cpioPath;
- if (!isSrc && pkg->removePostfixes)
for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
int len = strlen(*postfix_p);
int plen = strlen(cpiopath);
if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
cpiopath[plen-len] = '\0';
- changed = 1;
if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
cpiopath[plen-len-1] = '\0';
}
}
}
- if (changed) {
- char * tmp = xstrdup(cpiopath);
- _free(flp->cpioPath);
- flp->cpioPath = tmp;
- }
}
/* Sort the big list */

View File

@ -1,66 +0,0 @@
From e7ce266784e2b122df03c8023c16ec18ec8209e7 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 28 Jul 2017 14:33:29 +0200
Subject: [PATCH] store path of excluded files
We will need this in next commit so we know which files
were excluded and we will exclude respective debug files.
Reviewed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit b5c2deffd4cb1b19782e11d1537a4a0ba8a52b60)
---
build/files.c | 6 +++++-
build/rpmbuild_internal.h | 1 +
build/spec.c | 2 ++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/build/files.c b/build/files.c
index 9b1d2cd98..b9716b4d8 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1060,7 +1060,11 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
}
/* Skip files that were marked with %exclude. */
- if (flp->flags & RPMFILE_EXCLUDE) continue;
+ if (flp->flags & RPMFILE_EXCLUDE)
+ {
+ argvAdd(&pkg->fileExcludeList, flp->cpioPath);
+ continue;
+ }
/* Collect on-disk paths for archive creation */
pkg->dpaths[npaths++] = xstrdup(flp->diskPath);
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 1c3332faf..5978a6d32 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -118,6 +118,7 @@ struct Package_s {
ARGV_t fileFile;
ARGV_t fileList; /* If NULL, package will not be written */
+ ARGV_t fileExcludeList;
ARGV_t removePostfixes;
ARGV_t policyList;
diff --git a/build/spec.c b/build/spec.c
index 7cb264abd..c33cde7eb 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -101,6 +101,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist)
p->autoProv = 1;
p->autoReq = 1;
p->fileList = NULL;
+ p->fileExcludeList = NULL;
p->fileFile = NULL;
p->policyList = NULL;
p->pool = rpmstrPoolLink(pool);
@@ -143,6 +144,7 @@ static Package freePackage(Package pkg)
}
pkg->fileList = argvFree(pkg->fileList);
+ pkg->fileExcludeList = argvFree(pkg->fileExcludeList);
pkg->fileFile = argvFree(pkg->fileFile);
pkg->policyList = argvFree(pkg->policyList);
pkg->removePostfixes = argvFree(pkg->removePostfixes);

View File

@ -1,39 +0,0 @@
From daf5b95c2b2a9c2e869520240651f4b3c673da38 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 28 Jul 2017 15:21:00 +0200
Subject: [PATCH] exclude respective debug files for files which are excluded
Closes: https://github.com/rpm-software-management/rpm/issues/284
Reviewed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit 1e7d3c58fc7c55e2dd20b5ca459f36a1cd2a3d8e)
---
build/files.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/build/files.c b/build/files.c
index b9716b4d8..36e1ed5ea 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2803,6 +2803,21 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
}
path = _free(path);
}
+ /* Exclude debug files for files which were excluded in respective non-debug package */
+ for (ARGV_const_t excl = pkg->fileExcludeList; excl && *excl; excl++) {
+ const char *name = *excl;
+
+ /* generate path */
+ rasprintf(&path, "%s%s%s%s.debug", buildroot, DEBUG_LIB_DIR, name, uniquearch);
+ /* Exclude only debuginfo files which actually exist */
+ if (access(path, F_OK) == 0) {
+ char *line = NULL;
+ rasprintf(&line, "%%exclude %s", path + buildrootlen);
+ argvAdd(&files, line);
+ _free(line);
+ }
+ path = _free(path);
+ }
/* add collected directories to file list */
if (dirs) {

View File

@ -1,129 +0,0 @@
From bcc54f828865ea5ba8b99acb2b6882f6e32190b0 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 28 Jul 2017 18:30:37 +0200
Subject: [PATCH] store mapping for renamed files
We will need this in next commit so we know which original name
files had, so we can reference appropriate debug file.
Reviewed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit cc8a682c386bf28540dc3fa5dbbb66c57bca5ec5)
---
build/files.c | 42 +++++++++++++++++++++++++++++++-----------
build/rpmbuild_internal.h | 12 ++++++++++++
build/spec.c | 2 ++
3 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/build/files.c b/build/files.c
index 36e1ed5ea..42709a549 100644
--- a/build/files.c
+++ b/build/files.c
@@ -50,6 +50,17 @@
#define DEBUG_ID_DIR "/usr/lib/debug/.build-id"
#define DEBUG_DWZ_DIR "/usr/lib/debug/.dwz"
+#undef HASHTYPE
+#undef HTKEYTYPE
+#undef HTDATATYPE
+#define HASHTYPE fileRenameHash
+#define HTKEYTYPE const char *
+#define HTDATATYPE const char *
+#include "lib/rpmhash.C"
+#undef HASHTYPE
+#undef HTKEYTYPE
+#undef HTDATATYPE
+
/**
*/
enum specfFlags_e {
@@ -982,19 +993,28 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
}
/* Adjust paths if needed */
- if (!isSrc && pkg->removePostfixes)
- for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
- char * cpiopath = flp->cpioPath;
-
- for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
- int len = strlen(*postfix_p);
- int plen = strlen(cpiopath);
- if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
- cpiopath[plen-len] = '\0';
- if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
- cpiopath[plen-len-1] = '\0';
+ if (!isSrc && pkg->removePostfixes) {
+ pkg->fileRenameMap = fileRenameHashCreate(fl->files.used,
+ rstrhash, strcmp,
+ (fileRenameHashFreeKey)rfree, (fileRenameHashFreeData)rfree);
+ for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
+ char * cpiopath = flp->cpioPath;
+ char * cpiopath_orig = xstrdup(cpiopath);
+
+ for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
+ int len = strlen(*postfix_p);
+ int plen = strlen(cpiopath);
+ if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
+ cpiopath[plen-len] = '\0';
+ if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
+ cpiopath[plen-len-1] = '\0';
+ }
}
}
+ if (strcmp(cpiopath_orig, cpiopath))
+ fileRenameHashAddEntry(pkg->fileRenameMap, xstrdup(cpiopath), cpiopath_orig);
+ else
+ _free(cpiopath_orig);
}
}
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 5978a6d32..5dd0a5b83 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -6,6 +6,17 @@
#include <rpm/rpmstrpool.h>
#include "build/rpmbuild_misc.h"
+#undef HASHTYPE
+#undef HTKEYTYPE
+#undef HTDATATYPE
+#define HASHTYPE fileRenameHash
+#define HTKEYTYPE const char *
+#define HTDATATYPE const char *
+#include "lib/rpmhash.H"
+#undef HASHTYPE
+#undef HTKEYTYPE
+#undef HTDATATYPE
+
struct TriggerFileEntry {
int index;
char * fileName;
@@ -120,6 +131,7 @@ struct Package_s {
ARGV_t fileList; /* If NULL, package will not be written */
ARGV_t fileExcludeList;
ARGV_t removePostfixes;
+ fileRenameHash fileRenameMap;
ARGV_t policyList;
Package next;
diff --git a/build/spec.c b/build/spec.c
index c33cde7eb..eaa5dce61 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -104,6 +104,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist)
p->fileExcludeList = NULL;
p->fileFile = NULL;
p->policyList = NULL;
+ p->fileRenameMap = NULL;
p->pool = rpmstrPoolLink(pool);
p->dpaths = NULL;
@@ -148,6 +149,7 @@ static Package freePackage(Package pkg)
pkg->fileFile = argvFree(pkg->fileFile);
pkg->policyList = argvFree(pkg->policyList);
pkg->removePostfixes = argvFree(pkg->removePostfixes);
+ pkg->fileRenameMap = fileRenameHashFree(pkg->fileRenameMap);
pkg->cpioList = rpmfilesFree(pkg->cpioList);
pkg->dpaths = argvFree(pkg->dpaths);

View File

@ -1,38 +0,0 @@
From 1cd1d45798a30b95bd5535463002c148bf04e7e2 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 28 Jul 2017 18:32:06 +0200
Subject: [PATCH] reference proper debug files whenever RemovePathPostfixes is
used
Closes: https://github.com/rpm-software-management/rpm/issues/280
Reviewed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
(cherry picked from commit 98efb7f6dc222ed175516298a34e807053d125f4)
---
build/files.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/build/files.c b/build/files.c
index 42709a549..3b93ac559 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2791,6 +2791,19 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
namel = strlen(name);
if (namel > 6 && !strcmp(name + namel - 6, ".debug"))
namel -= 6;
+
+ /* fileRenameMap doesn't necessarily have to be initialized */
+ if (pkg->fileRenameMap) {
+ const char **names = NULL;
+ int namec = 0;
+ fileRenameHashGetEntry(pkg->fileRenameMap, name, &names, &namec, NULL);
+ if (namec) {
+ if (namec > 1)
+ rpmlog(RPMLOG_WARNING, _("%s was mapped to multiple filenames"), name);
+ name = *names;
+ namel = strlen(name);
+ }
+ }
/* generate path */
rasprintf(&path, "%s%s%.*s%s.debug", buildroot, DEBUG_LIB_DIR, namel, name, uniquearch);

153
rpm.spec
View File

@ -17,8 +17,8 @@
%define rpmhome /usr/lib/rpm %define rpmhome /usr/lib/rpm
%global rpmver 4.13.0.1 %global rpmver 4.13.90
#global snapver rc2 %global snapver git14002
%global srcver %{version}%{?snapver:-%{snapver}} %global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x} %global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x}
@ -29,7 +29,7 @@
Summary: The RPM package management system Summary: The RPM package management system
Name: rpm Name: rpm
Version: %{rpmver} Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}41%{?dist} Release: %{?snapver:0.%{snapver}.}1%{?dist}
Group: System Environment/Base Group: System Environment/Base
Url: http://www.rpm.org/ Url: http://www.rpm.org/
Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2 Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
@ -52,120 +52,6 @@ Patch4: rpm-4.8.1-use-gpg2.patch
Patch5: rpm-4.12.0-rpm2cpio-hack.patch Patch5: rpm-4.12.0-rpm2cpio-hack.patch
# Patches already upstream: # Patches already upstream:
# All patches are tracked on https://pagure.io/rpm-fedora
# Regenerate them using -N and --no-signature to minimize differences:
# git format-patch -N --no-signature rpm-4.13.0.1-release..
Patch100: 0001-Use-correct-source-file-for-rpmsign-module.patch
Patch140: 0002-brp-python-bytecompile-Process-python-lib-dirs-even-.patch
Patch142: 0003-Fix-number-of-references-on-spec_Type-114.patch
# debuginfo backports (#1427970)
Patch250: 0004-Add-build-id-links-to-rpm-for-all-ELF-files.patch
Patch251: 0005-Make-it-possible-to-have-unique-build-ids-across-bui.patch
Patch252: 0006-Make-adding-GDB-index-sections-configurable.patch
Patch253: 0007-Add-option-to-have-unique-debug-file-names-across-ve.patch
Patch254: 0008-Fix-behavior-when-_build_id_links-is-undefined.patch
Patch255: 0009-Fix-debuginfo-etc-when-subpackages-have-different-ve.patch
Patch256: 0010-Only-process-regular-files-when-generating-build-ids.patch
Patch257: 0011-configure.ac-use-LIBDW-always-conditionally.patch
Patch258: 0012-Fix-libdw-configure-check.patch
Patch259: 0013-debugedit-Support-String-Line-table-rewriting-for-la.patch
Patch260: 0014-Add-option-to-have-unique-debug-source-dirs-across-v.patch
# debuginfo build-id warn/error fix (#1430587)
Patch261: 0015-generateBuildIDs-Don-t-warn-or-error-for-object-file.patch
Patch262: 0016-build-files.c-Unset-__debug_package-implies-missing-.patch
Patch263: 0017-generateBuildIDs-Fix-error-handling.patch
Patch264: 0018-Make-sure-to-reset-file-attributes-for-generated-bui.patch
Patch265: 0019-rpmbuild-Reset-attrFlags-in-generateBuildIDs.patch
Patch266: 0020-debugedit-Fix-edit_dwarf2_line-replace_dirs-replace_.patch
Patch267: 0021-build-files.c-processPackageFiles-Don-t-call-generat.patch
Patch268: 0022-debugedit-Fix-cross-endian-build-id-reading-and-upda.patch
Patch269: 0023-tests-tpmbuild.at-Make-file-sed-regexp-more-strict-t.patch
Patch270: 0024-tests-rpmbuildid.at-Make-file-sed-regexp-more-strict.patch
Patch271: 0025-build-files.c-Only-check-build-ids-for-executable-fi.patch
Patch272: 0026-debugedit-Fix-off-by-one-adding-DW_FORM_string-repla.patch
Patch273: 0027-Unbreak-short-circuited-binary-builds.patch
Patch274: 0028-find-debuginfo.sh-Only-add-minisymtab-for-executable.patch
Patch275: 0029-debugedit-Add-n-no-recompute-build-id.patch
Patch276: 0030-Fix-non-standard-inherented-modes-of-directories-in-.patch
# World writable empty (tmp) dirs in debuginfo packages (#641022)
Patch280: 0031-debugedit-Only-output-comp_dir-under-build-dir-once.patch
# Parallel debuginfo processing
Patch281: 0032-find-debuginfo.sh-Split-directory-traversal-and-debu.patch
Patch282: 0033-find-debuginfo.sh-Use-return-not-continue-to-break-o.patch
Patch283: 0034-find-debuginfo.sh-Process-files-in-parallel.patch
# Support debugsource and debuginfo subpackages
Patch284: 0035-Untangle-unique-build-options-in-find-debuginfo.sh.patch
Patch285: 0036-Support-debugsource-subpackages.patch
Patch286: 0037-Support-debuginfo-subpackages.patch
Patch287: 0038-Also-add-directories-to-split-debuginfo-packages.patch
# debugedit check prefix match ends with slash.
Patch290: 0039-debugedit-skip_dir_prefix-should-check-for-dir-separ.patch
# find-debuginfo.sh: Filter out all <built-in> like fake file names.
Patch291: 0040-find-debuginfo.sh-Filter-out-all-built-in-like-fake-.patch
# Don't create dwz multi file if there is only one .debug.
Patch292: 0041-find-debuginfo.sh-Don-t-create-dwz-multi-file-if-the.patch
# Update find-debuginfo.sh options and macros documentation.
Patch293: 0042-Update-find-debuginfo.sh-options-and-macros-document.patch
# OpenSSL backend
Patch300: 0043-Add-OpenSSL-support-for-digest-and-signatures.patch
# Rich dependencies coming from dependency generatos
Patch310: 0044-Use-RPMTAG_-NAME-instead-of-RPMTAG_-FLAGS-in-parsePr.patch
Patch311: 0045-Fix-check-for-weak-deps-in-external-dependency-gener.patch
Patch312: 0046-Fix-check-whether-to-allow-rich-deps-in-a-given-tag.patch
Patch313: 0047-Re-enable-rich-dependecies-for-build-requires-and-co.patch
Patch314: 0048-add-support-for-rich-dependencies-from-dependency-ge.patch
Patch315: 0049-Pass-proper-file-index-when-recording-generated-depe.patch
# Use file list to explicitly set mode for build-id dirs/files.
# https://bugzilla.redhat.com/show_bug.cgi?id=1452893
# https://bugzilla.redhat.com/show_bug.cgi?id=1458839
Patch320: 0050-Consolidate-defattr-attr-root-root-generation-to-hel.patch
Patch321: 0051-Extract-package-file-list-processing-in-separate-fun.patch
Patch322: 0052-Use-a-file-list-to-add-build-id-files-to-pkgList.patch
Patch323: 0053-Change-mkattr-to-always-create-a-defattr-with-explic.patch
# Fix regression from 0044-Use-RPMTAG_-NAME-instead-of-RPMTAG_-FLAGS-in-parsePr.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1468476
Patch330: 0054-rpmfc-fix-ternary-operator.patch
# debuginfo packages should automatically provide debuginfo(build-id) = ...
Patch331: 0055-let-debuginfo-packages-provide-the-build-id.patch
# find-debuginfo.sh: Add --keep-section and --remove-section for eu-strip.
# https://bugzilla.redhat.com/show_bug.cgi?id=1465997
Patch332: 0056-find-debuginfo.sh-Add-keep-section-and-remove-sectio.patch
Patch333: 0057-find-debuginfo.sh-Remove-non-allocated-NOBITS-sectio.patch
# Fix rpmfd_write on big endian arches.
Patch334: 0058-Define-PY_SSIZE_T_CLEAN.patch
Patch335: 0059-Fix-error-handling-in-rpmio-Python-binding-test-case.patch
# Finally make sure that test results are not ignored ;)
Patch340: 0060-Return-error-exit-status-when-make-check-is-failed.patch
# Fix for generation of debugsourcefiles.list in subdirectory
Patch341: 0061-find-debuginfo.sh-make-sure-that-debugsourcefiles.li.patch
# Trivial improvement for RemovePathPostfixes
Patch342: 0062-Avoid-redundant-processing-for-RemovePathPostfixes.patch
# debuginfo_subpackages fixes
Patch343: 0063-store-path-of-excluded-files.patch
Patch344: 0064-exclude-respective-debug-files-for-files-which-are-e.patch
Patch345: 0065-store-mapping-for-renamed-files.patch
Patch346: 0066-reference-proper-debug-files-whenever-RemovePathPost.patch
# These are not yet upstream # These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch Patch906: rpm-4.7.1-geode-i686.patch
@ -408,7 +294,18 @@ Requires: rpm-libs%{_isa} = %{version}-%{release}
%description plugin-ima %description plugin-ima
%{summary} %{summary}
%endif %package plugin-prioreset
Summary: Rpm plugin for resetting scriptlet priorities for SysV init
Group: System Environment/Base
Requires: rpm-libs%{_isa} = %{version}-%{release}
%description plugin-prioreset
%{summary}
Useful on legacy SysV init systems if you run rpm transactions with
nice/ionice priorities. Should not be used on systemd systems.
%endif # with plugins
%prep %prep
%autosetup -n %{name}-%{srcver} %{?with_int_bdb:-a 1} -p1 %autosetup -n %{name}-%{srcver} %{?with_int_bdb:-a 1} -p1
@ -519,7 +416,7 @@ rm -f $RPM_BUILD_ROOT/%{rpmhome}/{tcl.req,osgideps.pl}
%if %{with check} %if %{with check}
%check %check
make check make check
#[ "$(ls -A tests/rpmtests.dir)" ] && cat tests/rpmtests.log [ "$(ls -A tests/rpmtests.dir)" ] && cat tests/rpmtests.log
%endif %endif
%post libs -p /sbin/ldconfig %post libs -p /sbin/ldconfig
@ -540,7 +437,7 @@ exit 0
%files -f %{name}.lang %files -f %{name}.lang
%license COPYING %license COPYING
%doc GROUPS CREDITS doc/manual/[a-z]* %doc CREDITS doc/manual/[a-z]*
/usr/lib/tmpfiles.d/rpm.conf /usr/lib/tmpfiles.d/rpm.conf
%dir %{_sysconfdir}/rpm %dir %{_sysconfdir}/rpm
@ -548,7 +445,7 @@ exit 0
%attr(0755, root, root) %dir /var/lib/rpm %attr(0755, root, root) %dir /var/lib/rpm
%attr(0644, root, root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/rpm/* %attr(0644, root, root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/rpm/*
/bin/rpm %{_bindir}/rpm
%{_bindir}/rpm2archive %{_bindir}/rpm2archive
%{_bindir}/rpm2cpio %{_bindir}/rpm2cpio
%{_bindir}/rpmdb %{_bindir}/rpmdb
@ -560,6 +457,7 @@ exit 0
%{_mandir}/man8/rpmdb.8* %{_mandir}/man8/rpmdb.8*
%{_mandir}/man8/rpmkeys.8* %{_mandir}/man8/rpmkeys.8*
%{_mandir}/man8/rpm2cpio.8* %{_mandir}/man8/rpm2cpio.8*
%{_mandir}/man8/rpm-misc.8*
# XXX this places translated manuals to wrong package wrt eg rpmbuild # XXX this places translated manuals to wrong package wrt eg rpmbuild
%lang(fr) %{_mandir}/fr/man[18]/*.[18]* %lang(fr) %{_mandir}/fr/man[18]/*.[18]*
@ -600,10 +498,14 @@ exit 0
%files plugin-systemd-inhibit %files plugin-systemd-inhibit
%{_libdir}/rpm-plugins/systemd_inhibit.so %{_libdir}/rpm-plugins/systemd_inhibit.so
%{_mandir}/man8/rpm-plugin-systemd-inhibit.8*
%files plugin-ima %files plugin-ima
%{_libdir}/rpm-plugins/ima.so %{_libdir}/rpm-plugins/ima.so
%endif
%files plugin-prioreset
%{_libdir}/rpm-plugins/prioreset.so
%endif # with plugins
%files build-libs %files build-libs
%{_libdir}/librpmbuild.so.* %{_libdir}/librpmbuild.so.*
@ -641,11 +543,11 @@ exit 0
%files -n python2-%{name} %files -n python2-%{name}
%{python_sitearch}/%{name}/ %{python_sitearch}/%{name}/
%{python_sitearch}/%{name}_python-*.egg-info %{python_sitearch}/%{name}-%{version}*.egg-info
%files -n python3-%{name} %files -n python3-%{name}
%{python3_sitearch}/%{name}/ %{python3_sitearch}/%{name}/
%{python3_sitearch}/%{name}_python-*.egg-info %{python3_sitearch}/%{name}-%{version}*.egg-info
%files devel %files devel
%{_mandir}/man8/rpmgraph.8* %{_mandir}/man8/rpmgraph.8*
@ -663,6 +565,9 @@ exit 0
%doc doc/librpm/html/* %doc doc/librpm/html/*
%changelog %changelog
* Thu Aug 10 2017 Panu Matilainen <pmatilai@redhat.com> - 4.13.90-0.git14000.1
- Rebase to rpm 4.13.90 aka 4.14.0-alpha (#1474836)
* Mon Jul 31 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.13.0.1-41 * Mon Jul 31 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.13.0.1-41
- Move _debuginfo_subpackages and _debugsource_packages to redhat-rpm-config - Move _debuginfo_subpackages and _debugsource_packages to redhat-rpm-config