On 11. 02. 23 17:58, Mattia Verga wrote:
Sctriptlets are expanded on build time, so rpm.expand() is unnecessary and
dangerous.
Don't use it in sctriptlets. Use the macros directly.
See:
https://src.fedoraproject.org/rpms/python-notebook/blob/f35/f/python-note...
%pretrans -n python3-%{pypi_name} -p <lua>
path = "%{python3_sitelib}/%{pypi_name}/static/components/moment"
st = posix.stat(path)
if st and st.type == "link" then
os.remove(path)
end
$ rpm -qp --scripts python3-notebook-6.4.0-4.fc35.noarch.rpm
pretrans scriptlet (using <lua>):
path = "/usr/lib/python3.10/site-packages/notebook/static/components/moment"
st = posix.stat(path)
if st and st.type == "link" then
os.remove(path)
end
If the rpm.expand() call actually was there, you would end up with:
path =
rpm.expand("/usr/lib/python3.10/site-packages/notebook/static/components/moment")
Which is not necessary. And even if you escaped the %-signs like this:
path = rpm.expand("%%{python3_sitelib}/%{pypi_name}/static/components/moment")
You would (probably) end up with:
path = rpm.expand("%{python3_sitelib}/%{pypi_name}/static/components/moment")
Which would fail on runtime if python3-rpm-macros is not instilled.
Oh thanks for the tip. I was unsure if macros would have been translated when used between
quotes in a lua script.
Mattia