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