From 149ad39f435bf2190af185717f6c7387742eee7e Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 22 2016 14:18:29 +0000 Subject: import nodejs010-2.1-5.el7 --- diff --git a/SOURCES/macros.nodejs b/SOURCES/macros.nodejs index 5d53ddb..6d3cfe8 100644 --- a/SOURCES/macros.nodejs +++ b/SOURCES/macros.nodejs @@ -33,6 +33,6 @@ # macro to invoke the Node.js provides and requires generators %nodejs_find_provides_and_requires %{expand: \ %global _use_internal_dependency_generator 0 -%global __find_provides %{_rpmconfigdir}/nodejs010-provide.sh -%global __find_requires %{_rpmconfigdir}/nodejs010-require.sh +%global __find_provides %{_rpmconfigdir}/nodejs010.prov +%global __find_requires %{_rpmconfigdir}/nodejs010.req } diff --git a/SOURCES/multiver_modules b/SOURCES/multiver_modules index 6b01890..2dc44eb 100644 --- a/SOURCES/multiver_modules +++ b/SOURCES/multiver_modules @@ -1 +1,3 @@ +uglify-js inherits +nan \ No newline at end of file diff --git a/SOURCES/nodejs-fixdep b/SOURCES/nodejs-fixdep index 47766ea..6d5ce21 100755 --- a/SOURCES/nodejs-fixdep +++ b/SOURCES/nodejs-fixdep @@ -23,30 +23,76 @@ # IN THE SOFTWARE. import json +import optparse import os +import re import shutil import sys +RE_VERSION = re.compile(r'\s*v?([<>=~^]{0,2})\s*([0-9][0-9\.\-]*)\s*') + +p = optparse.OptionParser( + description='Modifies dependency entries in package.json files') + +p.add_option('-r', '--remove', action='store_true') +p.add_option('--dev', action='store_const', const='devDependencies', + dest='deptype', help='affect devDependencies') +p.add_option('--optional', action='store_const', const='optionalDependencies', + dest='deptype', help='affect optionalDependencies') +p.add_option('--caret', action='store_true', + help='convert all or specified dependencies to use the caret operator') + +options, args = p.parse_args() + if not os.path.exists('package.json~'): shutil.copy2('package.json', 'package.json~') md = json.load(open('package.json')) -if 'dependencies' not in md: - md['dependencies'] = {} +deptype = options.deptype if options.deptype is not None else 'dependencies' + +if deptype not in md: + md[deptype] = {} + +# convert alternate JSON dependency representations to a dictionary +if not options.caret and not isinstance(md[deptype], dict): + if isinstance(md[deptype], list): + deps = md[deptype] + md[deptype] = {} + for dep in deps: + md[deptype][dep] = '*' + elif isinstance(md[deptype], basestring): + md[deptype] = { md[deptype] : '*' } -if sys.argv[1] == '-r': - dep = sys.argv[2] - del md['dependencies'][dep] +if options.remove: + dep = args[0] + del md[deptype][dep] +elif options.caret: + if not isinstance(md[deptype], dict): + sys.stderr.write('All dependencies are unversioned. Unable to apply ' + + 'caret operator.\n') + sys.exit(2) + + deps = args if len(args) > 0 else md[deptype].keys() + for dep in deps: + if md[deptype][dep][0] == '^': + continue + elif md[deptype][dep][0] in ('~','0','1','2','3','4','5','6','7','8','9'): + ver = re.match(RE_VERSION, md[deptype][dep]).group(2) + md[deptype][dep] = '^' + ver + else: + sys.stderr.write('Attempted to convert non-numeric or tilde ' + + 'dependency to caret. This is not permitted.\n') + sys.exit(1) else: - dep = sys.argv[1] + dep = args[0] - if len(sys.argv) > 2: - ver = sys.argv[2] + if len(args) > 1: + ver = args[1] else: ver = '*' - md['dependencies'][dep] = ver + md[deptype][dep] = ver fh = open('package.json', 'w') data = json.JSONEncoder(indent=4).encode(md) diff --git a/SOURCES/nodejs-symlink-deps b/SOURCES/nodejs-symlink-deps index e4a574d..fe029df 100755 --- a/SOURCES/nodejs-symlink-deps +++ b/SOURCES/nodejs-symlink-deps @@ -25,6 +25,7 @@ can `npm link` RPM-installed modules into their personal projects.""" import json import os +import shutil import sys def symlink(source, dest): @@ -42,6 +43,14 @@ Please report this to upstream. For more information, see: """.format(dest)) + elif '--force' in sys.argv: + if os.path.isdir(dest): + shutil.rmtree(dest) + else: + os.unlink(dest) + + os.symlink(source, dest) + else: sys.stderr.write(""" ERROR: the path for dependency "{0}" already exists @@ -64,6 +73,9 @@ version of the module and eliminate this error. def symlink_deps(deps, check): if isinstance(deps, dict): + #read in the list of mutiple-versioned packages + mvpkgs = open('/opt/rh/nodejs010/root/usr/share/node/multiver_modules').read().split('\n') + for dep, ver in deps.iteritems(): if dep in mvpkgs and ver != '' and ver != '*': depver = ver.lstrip('~').split('.')[0] @@ -92,10 +104,7 @@ def symlink_deps(deps, check): #the %nodejs_symlink_deps macro passes %nodejs_sitelib as the first argument sitelib = sys.argv[1] -#read in the list of mutiple-versioned packages -mvpkgs = open('/opt/rh/nodejs010/root/usr/share/node/multiver_modules').read().split('\n') - -if '--check' in sys.argv: +if '--check' in sys.argv or '--build' in sys.argv: check = True modules = [os.getcwd()] else: diff --git a/SOURCES/nodejs.req b/SOURCES/nodejs.req index b924441..e4967fd 100755 --- a/SOURCES/nodejs.req +++ b/SOURCES/nodejs.req @@ -6,7 +6,7 @@ Automatic dependency generator for Node.js libraries. Parsed from package.json. See `man npm-json` for details. """ -# Copyright 2012 T.C. Hollingsworth +# Copyright 2012, 2013 T.C. Hollingsworth # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to @@ -28,11 +28,12 @@ Parsed from package.json. See `man npm-json` for details. from __future__ import unicode_literals import json +import os import re import subprocess import sys -RE_VERSION = re.compile(r'\s*v?([<>=~]{0,2})\s*([0-9][0-9\.\-]*)\s*') +RE_VERSION = re.compile(r'\s*v?([<>=~^]{0,2})\s*([0-9][0-9\.\-]*)\s*') def main(): #npm2rpm uses functions here to write BuildRequires so don't print anything @@ -44,34 +45,41 @@ def main(): paths = [path.rstrip() for path in sys.stdin.readlines()] for path in paths: - if path.endswith('package.json'): - fh = open(path) - metadata = json.load(fh) - fh.close() + if not path.endswith('package.json'): + continue - #write out the node.js interpreter dependency - req = 'nodejs010-nodejs(engine)' - - if 'engines' in metadata and isinstance(metadata['engines'], dict) \ - and 'node' in metadata['engines']: - deps += process_dep(req, metadata['engines']['node']) - else: - deps.append(req) + # we only want the package.json in the toplevel module directory + pathparts = path.split(os.sep) + if not pathparts[-5:-2] == ['usr', 'lib', 'node_modules']: + continue + + fh = open(path) + metadata = json.load(fh) + fh.close() + + #write out the node.js interpreter dependency + req = 'nodejs010-nodejs(engine)' + + if 'engines' in metadata and isinstance(metadata['engines'], dict) \ + and 'node' in metadata['engines']: + deps += process_dep(req, metadata['engines']['node']) + else: + deps.append(req) - if 'dependencies' in metadata: - if isinstance(metadata['dependencies'], dict): - for name, version in metadata['dependencies'].iteritems(): - req = 'nodejs010-npm(' + name + ')' - deps += process_dep(req, version) - elif isinstance(metadata['dependencies'], list): - for name in metadata['dependencies']: - req = 'nodejs010-npm(' + name + ')' - deps.append(req) - elif isinstance(metadata['dependencies'], basestring): - req = 'nodejs010-npm(' + metadata['dependencies'] + ')' + if 'dependencies' in metadata: + if isinstance(metadata['dependencies'], dict): + for name, version in metadata['dependencies'].iteritems(): + req = 'nodejs010-npm(' + name + ')' + deps += process_dep(req, version) + elif isinstance(metadata['dependencies'], list): + for name in metadata['dependencies']: + req = 'nodejs010-npm(' + name + ')' deps.append(req) - else: - raise TypeError('invalid package.json: dependencies not a valid type') + elif isinstance(metadata['dependencies'], basestring): + req = 'nodejs010-npm(' + metadata['dependencies'] + ')' + deps.append(req) + else: + raise TypeError('invalid package.json: dependencies not a valid type') print '\n'.join(deps) @@ -133,30 +141,40 @@ def convert_dep(req, operator, version): parts = [int(part) if part != 'x' and not '-' in part else part for part in parts] - # 1 or 1.x or 1.x.x or ~1 + # 1 or 1.x or 1.x.x or ~1 or ^1 if len(parts) == 1 or parts[1] == 'x': if parts[0] != 0: deps.append('{0} >= {1}'.format(req, parts[0])) deps.append('{0} < {1}'.format(req, parts[0]+1)) - # 1.2.3 or 1.2.3-4 or 1.2.x or ~1.2.3 or 1.2 + # 1.2.3 or 1.2.3-4 or 1.2.x or ~1.2.3 or ^1.2.3 or 1.2 elif len(parts) == 3 or operator != '~': # 1.2.x or 1.2 if len(parts) == 2 or parts[2] == 'x': deps.append('{0} >= {1}.{2}'.format(req, parts[0], parts[1])) deps.append('{0} < {1}.{2}'.format(req, parts[0], parts[1]+1)) - # ~1.2.3 - elif operator == '~': + # ~1.2.3 or ^0.1.2 (zero is special with the caret operator) + elif operator == '~' or (operator == '^' and parts[0] == 0 and parts[1] > 0): deps.append('{0} >= {1}'.format(req, version)) deps.append('{0} < {1}.{2}'.format(req, parts[0], parts[1]+1)) - # 1.2.3 or 1.2.3-4 + #^1.2.3 + elif operator == '^' and parts[0:1] != [0,0]: + deps.append('{0} >= {1}'.format(req, version)) + deps.append('{0} < {1}'.format(req, parts[0]+1)) + # 1.2.3 or 1.2.3-4 or ^0.0.3 else: deps.append('{0} = {1}'.format(req, version)) # ~1.2 - else: + elif operator == '~': deps.append('{0} >= {1}'.format(req, version)) deps.append('{0} < {1}'.format(req, parts[0]+1)) + + #^1.2 + elif operator == '^': + deps.append('{0} >= {1}'.format(req, version)) + deps.append('{0} < {1}'.format(req, parts[0]+1)) + return deps diff --git a/SPECS/nodejs010.spec b/SPECS/nodejs010.spec index 765c357..e552cfe 100644 --- a/SPECS/nodejs010.spec +++ b/SPECS/nodejs010.spec @@ -12,7 +12,7 @@ Summary: %scl Software Collection Name: %scl_name Version: 2.1 -Release: 3%{?dist} +Release: 5%{?dist} Source1: macros.nodejs Source2: nodejs.attr @@ -165,8 +165,12 @@ install -m 644 %{scl_name}.7 %{buildroot}%{_mandir}/man7/%{scl_name}.7 %{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel %changelog -* Fri Oct 02 2015 Zuzana Svetlikova - 2.1-3 -- Enable installing whole collection +* Thu Jan 14 2016 Tomas Hrcka - 2.1-5 +- Include nodemon in collection +- Update packaging scripts and macros + +* Sun Oct 02 2015 Zuzana Svetlikova - 2.1-3 +- Enable installing of whole collection * Thu Jul 02 2015 Tomas Hrcka - 2.1-2 - RHSCL 2.1 release @@ -182,16 +186,17 @@ install -m 644 %{scl_name}.7 %{buildroot}%{_mandir}/man7/%{scl_name}.7 * Mon Oct 06 2014 Tomas Hrcka - 1.2-28 - bump scl version -* Mon Oct 06 2014 Tomas Hrcka - 1.1-27 +* Mon Oct 06 2014 Tomas Hrcka - 1.2-27 - Require scriptlet scl_devel instead of specific scl-utils version -* Mon Mar 31 2014 Honza Horak - 1.1-26 +* Mon Sep 08 2014 Tomas Hrcka - 1.2-26 +- Fix version of scl-utils required by this package +- Bump version + +* Mon Mar 31 2014 Honza Horak - 1.1-25 - Fix path typo in README Related: #1061452 -* Tue Mar 25 2014 Tomas Hrcka - 1.1-25 -- Fix ownership of man pages - * Mon Feb 17 2014 Tomas Hrcka - 1.1-24 - Require version of scl-utils @@ -202,13 +207,6 @@ install -m 644 %{scl_name}.7 %{buildroot}%{_mandir}/man7/%{scl_name}.7 - Some more grammar fixes in README Related: #1061452 -* Wed Feb 12 2014 Tomas Hrcka - 1.1-21 -- Add nodejs010-scldevel sub package - -* Tue Feb 11 2014 Tomas Hrcka - 1.1-20 -- Add LICENSE, README and nodejs010.7 man page -- Minor changes in collection macros nodejs-fixdep,nodejs-symlink-deps - * Tue Jan 21 2014 Tomas Hrcka - 1-21 - Rebuilt for rhbz#1054252