Produce bit-by-bit identical .pyc files across different architectures, to avoid multilib conflicts

Resolves rhbz#2008912
This commit is contained in:
Miro Hrončok 2021-10-05 22:39:54 +02:00
parent a4640c18cd
commit 947d874c70

View File

@ -37,6 +37,7 @@ BuildRequires: pkgconfig(mount)
BuildRequires: pkgconfig(sysprof-capture-4) BuildRequires: pkgconfig(sysprof-capture-4)
BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(zlib)
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: /usr/bin/marshalparser
# For gnutls-hmac.patch. We now dlopen libgnutls.so.30 so that we can build a # For gnutls-hmac.patch. We now dlopen libgnutls.so.30 so that we can build a
# static glib2 without depending on a static build of GnuTLS as well. This will # static glib2 without depending on a static build of GnuTLS as well. This will
@ -116,19 +117,25 @@ rm -rf subprojects
%install %install
%meson_install %meson_install
# Since this is a generated .py file, set it to a known timestamp for
# better reproducibility. # We need reproducible .pyc files across architectures to support multilib installations
# https://bugzilla.redhat.com/show_bug.cgi?id=2008912
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/#_byte_compilation_reproducibility
%global py_reproducible_pyc_path %{buildroot}%{_datadir}
# Since this is a generated .py file, set it to a known timestamp
# because the source timestamp is baked into the .pyc file
# Also copy the timestamp for other .py files, because meson doesn't # Also copy the timestamp for other .py files, because meson doesn't
# do this, see https://github.com/mesonbuild/meson/issues/5027. # do this, see https://github.com/mesonbuild/meson/issues/5027.
touch -r gio/gdbus-2.0/codegen/config.py.in %{buildroot}%{_datadir}/glib-2.0/codegen/*.py touch -r gio/gdbus-2.0/codegen/config.py.in %{buildroot}%{_datadir}/glib-2.0/codegen/*.py
chrpath --delete %{buildroot}%{_libdir}/*.so chrpath --delete %{buildroot}%{_libdir}/*.so
# Perform byte compilation manually to avoid issues with # Perform byte compilation manually to avoid issues with
# irreproducibility of the default invalidation mode, see # irreproducibility of the default invalidation mode, see
# https://www.python.org/dev/peps/pep-0552/ and # https://www.python.org/dev/peps/pep-0552/ and
# https://bugzilla.redhat.com/show_bug.cgi?id=1686078 # https://bugzilla.redhat.com/show_bug.cgi?id=1686078
export PYTHONHASHSEED=0 %py_byte_compile %{python3} %{buildroot}%{_datadir}
%py_byte_compile %{__python3} %{buildroot}%{_datadir}
mv %{buildroot}%{_bindir}/gio-querymodules %{buildroot}%{_bindir}/gio-querymodules-%{__isa_bits} mv %{buildroot}%{_bindir}/gio-querymodules %{buildroot}%{_bindir}/gio-querymodules-%{__isa_bits}
sed -i -e "/^gio_querymodules=/s/gio-querymodules/gio-querymodules-%{__isa_bits}/" %{buildroot}%{_libdir}/pkgconfig/gio-2.0.pc sed -i -e "/^gio_querymodules=/s/gio-querymodules/gio-querymodules-%{__isa_bits}/" %{buildroot}%{_libdir}/pkgconfig/gio-2.0.pc