From a272f5982519bb58f95d743df16fc15bdf9a17b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 27 Apr 2021 10:36:11 +0000 Subject: [PATCH] Escape % symbols in macro files comments This is most likely not neccessary but can prevent serious problems like: https://bugzilla.redhat.com/show_bug.cgi?id=1953910 Related: rhbz#1950291 --- macros.pybytecompile | 6 +++--- macros.python-srpm | 14 +++++++------- python-rpm-macros.spec | 11 ++++++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/macros.pybytecompile b/macros.pybytecompile index 7bd555b..b58fff4 100644 --- a/macros.pybytecompile +++ b/macros.pybytecompile @@ -4,13 +4,13 @@ # Which unfortunately makes the definition more complicated than it should be # Usage: -# %py_byte_compile +# %%py_byte_compile # Example: -# %py_byte_compile %{__python3} %{buildroot}%{_datadir}/spam/plugins/ +# %%py_byte_compile %%{__python3} %%{buildroot}%%{_datadir}/spam/plugins/ # This will terminate build on SyntaxErrors, if you want to avoid that, # use it in a subshell like this: -# (%{py_byte_compile }) || : +# (%%{py_byte_compile }) || : # Setting PYTHONHASHSEED=0 disables Python hash seed randomization # This should help with byte-compilation reproducibility: https://bugzilla.redhat.com/show_bug.cgi?id=1686078 diff --git a/macros.python-srpm b/macros.python-srpm index efe2bba..4957492 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -47,7 +47,7 @@ # a specific version (e.g. 34 in Fedora EPEL7) %python3_pkgversion 3 -# Set to /bin/true to avoid %ifdefs and %{? in specfiles +# Set to /bin/true to avoid %%ifdefs and %%{? in specfiles %__python3_other /bin/true %py3_other_build /bin/true %py3_other_install /bin/true @@ -68,7 +68,7 @@ # Creates Python 2 dist tag(s) after converting names to canonical format # Needs to first put all arguments into a list, because invoking a different -# macro (%py_dist_name) overwrites them +# macro (%%py_dist_name) overwrites them %py2_dist() %{lua:\ args = {}\ arg = 1\ @@ -88,7 +88,7 @@ # Creates Python 3 dist tag(s) after converting names to canonical format # Needs to first put all arguments into a list, because invoking a different -# macro (%py_dist_name) overwrites them +# macro (%%py_dist_name) overwrites them %py3_dist() %{lua:\ python3_pkgversion = rpm.expand("%python3_pkgversion");\ args = {}\ @@ -110,12 +110,12 @@ # Macro to replace overly complicated references to PyPI source files. # Expands to the pythonhosted URL for a package # Accepts zero to three arguments: -# 1: The PyPI project name, defaulting to %srcname if it is defined, then -# %pypi_name if it is defined, then just %name. -# 2: The PYPI version, defaulting to %version with tildes stripped. +# 1: The PyPI project name, defaulting to %%srcname if it is defined, then +# %%pypi_name if it is defined, then just %%name. +# 2: The PYPI version, defaulting to %%version with tildes stripped. # 3: The file extension, defaulting to "tar.gz". (A period will be added # automatically.) -# Requires %__pypi_url and %__pypi_default_extension to be defined. +# Requires %%__pypi_url and %%__pypi_default_extension to be defined. %__pypi_url https://files.pythonhosted.org/packages/source/ %__pypi_default_extension tar.gz diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 4f63475..35ba7c9 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3.9 -Release: 37%{?dist} +Release: 38%{?dist} Summary: The common Python RPM macros # macros and lua: MIT, compileall2.py: PSFv2 @@ -76,6 +76,11 @@ mkdir -p %{buildroot}%{_rpmconfigdir}/redhat install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ +%check +# no macros in comments +! grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* + + %files %{rpmmacrodir}/macros.python %{rpmmacrodir}/macros.pybytecompile @@ -90,6 +95,10 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ %changelog +* Tue Apr 27 2021 Miro HronĨok - 3.9-38 +- Escape %% symbols in macro files comments +- Fixes: rhbz#1953910 + * Fri Apr 16 2021 Karolina Surma - 3.9-37 - Use sysconfig.get_path() to get %%python3_sitelib and %%python3_sitearch - Fixes: rhbz#1947468