Add pretrans scriptlet for node_modules

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2022-11-30 15:46:12 -05:00
parent cc73e226d4
commit e518e262b3
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11

View File

@ -733,7 +733,7 @@ NODE_PATH=%{buildroot}%{_prefix}/lib/node_modules:%{buildroot}%{nodejs_private_s
%if 0%{?rhel} && 0%{?rhel} < 8 %if 0%{?rhel} && 0%{?rhel} < 8
%pretrans npm -p <lua> %pretrans %{pkgname}-npm -p <lua>
-- Remove all of the symlinks from the bundled npm node_modules directory -- Remove all of the symlinks from the bundled npm node_modules directory
base_path = "%{_prefix}/lib/node_modules/npm/node_modules/" base_path = "%{_prefix}/lib/node_modules/npm/node_modules/"
d_st = posix.stat(base_path) d_st = posix.stat(base_path)
@ -748,6 +748,22 @@ if d_st then
end end
%endif %endif
# This can be removed once F37 is EOL
%pretrans -n %{pkgname} -p <lua>
path = "/usr/lib/node_modules"
st = posix.stat(path)
if st and st.type == "directory" then
status = os.rename(path, path .. ".rpmmoved")
if not status then
suffix = 0
while not status do
suffix = suffix + 1
status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
end
os.rename(path, path .. ".rpmmoved")
end
end
%files -n %{pkgname} %files -n %{pkgname}
%doc AUTHORS CHANGELOG.md onboarding.md GOVERNANCE.md README.md %doc AUTHORS CHANGELOG.md onboarding.md GOVERNANCE.md README.md