In this change:
https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error
We have advised the following:
pathfix.py -pni "%{__python3} %{py3_shbang_opts}" <paths>
To fix the shebangs.
-p preserves timestamps -n prevents creating ~backup files -i specifies the interpreter for the shebang
Now we have new features and we ultimately want this for the best experience:
pathfix.py -pni %{python3} -ka %{py3_shbang_opts_nodash}
-k keeps existing flags -a adds our flags (if not already there) %py3_shbang_opts_nodash is derived from %py3_shbang_opts
This is very tedious copypasta.
I propose we macronize this as follows:
We create %py3_shebang_flags. By default, it is the same as %py3_shbang_opts without dash to avoid confusion, but it can be overridden. Note the proper "e" in the name.
We create %py3_shebang_fix:
pathfix.py -pni %{__python3} -k%{?py3_shebang_flags:a %py3_shebang_flags}
Usage:
%prep %autosetup %py3_shebang_fix .
Or:
%install ...install stuff... %py3_shebang_fix %{buildroot}%{python3_sitearch} %{buildroot}%{_bindir}/*
As a side not, is it possible to have conditonal expansion not expand on empty macro?
E.g. this works:
%undefine py3_shebang_flags %{?py3_shebang_flags:a %py3_shebang_flags} -> nothing
But this does not:
%global py3_shebang_flags %{nil} %{?py3_shebang_flags:a %py3_shebang_flags} -> a
If not, we'll advise the users to undefine when they want "empty flags".
Le mercredi 06 mai 2020 à 13:44 +0200, Miro Hrončok a écrit : Hi, Miro
As a side not, is it possible to have conditonal expansion not expand on empty macro?
If not, we'll advise the users to undefine when they want "empty flags".
That won’t work if you need to build upon those macros in the future lua-side. The official documented rpm lua API does not contain undefine, just define.
Because of this, in my own Fedora macro sets, unsetting already set variables safely, or emptying them, is done with rpm.define(rpmvar .. " %{nil}")
And the test to check if a variable is free to be set, is checking if "%{foo}" expands to "%{foo}". Anything else means something else already touched the variable in the spec file and the result should best be left alone.
Macros that consume the result then have to use rpm.expand("%{?foo}") as input. Which seems to work as expected in all cases.
Regards,
On 2020-05-06 14:18, Nicolas Mailhot wrote:
Le mercredi 06 mai 2020 à 13:44 +0200, Miro Hrončok a écrit : Hi, Miro
As a side not, is it possible to have conditonal expansion not expand on empty macro?
If not, we'll advise the users to undefine when they want "empty flags".
That won’t work if you need to build upon those macros in the future lua-side. The official documented rpm lua API does not contain undefine, just define.
Do you know if that's a technical limitation, or just an omission in the docs?
packaging@lists.fedoraproject.org