teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0025-buildid-reset-attrs.patch

Mark Wielaard 117a78
commit b91dc6106e360f13ff365dfac247191942039152
Mark Wielaard 117a78
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard 117a78
Date:   Wed Mar 15 20:07:29 2017 +0100
Mark Wielaard 117a78
Mark Wielaard 117a78
    Make sure to reset file attributes for generated build-id directories.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    [Note this patch is currently being tested in Fedora. See bug below.]
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    When creating the build-id directories we should reset the file attributes
Mark Wielaard 117a78
    to the defaults. Otherwise if the file list contained an %attr or %defattr
Mark Wielaard 117a78
    the directories would come out with the wrong mode.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    Includes a testcase based on a spec by Igor Gnatenko that fails before
Mark Wielaard 117a78
    and Check that build-id directories are created with the right permissions
Mark Wielaard 117a78
    even if the spec file sets attrs explicitly.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    https://bugzilla.redhat.com/show_bug.cgi?id=1432372
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard 117a78
Mark Wielaard 117a78
[Just the testcase]
Mark Wielaard 117a78
Mark Wielaard 117a78
diff --git a/tests/Makefile.am b/tests/Makefile.am
Mark Wielaard 117a78
index 815a390..ad41957 100644
Mark Wielaard 117a78
--- a/tests/Makefile.am
Mark Wielaard 117a78
+++ b/tests/Makefile.am
Mark Wielaard 117a78
@@ -69,6 +69,8 @@ EXTRA_DIST += data/RPMS/hello-2.0-1.i686.rpm
Mark Wielaard 117a78
 EXTRA_DIST += data/RPMS/hello-2.0-1.x86_64.rpm
Mark Wielaard 117a78
 EXTRA_DIST += data/SRPMS/foo-1.0-1.src.rpm
Mark Wielaard 117a78
 EXTRA_DIST += data/SRPMS/hello-1.0-1.src.rpm
Mark Wielaard 117a78
+EXTRA_DIST += data/SOURCES/hello.c
Mark Wielaard 117a78
+EXTRA_DIST += data/SPECS/hello-attr-buildid.spec
Mark Wielaard 117a78
 
Mark Wielaard 117a78
 # testsuite voodoo
Mark Wielaard 117a78
 AUTOTEST = $(AUTOM4TE) --language=autotest
Mark Wielaard 117a78
diff --git a/tests/data/SOURCES/hello.c b/tests/data/SOURCES/hello.c
Mark Wielaard 117a78
new file mode 100644
Mark Wielaard 117a78
index 0000000..020484e
Mark Wielaard 117a78
--- /dev/null
Mark Wielaard 117a78
+++ b/tests/data/SOURCES/hello.c
Mark Wielaard 117a78
@@ -0,0 +1,8 @@
Mark Wielaard 117a78
+#include <stdio.h>
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+int
Mark Wielaard 117a78
+main (void)
Mark Wielaard 117a78
+{
Mark Wielaard 117a78
+  printf ("Hello, world!\n");
Mark Wielaard 117a78
+  return 0;
Mark Wielaard 117a78
+}
Mark Wielaard 117a78
diff --git a/tests/data/SPECS/hello-attr-buildid.spec b/tests/data/SPECS/hello-attr-buildid.spec
Mark Wielaard 117a78
new file mode 100644
Mark Wielaard 117a78
index 0000000..cdab95f
Mark Wielaard 117a78
--- /dev/null
Mark Wielaard 117a78
+++ b/tests/data/SPECS/hello-attr-buildid.spec
Mark Wielaard 117a78
@@ -0,0 +1,27 @@
Mark Wielaard 117a78
+Name:           test
Mark Wielaard 117a78
+Version:        1.0
Mark Wielaard 117a78
+Release:        1
Mark Wielaard 117a78
+Summary:        Test
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+License:        Public Domain
Mark Wielaard 117a78
+URL:            https://fedoraproject.org
Mark Wielaard 117a78
+Source:         hello.c
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%description
Mark Wielaard 117a78
+%{summary}.
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%prep
Mark Wielaard 117a78
+%autosetup -c -D -T
Mark Wielaard 117a78
+cp -a %{S:0} .
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%build
Mark Wielaard 117a78
+gcc -g hello.c -o hello
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%install
Mark Wielaard 117a78
+mkdir -p %{buildroot}%{_bindir}
Mark Wielaard 117a78
+install -D -p -m 0755 -t %{buildroot}%{_bindir} hello
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%files
Mark Wielaard 117a78
+%attr(644,root,root) %{_bindir}/hello
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%changelog
Mark Wielaard 117a78
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
Mark Wielaard 117a78
index 15c0620..1cae26d 100644
Mark Wielaard 117a78
--- a/tests/rpmbuildid.at
Mark Wielaard 117a78
+++ b/tests/rpmbuildid.at
Mark Wielaard 117a78
@@ -1166,3 +1166,39 @@ if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi
Mark Wielaard 117a78
 ],
Mark Wielaard 117a78
 [ignore])
Mark Wielaard 117a78
 AT_CLEANUP
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# ------------------------------
Mark Wielaard 117a78
+# Check that build-id directories are created with the right permissions
Mark Wielaard 117a78
+# even if the spec file sets attrs explicitly.
Mark Wielaard 117a78
+AT_SETUP([rpmbuild buildid attrs])
Mark Wielaard 117a78
+AT_KEYWORDS([build] [debuginfo] [buildid])
Mark Wielaard 117a78
+AT_CHECK([
Mark Wielaard 117a78
+rm -rf ${TOPDIR}
Mark Wielaard 117a78
+AS_MKDIR_P(${TOPDIR}/SOURCES)
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# Setup sources
Mark Wielaard 117a78
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# Build, contains one ELF which should have a buildid.
Mark Wielaard 117a78
+run rpmbuild \
Mark Wielaard 117a78
+  --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \
Mark Wielaard 117a78
+  --rcfile=${abs_top_builddir}/rpmrc \
Mark Wielaard 117a78
+  --define="_build_id_links compat" \
Mark Wielaard 117a78
+  --define "_unique_debug_names 1" \
Mark Wielaard 117a78
+  --define "_unique_debug_srcs 1" \
Mark Wielaard 117a78
+  --quiet -ba "${abs_srcdir}"/data/SPECS/hello-attr-buildid.spec
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
Mark Wielaard 117a78
+        ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm \
Mark Wielaard 117a78
+	| grep "build-id d"
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
Mark Wielaard 117a78
+        ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm \
Mark Wielaard 117a78
+	| grep "build-id d"
Mark Wielaard 117a78
+],
Mark Wielaard 117a78
+[0],
Mark Wielaard 117a78
+[/usr/lib/.build-id drwxr-xr-x
Mark Wielaard 117a78
+/usr/lib/debug/.build-id drwxr-xr-x
Mark Wielaard 117a78
+],
Mark Wielaard 117a78
+[ignore])
Mark Wielaard 117a78
+AT_CLEANUP
Mark Wielaard 117a78
Mark Wielaard 117a78
commit 9d942049cf929d5a053c239cdd64f5b97d182c14
Mark Wielaard 117a78
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard 117a78
Date:   Fri May 19 23:11:39 2017 +0200
Mark Wielaard 117a78
Mark Wielaard 117a78
    rpmbuild: Reset attrFlags in generateBuildIDs.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    Debuginfo directories and files could be marked as configuration files
Mark Wielaard 117a78
    if the file list ended with a config file.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    Patch by Panu Matilainen. Testcase by me.
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    https://bugzilla.redhat.com/show_bug.cgi?id=1449732
Mark Wielaard 117a78
    
Mark Wielaard 117a78
    Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard 117a78
Mark Wielaard 117a78
diff --git a/build/files.c b/build/files.c
Mark Wielaard 117a78
index 791bbe2..86c601b 100644
Mark Wielaard 117a78
--- a/build/files.c
Mark Wielaard 117a78
+++ b/build/files.c
Mark Wielaard 117a78
@@ -1860,6 +1860,8 @@ static int generateBuildIDs(FileList fl)
Mark Wielaard 117a78
 	       Uses parseForAttr to reset ar, arFlags, and specdFlags.
Mark Wielaard 117a78
 	       Note that parseForAttr pokes at the attrstr, so we cannot
Mark Wielaard 117a78
 	       just pass a static string. */
Mark Wielaard 117a78
+	    fl->cur.attrFlags = 0;
Mark Wielaard 117a78
+	    fl->def.attrFlags = 0;
Mark Wielaard 117a78
 	    fl->def.verifyFlags = RPMVERIFY_ALL;
Mark Wielaard 117a78
 	    fl->cur.verifyFlags = RPMVERIFY_ALL;
Mark Wielaard 117a78
 	    fl->def.specdFlags |= SPECD_VERIFY;
Mark Wielaard 117a78
 
Mark Wielaard 117a78
diff --git a/tests/data/SPECS/hello-config-buildid.spec b/tests/data/SPECS/hello-config-buildid.spec
Mark Wielaard 117a78
new file mode 100644
Mark Wielaard 117a78
index 0000000..ca2d30d
Mark Wielaard 117a78
--- /dev/null
Mark Wielaard 117a78
+++ b/tests/data/SPECS/hello-config-buildid.spec
Mark Wielaard 117a78
@@ -0,0 +1,30 @@
Mark Wielaard 117a78
+Name:           test
Mark Wielaard 117a78
+Version:        1.0
Mark Wielaard 117a78
+Release:        1
Mark Wielaard 117a78
+Summary:        Test
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+License:        Public Domain
Mark Wielaard 117a78
+URL:            https://fedoraproject.org
Mark Wielaard 117a78
+Source:         hello.c
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%description
Mark Wielaard 117a78
+%{summary}.
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%prep
Mark Wielaard 117a78
+%autosetup -c -D -T
Mark Wielaard 117a78
+cp -a %{S:0} .
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%build
Mark Wielaard 117a78
+gcc -g hello.c -o hello
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%install
Mark Wielaard 117a78
+mkdir -p %{buildroot}/bin
Mark Wielaard 117a78
+install -D -p -m 0755 -t %{buildroot}/bin hello
Mark Wielaard 117a78
+mkdir -p %{buildroot}/etc
Mark Wielaard 117a78
+echo "settings" > %{buildroot}/etc/config.file
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%files
Mark Wielaard 117a78
+%attr(644,root,root) /bin/hello
Mark Wielaard 117a78
+%config(noreplace) /etc/config.file
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+%changelog
Mark Wielaard 117a78
diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at
Mark Wielaard 117a78
index 88ce226..4fab3d5 100644
Mark Wielaard 117a78
--- a/tests/rpmbuildid.at
Mark Wielaard 117a78
+++ b/tests/rpmbuildid.at
Mark Wielaard 117a78
@@ -1324,3 +1324,35 @@ run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
Mark Wielaard 117a78
 ],
Mark Wielaard 117a78
 [ignore])
Mark Wielaard 117a78
 AT_CLEANUP
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# ------------------------------
Mark Wielaard 117a78
+# Check that build-id directories are created with the right attributes
Mark Wielaard 117a78
+# even if the spec file sets config explicitly.
Mark Wielaard 117a78
+AT_SETUP([rpmbuild buildid config attrs])
Mark Wielaard 117a78
+AT_KEYWORDS([build] [debuginfo] [buildid])
Mark Wielaard 117a78
+AT_CHECK([
Mark Wielaard 117a78
+rm -rf ${TOPDIR}
Mark Wielaard 117a78
+AS_MKDIR_P(${TOPDIR}/SOURCES)
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# Setup sources
Mark Wielaard 117a78
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# Build, contains one ELF which should have a buildid.
Mark Wielaard 117a78
+run rpmbuild \
Mark Wielaard 117a78
+  --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \
Mark Wielaard 117a78
+  --rcfile=${abs_top_builddir}/rpmrc \
Mark Wielaard 117a78
+  --define="_build_id_links compat" \
Mark Wielaard 117a78
+  --define "_unique_debug_names 1" \
Mark Wielaard 117a78
+  --define "_unique_debug_srcs 1" \
Mark Wielaard 117a78
+  --quiet -ba "${abs_srcdir}"/data/SPECS/hello-config-buildid.spec
Mark Wielaard 117a78
+
Mark Wielaard 117a78
+# Should contain one config file.
Mark Wielaard 117a78
+run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm
Mark Wielaard 117a78
+# Should not contain config files.
Mark Wielaard 117a78
+run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm
Mark Wielaard 117a78
+],
Mark Wielaard 117a78
+[0],
Mark Wielaard 117a78
+[/etc/config.file
Mark Wielaard 117a78
+],
Mark Wielaard 117a78
+[ignore])
Mark Wielaard 117a78
+AT_CLEANUP
Mark Wielaard 117a78