[nodejs/f18] %nodejs_symlink_deps improvements

T.C. Hollingsworth patches at fedoraproject.org
Mon Apr 1 05:02:14 UTC 2013


commit b22ee6fcc9fb0c4f48b777fb0f67cf46531e6678
Author: T.C. Hollingsworth <tchollingsworth at gmail.com>
Date:   Sun Mar 31 21:26:43 2013 -0700

    %nodejs_symlink_deps improvements
    
    -support installing multiple modules from the same SRPM
    -drop name argument rendered useless by the above
    -support a --check argument that works in the current working directory
     instead of $RPM_BUILD_ROOT

 nodejs-symlink-deps |   43 +++++++++++++++++++++++--------------------
 nodejs.spec         |    3 +++
 2 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/nodejs-symlink-deps b/nodejs-symlink-deps
index f5636bb..e53e8e5 100755
--- a/nodejs-symlink-deps
+++ b/nodejs-symlink-deps
@@ -3,7 +3,7 @@
 """Symlink a node module's dependencies into the node_modules directory so users
 can `npm link` RPM-installed modules into their personal projects."""
 
-# Copyright 2012 T.C. Hollingsworth <tchollingsworth at gmail.com>
+# Copyright 2012, 2013 T.C. Hollingsworth <tchollingsworth at gmail.com>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to
@@ -30,23 +30,26 @@ import sys
 #the %nodejs_symlink_deps macro passes %nodejs_sitelib as the first argument
 sitelib = sys.argv[1]
 
-metadata = json.load(open('package.json'))
-
-if len(sys.argv) > 2:
-    name = sys.argv[2]
+if '--check' in sys.argv:
+    check = True
+    modules = [os.getcwd()]
 else:
-    name = metadata['name']
-
-os.chdir(os.path.join(os.environ['RPM_BUILD_ROOT'], sitelib.lstrip('/'), name))
-
-if 'dependencies' in metadata:
-    try:
-        os.mkdir('node_modules')
-    except OSError:
-        sys.stderr.write('WARNING: node_modules already exists. Make sure you have ' +
-                            'no bundled dependencies.\n')
-
-    os.chdir('node_modules')
-
-    for dep in metadata['dependencies'].iterkeys():
-        os.symlink(os.path.join(sitelib, dep), dep)
+    check = False
+    br_sitelib = os.path.join(os.environ['RPM_BUILD_ROOT'], sitelib.lstrip('/'))
+    modules = [os.path.join(br_sitelib, module) for module in os.listdir(br_sitelib)]
+
+for path in modules:
+    os.chdir(path)
+    md = json.load(open('package.json'))
+    
+    if 'dependencies' in md:
+        try:
+            os.mkdir('node_modules')
+        except OSError:
+            sys.stderr.write('WARNING: node_modules already exists. Make sure you have ' +
+                                'no bundled dependencies.\n')
+
+        os.chdir('node_modules')
+
+        for dep in md['dependencies'].iterkeys():
+            os.symlink(os.path.join(sitelib, dep), dep)
diff --git a/nodejs.spec b/nodejs.spec
index daf9e31..dc76fc1 100644
--- a/nodejs.spec
+++ b/nodejs.spec
@@ -194,6 +194,9 @@ cp -p common.gypi %{buildroot}%{_datadir}/node
 - remove %%nodejs_arches macro since it will only be useful if it is present in
   the redhat-rpm-config package
 - add default filtering macro to remove unwanted Provides from native modules
+- nodejs-symlink-deps now supports multiple modules in one SRPM properly
+- nodejs-symlink-deps also now supports a --check argument that works in the
+  current working directry instead of the buildroot
 
 * Fri Mar 22 2013 T.C. Hollingsworth <tchollingsworth at gmail.com> - 0.10.1-1
 - new upstream release 0.10.1


More information about the scm-commits mailing list