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
This commit is contained in:
Miro Hrončok 2021-04-27 10:00:02 +02:00
parent cad73c2159
commit 03a1e3ba65
3 changed files with 20 additions and 11 deletions

View File

@ -4,13 +4,13 @@
# Which unfortunately makes the definition more complicated than it should be # Which unfortunately makes the definition more complicated than it should be
# Usage: # Usage:
# %py_byte_compile <interpereter> <path> # %%py_byte_compile <interpereter> <path>
# Example: # 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, # This will terminate build on SyntaxErrors, if you want to avoid that,
# use it in a subshell like this: # use it in a subshell like this:
# (%{py_byte_compile <interpereter> <path>}) || : # (%%{py_byte_compile <interpereter> <path>}) || :
# Setting PYTHONHASHSEED=0 disables Python hash seed randomization # Setting PYTHONHASHSEED=0 disables Python hash seed randomization
# This should help with byte-compilation reproducibility: https://bugzilla.redhat.com/show_bug.cgi?id=1686078 # This should help with byte-compilation reproducibility: https://bugzilla.redhat.com/show_bug.cgi?id=1686078

View File

@ -47,7 +47,7 @@
# a specific version (e.g. 34 in Fedora EPEL7) # a specific version (e.g. 34 in Fedora EPEL7)
%python3_pkgversion 3 %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 %__python3_other /bin/true
%py3_other_build /bin/true %py3_other_build /bin/true
%py3_other_install /bin/true %py3_other_install /bin/true
@ -68,7 +68,7 @@
# Creates Python 2 dist tag(s) after converting names to canonical format # 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 # 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:\ %py2_dist() %{lua:\
args = {}\ args = {}\
arg = 1\ arg = 1\
@ -88,7 +88,7 @@
# Creates Python 3 dist tag(s) after converting names to canonical format # 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 # 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:\ %py3_dist() %{lua:\
python3_pkgversion = rpm.expand("%python3_pkgversion");\ python3_pkgversion = rpm.expand("%python3_pkgversion");\
args = {}\ args = {}\
@ -110,12 +110,12 @@
# Macro to replace overly complicated references to PyPI source files. # Macro to replace overly complicated references to PyPI source files.
# Expands to the pythonhosted URL for a package # Expands to the pythonhosted URL for a package
# Accepts zero to three arguments: # Accepts zero to three arguments:
# 1: The PyPI project name, defaulting to %srcname if it is defined, then # 1: The PyPI project name, defaulting to %%srcname if it is defined, then
# %pypi_name if it is defined, then just %name. # %%pypi_name if it is defined, then just %%name.
# 2: The PYPI version, defaulting to %version with tildes stripped. # 2: The PYPI version, defaulting to %%version with tildes stripped.
# 3: The file extension, defaulting to "tar.gz". (A period will be added # 3: The file extension, defaulting to "tar.gz". (A period will be added
# automatically.) # 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_url https://files.pythonhosted.org/packages/source/
%__pypi_default_extension tar.gz %__pypi_default_extension tar.gz

View File

@ -29,7 +29,7 @@ elseif posix.stat('macros.python-srpm') then
end end
} }
Version: %{__default_python3_version} Version: %{__default_python3_version}
Release: 37%{?dist} Release: 38%{?dist}
BuildArch: noarch BuildArch: noarch
@ -88,6 +88,11 @@ mkdir -p %{buildroot}%{_rpmconfigdir}/redhat
install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
%check
# no macros in comments
! grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.*
%files %files
%{rpmmacrodir}/macros.python %{rpmmacrodir}/macros.python
%{rpmmacrodir}/macros.pybytecompile %{rpmmacrodir}/macros.pybytecompile
@ -102,6 +107,10 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
%changelog %changelog
* Tue Apr 27 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-38
- Escape %% symbols in macro files comments
- Fixes: rhbz#1953910
* Wed Apr 07 2021 Karolina Surma <ksurma@redhat.com> - 3.9-37 * Wed Apr 07 2021 Karolina Surma <ksurma@redhat.com> - 3.9-37
- Use sysconfig.get_path() to get %%python3_sitelib and %%python3_sitearch - Use sysconfig.get_path() to get %%python3_sitelib and %%python3_sitearch
- Fixes: rhbz#1946972 - Fixes: rhbz#1946972