From e518e262b3bf55300852cfde646bc5c644f35d46 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 30 Nov 2022 15:46:12 -0500 Subject: [PATCH] Add pretrans scriptlet for node_modules Signed-off-by: Stephen Gallagher --- nodejs18.spec | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nodejs18.spec b/nodejs18.spec index f2c0bb4..af795dc 100644 --- a/nodejs18.spec +++ b/nodejs18.spec @@ -733,7 +733,7 @@ NODE_PATH=%{buildroot}%{_prefix}/lib/node_modules:%{buildroot}%{nodejs_private_s %if 0%{?rhel} && 0%{?rhel} < 8 -%pretrans npm -p +%pretrans %{pkgname}-npm -p -- Remove all of the symlinks from the bundled npm node_modules directory base_path = "%{_prefix}/lib/node_modules/npm/node_modules/" d_st = posix.stat(base_path) @@ -748,6 +748,22 @@ if d_st then end %endif +# This can be removed once F37 is EOL +%pretrans -n %{pkgname} -p +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} %doc AUTHORS CHANGELOG.md onboarding.md GOVERNANCE.md README.md