[nodejs-inherits/el6: 7/8] add some %triggerun hackery to fix busted upgrade paths
T.C. Hollingsworth
patches at fedoraproject.org
Fri Aug 16 21:42:36 UTC 2013
commit 73cf684ae221bba3ae4de5b6481d7f4e85bedf20
Author: T.C. Hollingsworth <tchollingsworth at gmail.com>
Date: Fri Aug 16 14:38:54 2013 -0700
add some %triggerun hackery to fix busted upgrade paths
sometimes symlinks end up still pointing to their old (wrong)
locations after upgrade (RHBZ#997978)
nodejs-inherits.spec | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/nodejs-inherits.spec b/nodejs-inherits.spec
index b5dd6ae..9e3f185 100644
--- a/nodejs-inherits.spec
+++ b/nodejs-inherits.spec
@@ -2,7 +2,7 @@
Name: nodejs-inherits
Version: 2.0.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: A tiny simple way to do classic inheritance in js
License: WTFPL
Group: Development/Libraries
@@ -40,13 +40,43 @@ ln -sf inherits at 2 %{buildroot}%{nodejs_sitelib}/inherits
%clean
rm -rf %{buildroot}
+# there have been reports that the symlinks are messed up when upgrading
+# from older versions, so let's make sure everything's copacetic
+%triggerun -- nodejs-inherits < 2.0.0-4
+ln -sf inherits at 2 %{nodejs_sitelib}/inherits
+%{__python} <<EOF
+import json, os
+
+for moddir in os.listdir('%{nodejs_sitelib}'):
+ if os.path.isdir(moddir):
+ md = json.load(open(os.path.join(moddir, 'package.json')))
+
+ if 'dependencies' in md and 'inherits' in md['dependencies']:
+ if isinstance(md['dependencies'], dict) and '1' in md['dependencies']['inherits']:
+ src = os.path.join('%{nodejs_sitelib}', 'inherits at 1')
+ else:
+ src = os.path.join('%{nodejs_sitelib}', 'inherits at 2')
+
+ dest = os.path.join('%{nodejs_sitelib}', moddir, 'node_modules/inherits')
+
+ if not os.path.realpath(dest) == src:
+ try:
+ os.unlink(dest)
+ except OSError:
+ pass
+
+ try:
+ os.symlink(src, dest)
+ except OSError, e:
+ sys.stderr.write(e + '\n')
+EOF
+
# rpm blows up if you try to replace a dir with a symlink or vice-versa
%pretrans -p <lua>
if posix.stat("%{nodejs_sitelib}/inherits", "type") == "directory" then
os.rename('%{nodejs_sitelib}/inherits', '%{nodejs_sitelib}/inherits at 2')
end
-
%files
%defattr(-,root,root,-)
%{nodejs_sitelib}/inherits at 2
@@ -54,6 +84,10 @@ end
%doc README.md LICENSE
%changelog
+* Fri Aug 16 2013 T.C. Hollingsworth <tchollingsworth at gmail.com> - 2.0.0-4
+- add some post-install hackery to work around potential RPM bug resulting in
+ symlinks still pointing to their old locations on upgrade (RHBZ#997978)
+
* Sat Jul 06 2013 T.C. Hollingsworth <tchollingsworth at gmail.com> - 2.0.0-3
- only run the hack when we really need to
More information about the scm-commits
mailing list