From 4559c0e65ffde455bc462f15a27aed5a9c015da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Sat, 28 Dec 2019 19:10:09 +0100 Subject: [PATCH] Define %python, but make it work only if %__python is redefined --- macros.python-srpm | 10 ++++++++++ python-rpm-macros.spec | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/macros.python-srpm b/macros.python-srpm index 62e7431..4fc56c8 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -11,6 +11,16 @@ %python2 %__python2 %python3 %__python3 +# Users can use %%python only if they redefined %%__python (e.g. to %%__python3) +%python() %{lua:\ + __python = rpm.expand("%__python")\ + if __python == "/usr/bin/python" then\ + rpm.expand("%{error:Cannot use %%python if %%__python wasn't redefined to something other than /usr/bin/python.}")\ + else\ + print(__python)\ + end\ +} + # python3_pkgversion specifies the version of Python 3 in the distro. It can be # a specific version (e.g. 34 in Fedora EPEL7) %python3_pkgversion 3 diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 04423c5..2059ff0 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 43%{?dist} +Release: 44%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -73,6 +73,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %changelog +* Sat Dec 28 2019 Miro Hrončok - 3-44 +- Define %%python, but make it work only if %%__python is redefined + * Fri Sep 27 2019 Miro Hrončok - 3-43 - Define %%python2 and %%python3