diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.gitignore diff --git a/.rh-nodejs12.metadata b/.rh-nodejs12.metadata new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.rh-nodejs12.metadata diff --git a/SOURCES/LICENSE b/SOURCES/LICENSE new file mode 100644 index 0000000..d27a669 --- /dev/null +++ b/SOURCES/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2018 by Red Hat inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/SOURCES/README b/SOURCES/README new file mode 100644 index 0000000..746aae9 --- /dev/null +++ b/SOURCES/README @@ -0,0 +1,38 @@ +Package %{scl_name} provides Node.js platform delivered as a Software +Collection. For more information about Software Collections, +see the scl(1) man page. By installing the %{scl_name} collection, +you will get the minimum working set of packages to have a working Node.js platform. + +Usage: scl enable %{scl} 'node' + +Software Collections allow you to build and execute applications +which are not located in the filesystem root hierarchy, +but are stored in an alternative location, which is %{_scl_root} +in case of the %{scl_name} collection. + +Node.js is a platform built on Chrome's JavaScript runtime +for easily building fast, scalable network applications. +Node.js uses an event-driven, non-blocking I/O model that +makes it lightweight and efficient, perfect for data-intensive +real-time applications that run across distributed devices. + +When you want to work with the %{scl_name} collection, use the scl +utility (see the scl(1) man page for usage) to enable the scl +environment. + +Examples: +scl enable %{scl_name} 'command --arg' + Run a specific command with the argument --arg within the %{scl_name} + software collections environment. + +scl enable %{scl_name} 'node' + Run node from the %{scl_name} software collection. + +scl enable %{scl_name} bash + Run an interactive shell with the %{scl_name} software collection enabled. + +scl enable %{scl_name} 'man node' + Show man pages for the node command, which is a part of the + %{scl_name} software collection. + +Report bugs to . diff --git a/SOURCES/macros.nodejs b/SOURCES/macros.nodejs new file mode 100644 index 0000000..8bf3e70 --- /dev/null +++ b/SOURCES/macros.nodejs @@ -0,0 +1,38 @@ +# nodejs binary +%__nodejs %{_bindir}/node + +# nodejs library directory +%nodejs_sitelib %{_prefix}/lib/node_modules + +#arch specific library directory +#for future-proofing only; we don't do multilib +%nodejs_sitearch %{nodejs_sitelib} + +# currently installed nodejs version +%nodejs_version %(%{__nodejs} -v | sed s/v//) + +# symlink dependencies so `npm link` works +# this should be run in every module's %%install section +# pass --check to work in the current directory instead of the buildroot +# pass --no-devdeps to ignore devDependencies when --check is used +%nodejs_symlink_deps %{_rpmconfigdir}/nodejs-symlink-deps %{nodejs_sitelib} + +# patch package.json to fix a dependency +# see `man npm-json` for details on writing dependencies for package.json files +# e.g. `%%nodejs_fixdep frobber` makes any version of frobber do +# `%%nodejs_fixdep frobber '>1.0'` requires frobber > 1.0 +# `%%nodejs_fixdep -r frobber removes the frobber dep +%nodejs_fixdep %{_rpmconfigdir}/rh-nodejs12-fixdep + +# patch package.json to set the package version +# e.g. `%%nodejs_setversion 1.2.3` +# %nodejs_setversion %{_rpmconfigdir}/rh-nodejs12-setversion +%nodejs_setversion %{_rpmconfigdir}/nodejs-setversion + +# macro to filter unwanted provides from Node.js binary native modules +%nodejs_default_filter %{expand: \ +%global __provides_exclude_from ^%{nodejs_sitearch}/.*\\.node$ +} + +# no-op macro to allow spec compatibility with EPEL +%nodejs_find_provides_and_requires %{nil} diff --git a/SOURCES/multiver_modules b/SOURCES/multiver_modules new file mode 100644 index 0000000..2dc44eb --- /dev/null +++ b/SOURCES/multiver_modules @@ -0,0 +1,3 @@ +uglify-js +inherits +nan \ No newline at end of file diff --git a/SOURCES/nodejs-fixdep b/SOURCES/nodejs-fixdep new file mode 100755 index 0000000..b425435 --- /dev/null +++ b/SOURCES/nodejs-fixdep @@ -0,0 +1,117 @@ +#!/usr/bin/python + +"""Modify a dependency listed in a package.json file""" + +# Copyright 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 +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# 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('-m', '--move', 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')) + +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], str): + md[deptype] = { md[deptype] : '*' } + +if options.remove: + dep = args[0] + del md[deptype][dep] +elif options.move: + dep = args[0] + ver = None + for fromtype in ['dependencies', 'optionalDependencies', 'devDependencies']: + if fromtype in md: + if isinstance(md[fromtype], dict) and dep in md[fromtype]: + ver = md[fromtype][dep] + del md[fromtype][dep] + elif isinstance(md[fromtype], list) and md[fromtype].count(dep) > 0: + ver = '*' + md[fromtype].remove(dep) + elif isinstance(md[fromtype], str) and md[fromtype] == dep: + ver = '*' + del md[fromtype] + if ver != None: + md[deptype][dep] = ver +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 = args[0] + + if len(args) > 1: + ver = args[1] + else: + ver = '*' + + md[deptype][dep] = ver + +fh = open('package.json', 'w') +data = json.JSONEncoder(indent=4).encode(md) +fh.write(data) +fh.close() diff --git a/SOURCES/nodejs-setversion b/SOURCES/nodejs-setversion new file mode 100755 index 0000000..b266603 --- /dev/null +++ b/SOURCES/nodejs-setversion @@ -0,0 +1,43 @@ +#!/usr/bin/python + +"""Set a package version in a package.json file""" + +# Copyright 2018 Tom Hughes +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +import json +import os +import shutil +import sys + +if not os.path.exists('package.json~'): + shutil.copy2('package.json', 'package.json~') + +md = json.load(open('package.json')) + +if 'version' in md and sys.argv[1] != md['version']: + raise RuntimeError('Version is already set to {0}'.format(md['version'])) +else: + md['version'] = sys.argv[1] + +fh = open('package.json', 'w') +data = json.JSONEncoder(indent=4).encode(md) +fh.write(data) +fh.close() diff --git a/SOURCES/nodejs-symlink-deps b/SOURCES/nodejs-symlink-deps new file mode 100755 index 0000000..05ab5c1 --- /dev/null +++ b/SOURCES/nodejs-symlink-deps @@ -0,0 +1,140 @@ +#!/usr/bin/python + +"""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, 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 +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +import json +import os +import shutil +import sys + +def symlink(source, dest): + try: + os.symlink(source, dest) + except OSError: + if os.path.islink(dest) and os.path.realpath(dest) == os.path.normpath(source): + sys.stderr.write(""" +WARNING: the symlink for dependency "{0}" already exists + +This could mean that the dependency exists in both devDependencies and +dependencies, which may cause trouble for people using this module with npm. + +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 + +This could mean that bundled modules are being installed. Bundled libraries are +forbidden in Fedora. For more information, see: + + +It is generally reccomended to remove the entire "node_modules" directory in +%prep when it exists. For more information, see: + + +If you have obtained permission from the Fedora Packaging Committee to bundle +libraries, please use `%nodejs_fixdep -r` in %prep to remove the dependency on +the bundled module. This will prevent an unnecessary dependency on the system +version of the module and eliminate this error. +""".format(dest)) + sys.exit(1) + + +def symlink_deps(deps, check): + if isinstance(deps, dict): + #read in the list of mutiple-versioned packages + mvpkgs = open('/opt/rh/rh-nodejs12/root/usr/share/node/multiver_modules').read().split('\n') + + for dep, ver in deps.items(): + if dep in mvpkgs and ver != '' and ver != '*' and ver != 'latest': + depver = ver.lstrip('~^').split('.')[0] + target = os.path.join(sitelib, '{0}@{1}'.format(dep, depver)) + else: + target = os.path.join(sitelib, dep) + + if not check or os.path.exists(target): + symlink(target, dep) + + elif isinstance(deps, list): + for dep in deps: + target = os.path.join(sitelib, dep) + if not check or os.path.exists(target): + symlink(target, dep) + + elif isinstance(deps, str): + target = os.path.join(sitelib, deps) + if not check or os.path.exists(target): + symlink(target, deps) + + else: + raise TypeError("Invalid package.json: dependencies weren't a recognized type") + + +#the %nodejs_symlink_deps macro passes %nodejs_sitelib as the first argument +sitelib = sys.argv[1] + +if '--check' in sys.argv or '--build' in sys.argv: + check = True + modules = [os.getcwd()] +else: + 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)] + +if '--optional' in sys.argv: + optional = True +else: + optional = False + +for path in modules: + os.chdir(path) + md = json.load(open('package.json')) + + if 'dependencies' in md or (check and 'devDependencies' in md) or (optional and 'optionalDependencies' 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') + + if 'dependencies' in md: + symlink_deps(md['dependencies'], check) + + if check and '--no-devdeps' not in sys.argv and 'devDependencies' in md: + symlink_deps(md['devDependencies'], check) + + if optional and 'optionalDependencies' in md: + symlink_deps(md['optionalDependencies'], check) diff --git a/SOURCES/nodejs.attr b/SOURCES/nodejs.attr new file mode 100644 index 0000000..f4adddd --- /dev/null +++ b/SOURCES/nodejs.attr @@ -0,0 +1,3 @@ +%__rh_nodejs12_provides %{_rpmconfigdir}/rh_nodejs12.prov +%__rh_nodejs12_requires %{_rpmconfigdir}/rh_nodejs12.req +%__rh_nodejs12_path ^(/opt/rh/rh-nodejs12/root)?/usr/lib(64)?/node_modules/[^/]+/package\\.json$ diff --git a/SOURCES/nodejs.prov b/SOURCES/nodejs.prov new file mode 100755 index 0000000..3caba34 --- /dev/null +++ b/SOURCES/nodejs.prov @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2012 T.C. Hollingsworth +# Copyright 2017 Tomas Tomecek +# Copyright 2019 Jan Stanek +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +"""Automatic provides generator for Node.js libraries. + +Metadata taken from package.json. See `man npm-json` for details. +""" + +from __future__ import print_function, with_statement + +import json +import os +import sys +from itertools import chain, groupby + +DEPENDENCY_TEMPLATE = "rh-nodejs12-npm(%(name)s) = %(version)s" +BUNDLED_TEMPLATE = "bundled(nodejs-%(name)s) = %(version)s" +NODE_MODULES = {"node_modules", "node_modules.bundled"} + + +class PrivatePackage(RuntimeError): + """Private package metadata that should not be listed.""" + + +#: Something is wrong with the ``package.json`` file +_INVALID_METADATA_FILE = (IOError, PrivatePackage, KeyError) + + +def format_metadata(metadata, bundled=False): + """Format ``package.json``-like metadata into RPM dependency. + + Arguments: + metadata (dict): Package metadata, presumably read from ``package.json``. + bundled (bool): Should the bundled dependency format be used? + + Returns: + str: RPM dependency (i.e. ``npm(example) = 1.0.0``) + + Raises: + KeyError: Expected key (i.e. ``name``, ``version``) missing in metadata. + PrivatePackage: The metadata indicate private (unlisted) package. + """ + + # Skip private packages + if metadata.get("private", False): + raise PrivatePackage(metadata) + + template = BUNDLED_TEMPLATE if bundled else DEPENDENCY_TEMPLATE + return template % metadata + + +def generate_dependencies(module_path, module_dir_set=NODE_MODULES): + """Generate RPM dependency for a module and all it's dependencies. + + Arguments: + module_path (str): Path to a module directory or it's ``package.json`` + module_dir_set (set): Base names of directories to look into + for bundled dependencies. + + Yields: + str: RPM dependency for the module and each of it's (public) bundled dependencies. + + Raises: + ValueError: module_path is not valid module or ``package.json`` file + """ + + # Determine paths to root module directory and package.json + if os.path.isdir(module_path): + root_dir = module_path + elif os.path.basename(module_path) == "package.json": + root_dir = os.path.dirname(module_path) + else: # Invalid metadata path + raise ValueError("Invalid module path '%s'" % module_path) + + for dir_path, subdir_list, __ in os.walk(root_dir): + # Currently in node_modules (or similar), continue to subdirs + if os.path.basename(dir_path) in module_dir_set: + continue + + # Read and format metadata + metadata_path = os.path.join(dir_path, "package.json") + bundled = dir_path != root_dir + try: + with open(metadata_path, mode="r") as metadata_file: + metadata = json.load(metadata_file) + yield format_metadata(metadata, bundled=bundled) + except _INVALID_METADATA_FILE: + pass # Ignore + + # Only visit subdirectories in module_dir_set + subdir_list[:] = list(module_dir_set & set(subdir_list)) + + +if __name__ == "__main__": + module_paths = (path.strip() for path in sys.stdin) + provides = chain.from_iterable(generate_dependencies(m) for m in module_paths) + + # sort|uniq + for provide, __ in groupby(sorted(provides)): + print(provide) diff --git a/SOURCES/nodejs.req b/SOURCES/nodejs.req new file mode 100755 index 0000000..76ca68f --- /dev/null +++ b/SOURCES/nodejs.req @@ -0,0 +1,712 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2012, 2013 T.C. Hollingsworth +# Copyright 2019 Jan Staněk +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +""" Automatic dependency generator for Node.js libraries. + +Metadata parsed from package.json. See `man npm-json` for details. +""" + +from __future__ import print_function, with_statement + +import json +import operator +import os +import re +import sys +from collections import namedtuple +from itertools import chain +from itertools import takewhile + +# Python version detection +_PY2 = sys.version_info[0] <= 2 +_PY3 = sys.version_info[0] >= 3 + +if _PY2: + from future_builtins import map, filter + + +#: Name format of the requirements +REQUIREMENT_NAME_TEMPLATE = "npm({name})" + +#: ``simple`` product of the NPM semver grammar. +RANGE_SPECIFIER_SIMPLE = re.compile( + r""" + (?P + <= | >= | < | > | = # primitive + | ~ | \^ # tilde/caret operators + )? + \s*(?P\S+)\s* # version specifier + """, + flags=re.VERBOSE, +) + + +class UnsupportedVersionToken(ValueError): + """Version specifier contains token unsupported by the parser.""" + + +class Version(tuple): + """Normalized RPM/NPM version. + + The version has up to 3 components – major, minor, patch. + Any part set to None is treated as unspecified. + + :: + + 1.2.3 == Version(1, 2, 3) + 1.2 == Version(1, 2) + 1 == Version(1) + * == Version() + """ + + __slots__ = () + + #: Version part meaning 'Any' + #: ``xr`` in https://docs.npmjs.com/misc/semver#range-grammar + _PART_ANY = re.compile(r"^[xX*]$") + #: Numeric version part + #: ``nr`` in https://docs.npmjs.com/misc/semver#range-grammar + _PART_NUMERIC = re.compile(r"0|[1-9]\d*") + + def __new__(cls, *args): + """Create new version. + + Arguments: + Version components in the order of "major", "minor", "patch". + All parts are optional:: + + >>> Version(1, 2, 3) + Version(1, 2, 3) + >>> Version(1) + Version(1) + >>> Version() + Version() + + Returns: + New Version. + """ + + if len(args) > 3: + raise ValueError("Version has maximum of 3 components") + return super(Version, cls).__new__(cls, map(int, args)) + + def __repr__(self): + """Pretty debugging format.""" + + return "{0}({1})".format(self.__class__.__name__, ", ".join(map(str, self))) + + def __str__(self): + """RPM version format.""" + + return ".".join(format(part, "d") for part in self) + + @property + def major(self): + """Major version number, if any.""" + return self[0] if len(self) > 0 else None + + @property + def minor(self): + """Major version number, if any.""" + return self[1] if len(self) > 1 else None + + @property + def patch(self): + """Major version number, if any.""" + return self[2] if len(self) > 2 else None + + @property + def empty(self): + """True if the version contains nothing but zeroes.""" + return not any(self) + + @classmethod + def parse(cls, version_string): + """Parse individual version string (like ``1.2.3``) into Version. + + This is the ``partial`` production in the grammar: + https://docs.npmjs.com/misc/semver#range-grammar + + Examples:: + + >>> Version.parse("1.2.3") + Version(1, 2, 3) + >>> Version.parse("v2.x") + Version(2) + >>> Version.parse("") + Version() + + Arguments: + version_string (str): The version_string to parse. + + Returns: + Version: Parsed result. + """ + + # Ignore leading ``v``, if any + version_string = version_string.lstrip("v") + + part_list = version_string.split(".", 2) + # Use only parts up to first "Any" indicator + part_list = list(takewhile(lambda p: not cls._PART_ANY.match(p), part_list)) + + if not part_list: + return cls() + + # Strip off and discard any pre-release or build qualifiers at the end. + # We can get away with this, because there is no sane way to represent + # these kinds of version requirements in RPM, and we generally expect + # the distro will only carry proper releases anyway. + try: + part_list[-1] = cls._PART_NUMERIC.match(part_list[-1]).group() + except AttributeError: # no match + part_list.pop() + + # Extend with ``None``s at the end, if necessary + return cls(*part_list) + + def incremented(self): + """Increment the least significant part of the version:: + + >>> Version(1, 2, 3).incremented() + Version(1, 2, 4) + >>> Version(1, 2).incremented() + Version(1, 3) + >>> Version(1).incremented() + Version(2) + >>> Version().incremented() + Version() + + Returns: + Version: New incremented Version. + """ + + if len(self) == 0: + return self.__class__() + else: + args = self[:-1] + (self[-1] + 1,) + return self.__class__(*args) + + +class VersionBoundary(namedtuple("VersionBoundary", ("version", "operator"))): + """Normalized version range boundary.""" + + __slots__ = () + + #: Ordering of primitive operators. + #: Operators not listed here are handled specially; see __compare below. + #: Convention: Lower boundary < 0, Upper boundary > 0 + _OPERATOR_ORDER = {"<": 2, "<=": 1, ">=": -1, ">": -2} + + def __str__(self): + """Pretty-print the boundary""" + + return "{0.operator}{0.version}".format(self) + + def __compare(self, other, operator): + """Compare two boundaries with provided operator. + + Boundaries compare same as (version, operator_order) tuple. + In case the boundary operator is not listed in _OPERATOR_ORDER, + it's order is treated as 0. + + Arguments: + other (VersionBoundary): The other boundary to compare with. + operator (Callable[[VersionBoundary, VersionBoundary], bool]): + Comparison operator to delegate to. + + Returns: + bool: The result of the operator's comparison. + """ + + ORDER = self._OPERATOR_ORDER + + lhs = self.version, ORDER.get(self.operator, 0) + rhs = other.version, ORDER.get(other.operator, 0) + return operator(lhs, rhs) + + def __eq__(self, other): + return self.__compare(other, operator.eq) + + def __lt__(self, other): + return self.__compare(other, operator.lt) + + def __le__(self, other): + return self.__compare(other, operator.le) + + def __gt__(self, other): + return self.__compare(other, operator.gt) + + def __ge__(self, other): + return self.__compare(other, operator.ge) + + @property + def upper(self): + """True if self is upper boundary.""" + return self._OPERATOR_ORDER.get(self.operator, 0) > 0 + + @property + def lower(self): + """True if self is lower boundary.""" + return self._OPERATOR_ORDER.get(self.operator, 0) < 0 + + @classmethod + def equal(cls, version): + """Normalize single samp:`={version}` into equivalent x-range:: + + >>> empty = VersionBoundary.equal(Version()); tuple(map(str, empty)) + () + >>> patch = VersionBoundary.equal(Version(1, 2, 3)); tuple(map(str, patch)) + ('>=1.2.3', '<1.2.4') + >>> minor = VersionBoundary.equal(Version(1, 2)); tuple(map(str, minor)) + ('>=1.2', '<1.3') + >>> major = VersionBoundary.equal(Version(1)); tuple(map(str, major)) + ('>=1', '<2') + + See `X-Ranges `_ + for details. + + Arguments: + version (Version): The version the x-range should be equal to. + + Returns: + (VersionBoundary, VersionBoundary): + Lower and upper bound of the x-range. + (): Empty tuple in case version is empty (any version matches). + """ + + if version: + return ( + cls(version=version, operator=">="), + cls(version=version.incremented(), operator="<"), + ) + else: + return () + + @classmethod + def tilde(cls, version): + """Normalize :samp:`~{version}` into equivalent range. + + Tilde allows patch-level changes if a minor version is specified. + Allows minor-level changes if not:: + + >>> with_minor = VersionBoundary.tilde(Version(1, 2, 3)); tuple(map(str, with_minor)) + ('>=1.2.3', '<1.3') + >>> no_minor = VersionBoundary.tilde(Version(1)); tuple(map(str, no_minor)) + ('>=1', '<2') + + Arguments: + version (Version): The version to tilde-expand. + + Returns: + (VersionBoundary, VersionBoundary): + The lower and upper boundary of the tilde range. + """ + + # Fail on ``~*`` or similar nonsense specifier + assert version.major is not None, "Nonsense '~*' specifier" + + lower_boundary = cls(version=version, operator=">=") + + if version.minor is None: + upper_boundary = cls(version=Version(version.major + 1), operator="<") + else: + upper_boundary = cls( + version=Version(version.major, version.minor + 1), operator="<" + ) + + return lower_boundary, upper_boundary + + @classmethod + def caret(cls, version): + """Normalize :samp:`^{version}` into equivalent range. + + Caret allows changes that do not modify the left-most non-zero digit + in the ``(major, minor, patch)`` tuple. + In other words, this allows + patch and minor updates for versions 1.0.0 and above, + patch updates for versions 0.X >=0.1.0, + and no updates for versions 0.0.X:: + + >>> major = VersionBoundary.caret(Version(1, 2, 3)); tuple(map(str, major)) + ('>=1.2.3', '<2') + >>> minor = VersionBoundary.caret(Version(0, 2, 3)); tuple(map(str, minor)) + ('>=0.2.3', '<0.3') + >>> patch = VersionBoundary.caret(Version(0, 0, 3)); tuple(map(str, patch)) + ('>=0.0.3', '<0.0.4') + + When parsing caret ranges, a missing patch value desugars to the number 0, + but will allow flexibility within that value, + even if the major and minor versions are both 0:: + + >>> rel = VersionBoundary.caret(Version(1, 2)); tuple(map(str, rel)) + ('>=1.2', '<2') + >>> pre = VersionBoundary.caret(Version(0, 0)); tuple(map(str, pre)) + ('>=0.0', '<0.1') + + A missing minor and patch values will desugar to zero, + but also allow flexibility within those values, + even if the major version is zero:: + + >>> rel = VersionBoundary.caret(Version(1)); tuple(map(str, rel)) + ('>=1', '<2') + >>> pre = VersionBoundary.caret(Version(0)); tuple(map(str, pre)) + ('>=0', '<1') + + Arguments: + version (Version): The version to range-expand. + + Returns: + (VersionBoundary, VersionBoundary): + The lower and upper boundary of caret-range. + """ + + # Fail on ^* or similar nonsense specifier + assert len(version) != 0, "Nonsense '^*' specifier" + + lower_boundary = cls(version=version, operator=">=") + + # Increment left-most non-zero part + for idx, part in enumerate(version): + if part != 0: + upper_version = Version(*(version[:idx] + (part + 1,))) + break + else: # No non-zero found; increment last specified part + upper_version = version.incremented() + + upper_boundary = cls(version=upper_version, operator="<") + + return lower_boundary, upper_boundary + + @classmethod + def hyphen(cls, lower_version, upper_version): + """Construct hyphen range (inclusive set):: + + >>> full = VersionBoundary.hyphen(Version(1, 2, 3), Version(2, 3, 4)); tuple(map(str, full)) + ('>=1.2.3', '<=2.3.4') + + If a partial version is provided as the first version in the inclusive range, + then the missing pieces are treated as zeroes:: + + >>> part = VersionBoundary.hyphen(Version(1, 2), Version(2, 3, 4)); tuple(map(str, part)) + ('>=1.2', '<=2.3.4') + + If a partial version is provided as the second version in the inclusive range, + then all versions that start with the supplied parts of the tuple are accepted, + but nothing that would be greater than the provided tuple parts:: + + >>> part = VersionBoundary.hyphen(Version(1, 2, 3), Version(2, 3)); tuple(map(str, part)) + ('>=1.2.3', '<2.4') + >>> part = VersionBoundary.hyphen(Version(1, 2, 3), Version(2)); tuple(map(str, part)) + ('>=1.2.3', '<3') + + Arguments: + lower_version (Version): Version on the lower range boundary. + upper_version (Version): Version on the upper range boundary. + + Returns: + (VersionBoundary, VersionBoundary): + Lower and upper boundaries of the hyphen range. + """ + + lower_boundary = cls(version=lower_version, operator=">=") + + if len(upper_version) < 3: + upper_boundary = cls(version=upper_version.incremented(), operator="<") + else: + upper_boundary = cls(version=upper_version, operator="<=") + + return lower_boundary, upper_boundary + + +def parse_simple_seq(specifier_string): + """Parse all specifiers from a space-separated string:: + + >>> single = parse_simple_seq(">=1.2.3"); list(map(str, single)) + ['>=1.2.3'] + >>> multi = parse_simple_seq("~1.2.0 <1.2.5"); list(map(str, multi)) + ['>=1.2.0', '<1.3', '<1.2.5'] + + This method implements the ``simple (' ' simple)*`` part of the grammar: + https://docs.npmjs.com/misc/semver#range-grammar. + + Arguments: + specifier_string (str): Space-separated string of simple version specifiers. + + Yields: + VersionBoundary: Parsed boundaries. + """ + + # Per-operator dispatch table + # API: Callable[[Version], Iterable[VersionBoundary]] + handler = { + ">": lambda v: [VersionBoundary(version=v, operator=">")], + ">=": lambda v: [VersionBoundary(version=v, operator=">=")], + "<=": lambda v: [VersionBoundary(version=v, operator="<=")], + "<": lambda v: [VersionBoundary(version=v, operator="<")], + "=": VersionBoundary.equal, + "~": VersionBoundary.tilde, + "^": VersionBoundary.caret, + None: VersionBoundary.equal, + } + + for match in RANGE_SPECIFIER_SIMPLE.finditer(specifier_string): + operator, version_string = match.group("operator", "version") + + for boundary in handler[operator](Version.parse(version_string)): + yield boundary + + +def parse_range(range_string): + """Parse full NPM version range specification:: + + >>> empty = parse_range(""); list(map(str, empty)) + [] + >>> simple = parse_range("^1.0"); list(map(str, simple)) + ['>=1.0', '<2'] + >>> hyphen = parse_range("1.0 - 2.0"); list(map(str, hyphen)) + ['>=1.0', '<2.1'] + + This method implements the ``range`` part of the grammar: + https://docs.npmjs.com/misc/semver#range-grammar. + + Arguments: + range_string (str): The range specification to parse. + + Returns: + Iterable[VersionBoundary]: Parsed boundaries. + + Raises: + UnsupportedVersionToken: ``||`` is present in range_string. + """ + + HYPHEN = " - " + + # FIXME: rpm should be able to process OR in dependencies + # This error reporting kept for backward compatibility + if "||" in range_string: + raise UnsupportedVersionToken(range_string) + + if HYPHEN in range_string: + version_pair = map(Version.parse, range_string.split(HYPHEN, 2)) + return VersionBoundary.hyphen(*version_pair) + + elif range_string != "": + return parse_simple_seq(range_string) + + else: + return [] + + +def unify_range(boundary_iter): + """Calculate largest allowed continuous version range from a set of boundaries:: + + >>> unify_range([]) + () + >>> _ = unify_range(parse_range("=1.2.3 <2")); tuple(map(str, _)) + ('>=1.2.3', '<1.2.4') + >>> _ = unify_range(parse_range("~1.2 <1.2.5")); tuple(map(str, _)) + ('>=1.2', '<1.2.5') + + Arguments: + boundary_iter (Iterable[VersionBoundary]): The version boundaries to unify. + + Returns: + (VersionBoundary, VersionBoundary): + Lower and upper boundary of the unified range. + """ + + # Drop boundaries with empty version + boundary_iter = ( + boundary for boundary in boundary_iter if not boundary.version.empty + ) + + # Split input sequence into upper/lower boundaries + lower_list, upper_list = [], [] + for boundary in boundary_iter: + if boundary.lower: + lower_list.append(boundary) + elif boundary.upper: + upper_list.append(boundary) + else: + msg = "Unsupported boundary for unify_range: {0}".format(boundary) + raise ValueError(msg) + + # Select maximum from lower boundaries and minimum from upper boundaries + intermediate = ( + max(lower_list) if lower_list else None, + min(upper_list) if upper_list else None, + ) + + return tuple(filter(None, intermediate)) + + +def rpm_format(requirement, version_spec="*"): + """Format requirement as RPM boolean dependency:: + + >>> rpm_format("nodejs(engine)") + 'nodejs(engine)' + >>> rpm_format("npm(foo)", ">=1.0.0") + 'npm(foo) >= 1.0.0' + >>> rpm_format("npm(bar)", "~1.2") + '(npm(bar) >= 1.2 with npm(bar) < 1.3)' + + Arguments: + requirement (str): The name of the requirement. + version_spec (str): The NPM version specification for the requirement. + + Returns: + str: Formatted requirement. + """ + + TEMPLATE = "{name} {boundary.operator} {boundary.version!s}" + + try: + boundary_tuple = unify_range(parse_range(version_spec)) + + except UnsupportedVersionToken: + # FIXME: Typos and print behavior kept for backward compatibility + warning_lines = [ + "WARNING: The {requirement} dependency contains an OR (||) dependency: '{version_spec}.", + "Please manually include a versioned dependency in your spec file if necessary", + ] + warning = "\n".join(warning_lines).format( + requirement=requirement, version_spec=version_spec + ) + print(warning, end="", file=sys.stderr) + + return requirement + + formatted = [ + TEMPLATE.format(name=requirement, boundary=boundary) + for boundary in boundary_tuple + ] + + if len(formatted) > 1: + return "({0})".format(" with ".join(formatted)) + elif len(formatted) == 1: + return formatted[0] + else: + return requirement + + +def has_only_bundled_dependencies(module_dir_path): + """Determines if the module contains only bundled dependencies. + + Dependencies are considered un-bundled when they are symlinks + pointing outside the root module's tree. + + Arguments: + module_dir_path (str): + Path to the module directory (directory with ``package.json``). + + Returns: + bool: True if all dependencies are bundled, False otherwise. + """ + + module_root_path = os.path.abspath(module_dir_path) + dependency_root_path = os.path.join(module_root_path, "node_modules") + + try: + dependency_path_iter = ( + os.path.join(dependency_root_path, basename) + for basename in os.listdir(dependency_root_path) + ) + linked_dependency_iter = ( + os.path.realpath(path) + for path in dependency_path_iter + if os.path.islink(path) + ) + outside_dependency_iter = ( + path + for path in linked_dependency_iter + if not path.startswith(module_root_path) + ) + + return not any(outside_dependency_iter) + except OSError: # node_modules does not exist + return False + + +def extract_dependencies(metadata_path, optional=False): + """Extract all dependencies in RPM format from package metadata. + + Arguments: + metadata_path (str): Path to package metadata (``package.json``). + optional (bool): + If True, extract ``optionalDependencies`` + instead of ``dependencies``. + + Yields: + RPM-formatted dependencies. + + Raises: + TypeError: Invalid dependency data type. + """ + + if has_only_bundled_dependencies(os.path.dirname(metadata_path)): + return # skip + + # Read metadata + try: + with open(metadata_path, mode="r") as metadata_file: + metadata = json.load(metadata_file) + except OSError: # Invalid metadata file + return # skip + + # Report required NodeJS version with required dependencies + if not optional: + try: + yield rpm_format("nodejs(engine)", metadata["engines"]["node"]) + except KeyError: # NodeJS engine version unspecified + yield rpm_format("nodejs(engine)") + + # Report listed dependencies + kind = "optionalDependencies" if optional else "dependencies" + container = metadata.get(kind, {}) + + if isinstance(container, dict): + for name, version_spec in container.items(): + yield rpm_format(REQUIREMENT_NAME_TEMPLATE.format(name=name), version_spec) + + elif isinstance(container, list): + for name in container: + yield rpm_format(REQUIREMENT_NAME_TEMPLATE.format(name=name)) + + elif isinstance(container, str): + yield rpm_format(REQUIREMENT_NAME_TEMPLATE.format(name=name)) + + else: + raise TypeError("invalid package.json: dependencies not a valid type") + + +if __name__ == "__main__": + nested = ( + extract_dependencies(path.strip(), optional="--optional" in sys.argv) + for path in sys.stdin + ) + flat = chain.from_iterable(nested) + # Ignore parentheses around the requirements when sorting + ordered = sorted(flat, key=lambda s: s.strip("()")) + + print(*ordered, sep="\n") diff --git a/SOURCES/nodejs_native.attr b/SOURCES/nodejs_native.attr new file mode 100644 index 0000000..5e0955e --- /dev/null +++ b/SOURCES/nodejs_native.attr @@ -0,0 +1,2 @@ +%__rh_nodejs12_native_requires %{_rpmconfigdir}/rh_nodejs12_native.req +%__rh_nodejs12_native_path ^(/opt/rh/rh-nodejs12/root)?/usr/lib.*/node_modules/.*\\.node$ diff --git a/SPECS/rh-nodejs12.spec b/SPECS/rh-nodejs12.spec new file mode 100644 index 0000000..c5ee3fc --- /dev/null +++ b/SPECS/rh-nodejs12.spec @@ -0,0 +1,360 @@ +%global scl_name_prefix rh- +%global scl_name_base nodejs +%global scl_name_version 12 + +%global scl %{scl_name_prefix}%{scl_name_base}%{scl_name_version} + +%scl_package %scl +%global install_scl 1 + +%global rpm_magic_name %{lua: name, _ = string.gsub(rpm.expand("%{scl_name}"), "-", "_"); print(name)} + +# do not produce empty debuginfo package +%global debug_package %{nil} + +Summary: %scl Software Collection +Name: %scl_name +Version: 3.4 +Release: 1%{?dist} + +Source1: macros.nodejs +Source2: nodejs.attr +Source3: nodejs.prov +Source4: nodejs.req +Source5: nodejs-symlink-deps +Source6: nodejs-fixdep +Source7: nodejs_native.attr +Source8: README +Source9: LICENSE +Source10: multiver_modules +Source11: nodejs-setversion + +License: MIT + +%if 0%{?install_scl} +Requires: %{scl_prefix}nodejs +Requires: %{scl_prefix}npm +Requires: %{scl_prefix}runtime +%endif + +BuildRequires: scl-utils-build +BuildRequires: python-devel +BuildRequires: help2man + +%description +This is the main package for %scl Software Collection. + +%package runtime +Summary: Package that handles %scl Software Collection. +Requires: %{_root_bindir}/scl_source + +%description runtime +Package shipping essential scripts to work with %scl Software Collection. + +%package build +Summary: Package shipping basic build configuration +Requires: scl-utils-build + +%description build +Package shipping essential configuration macros to build %scl Software Collection. + +%package scldevel +Summary: Package shipping development files for %scl + +%description scldevel +Package shipping development files, especially usefull for development of +packages depending on %scl Software Collection. + +%prep +%setup -c -T + +# This section generates README file from a template and creates man page +# from that file, expanding RPM macros in the template file. +cat >README <<'EOF' +%{expand:%(cat %{SOURCE8})} +EOF + +# copy the license file so %%files section sees it +cp %{SOURCE9} . + +%build +# generate a helper script that will be used by help2man +cat >h2m_helper <<'EOF' +#!/bin/bash +[ "$1" == "--version" ] && echo "%{scl_name} %{version} Software Collection" || cat README +EOF + +chmod a+x h2m_helper + +# generate the man page +help2man -N --section 7 ./h2m_helper -o %{scl_name}.7 + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}%{_scl_scripts}/root +cat >> %{buildroot}%{_scl_scripts}/enable << EOF +export PATH=%{_bindir}\${PATH:+:\${PATH}} +export LD_LIBRARY_PATH=%{_libdir}\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}} +export PYTHONPATH=%{_scl_root}%{python_sitelib}\${PYTHONPATH:+:\${PYTHONPATH}} +export MANPATH=%{_mandir}:\$MANPATH +#. scl_source enable v8314 +# new nodejs bundles v8 +EOF + +# install rpm magic +install -Dpm0644 %{SOURCE1} %{buildroot}%{_root_sysconfdir}/rpm/macros.%{name} +install -Dpm0644 %{SOURCE2} %{buildroot}%{_rpmconfigdir}/fileattrs/%{rpm_magic_name}.attr +install -pm0755 %{SOURCE3} %{buildroot}%{_rpmconfigdir}/%{rpm_magic_name}.prov +install -pm0755 %{SOURCE4} %{buildroot}%{_rpmconfigdir}/%{rpm_magic_name}.req +install -pm0755 %{SOURCE5} %{buildroot}%{_rpmconfigdir}/%{name}-symlink-deps +install -pm0755 %{SOURCE6} %{buildroot}%{_rpmconfigdir}/%{name}-fixdep +install -Dpm0644 %{SOURCE7} %{buildroot}%{_rpmconfigdir}/fileattrs/%{rpm_magic_name}_native.attr +install -Dpm0644 %{SOURCE10} %{buildroot}%{_datadir}/node/multiver_modules +install -pm0755 %{SOURCE11} %{buildroot}%{_rpmconfigdir}/%{name}-symlink-deps + +cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel << EOF +%%scl_%{scl_name_base} %{scl} +%%scl_prefix_%{scl_name_base} %{scl_prefix} +EOF + +# ensure Requires are added to every native module that match the Provides from +# the nodejs build in the buildroot +cat << EOF > %{buildroot}%{_rpmconfigdir}/%{rpm_magic_name}_native.req +#!/bin/sh +echo 'nodejs12-nodejs(abi) = %nodejs_abi' +echo 'nodejs12-nodejs(v8-abi) = %v8_abi' +EOF +chmod 0755 %{buildroot}%{_rpmconfigdir}/%{rpm_magic_name}_native.req + +cat << EOF > %{buildroot}%{_rpmconfigdir}/%{name}-require.sh +#!/bin/sh +%{_rpmconfigdir}/%{name}.req $* +%{_rpmconfigdir}/find-requires $* +EOF +chmod 0755 %{buildroot}%{_rpmconfigdir}/%{name}-require.sh + +cat << EOF > %{buildroot}%{_rpmconfigdir}/%{name}-provide.sh +#!/bin/sh +%{_rpmconfigdir}/%{name}.prov $* +%{_rpmconfigdir}/find-provides $* +EOF +chmod 0755 %{buildroot}%{_rpmconfigdir}/%{name}-provide.sh + +%scl_install +# scl doesn't include this directory +mkdir -p %{buildroot}%{_scl_root}%{python_sitelib} +mkdir -p %{buildroot}%{_libdir}/pkgconfig + +# install generated man page +mkdir -p %{buildroot}%{_mandir}/man7/ +install -m 644 %{scl_name}.7 %{buildroot}%{_mandir}/man7/%{scl_name}.7 + +# own license dir (RHBZ#1420294) +mkdir -p %{buildroot}%{_datadir}/licenses/ + + +%check +# Assert that installed file attributes are named appropriately +for attr_file in %{buildroot}%{_rpmconfigdir}/fileattrs/*.attr; do + macro_name="$(basename "$attr_file"|sed -E 's|\.attr$||')" + + # Delete comments and empty lines + # Select all remaining lines that start unexpectedly + # Fail if any such line is found, cotinue otherwise + sed -E -e '/^$/d;/^#/d' "$attr_file" \ + | grep -E -v "^%%__${macro_name}_" \ + && exit 1 || : +done + +%files + +%files -f filesystem runtime +%doc README +%{!?_licensedir:%global license %%doc} +%license LICENSE +%scl_files +#%%dir %%{_scl_root}%%{python_sitelib} +%dir %{_prefix}/lib/python2.* +%dir %{_libdir}/pkgconfig +%dir %{_datadir}/licenses +%{_datadir}/node/multiver_modules +%{_mandir}/man7/%{scl_name}.* +%dir %{_datadir}/node + +%files build +%{_root_sysconfdir}/rpm/macros.%{scl}-config +%{_root_sysconfdir}/rpm/macros.%{name} +%{_rpmconfigdir}/fileattrs/%{rpm_magic_name}*.attr +%{_rpmconfigdir}/%{name}* +%{_rpmconfigdir}/%{rpm_magic_name}* + +%files scldevel +%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel + +%changelog +* Wed Aug 14 2019 Zuzana Svetlikova - 3.4-1 +- Update to v12.x +- Resolves: RHBZ#1717846 + +* Thu Sep 20 2018 Zuzana Svetlikova - 3.2-2 +- Resolves: RHBZ#1584252 +- update to fedora packaging, generate bundled provides automaticaly + +* Thu Jul 19 2018 Zuzana Svetlikova - 3.2-1 +- Update to v10 + +* Thu Jul 13 2017 Zuzana Svetlikova - 3.0-4 +- Use macro for python sitelib in doc + +* Mon Jul 03 2017 Zuzana Svetlikova - 3.0-3 +- Fix typo in symlink script + +* Tue Jun 27 2017 Zuzana Svetlikova - 3.0-2 +- Enable installing the collection + +* Mon Jun 19 2017 Zuzana Svetlikova - 3.0-1 +- SCL 3.0, nodejs v8.x + +* Thu Feb 16 2017 Zuzana Svetlikova - 2.4-5 +- Own %%{_licensedir} ((RHBZ#1420294)) + +* Fri Jan 27 2017 Zuzana Svetlikova - 2.4-4 +- Enable installing main package set + +* Wed Jan 11 2017 Zuzana Svetlikova - 2.4-2 +- RHSCL 2.4 +- Update macros +- Use zvetlik/rh-nodejs6 as base for rh-nodejs6, change sclo- for rh- + +* Wed Jan 11 2017 Zuzana Svetlikova - 2.4-1 +- Use zvetlik/rh-nodejs6 as base for rh-nodejs6 + +* Mon Sep 05 2016 Zuzana Svetlikova - 2.3-2 +- Use sclo- prefix + +* Tue Aug 30 2016 Zuzana Svetlikova - 2.3-1 +- New meta-package for Nodejs v6 + +* Thu Mar 03 2016 Zuzana Svetlikova - 2.2-5 +- Enable installing whole scl (RBZ#1314093) + +* Fri Feb 12 2016 Zuzana Svetlikova - 2.2-4 +- Add prefixes to provides and requires + +* Wed Feb 10 2016 Tomas Hrcka - 2.2-3 +- Add missing rh- prefix + +* Wed Feb 03 2016 Zuzana Svetlikova - 2.2-1 +- RHSCL 2.2 +- add %%license tag to %%files + +* Thu Jan 14 2016 Tomas Hrcka - 2.1-5 +- Include nodemon in collection +- Update packaging scripts and macros + +* Fri 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 +- disable installing of whole collection this will be enabled after devel period + +* Thu May 14 2015 Tomas Hrcka - 2.0-3 +- Red Hat Software collections 2.0 +- Own python modules directory + +* Wed Oct 08 2014 Tomas Hrcka - 1.2-29 +- Require scriptlet scl_devel from root_bindir not scl_bindir + +* Mon Oct 06 2014 Tomas Hrcka - 1.2-28 +- bump scl version + +* Mon Oct 06 2014 Tomas Hrcka - 1.2-27 +- Require scriptlet scl_devel instead of specific scl-utils version + +* 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 + +* Mon Feb 17 2014 Tomas Hrcka - 1.1-24 +- Require version of scl-utils + +* Wed Feb 12 2014 Tomas Hrcka - 1.1-23 +- Define scl_name_base and scl_name_version macros + +* Wed Feb 12 2014 Honza Horak - 1.1-22 +- Some more grammar fixes in README + Related: #1061452 + +* Tue Jan 21 2014 Tomas Hrcka - 1-21 +- Rebuilt for rhbz#1054252 + +* Thu Dec 05 2013 Tomas Hrcka - 1-20 +- install collection packages as dependencies + +* Wed Nov 27 2013 Tomas Hrcka - 1-19 +- rebuilt +- fiw v8314 dependency + +* Wed Nov 20 2013 Tomas Hrcka - 1-18 +- added dependency on v8314 scl + +* Thu Aug 15 2013 thrcka@redhat.com - 1-17 +- clean up after previous fix + +* Fri Aug 09 2013 thrcka@redhat.com - 1-16 +- RHBZ#993425 - nodejs010.req fails when !noarch + +* Mon Jun 03 2013 thrcka@redhat.com - 1-15 +- Changed licence to MIT + +* Thu May 23 2013 Tomas Hrcka - 1-14.1 +- fixed typo in MANPATH + +* Thu May 23 2013 Tomas Hrcka - 1-14 +- Changed MAN_PATH so it does not ignore man pages from host system + +* Thu May 9 2013 Stanislav Ochotnicky - 1-13 +- Remove colons forgotten in scriplets + +* Tue May 07 2013 Stanislav Ochotnicky - 1-12 +- Add runtime dependency on scl-runtime + +* Mon May 06 2013 Stanislav Ochotnicky - 1-11 +- Add pkgconfig file ownership + +* Mon May 06 2013 Stanislav Ochotnicky - 1-10 +- Workaround scl-utils not generating all directory ownerships (#956213) + +* Mon May 06 2013 Stanislav Ochotnicky - 1-9 +- Fix enable scriptlet evironment expansion (#956788) + +* Wed Apr 17 2013 Stanislav Ochotnicky - 1-8 +- Extend MANPATH env variable +- Add npm to meta package requires + +* Mon Apr 15 2013 Stanislav Ochotnicky - 1-7 +- Update macros and requires/provides generator to latest + +* Wed Apr 10 2013 Stanislav Ochotnicky - 1-6 +- Fix rpm requires/provides generator paths +- Add requires to main meta package + +* Mon Apr 08 2013 Stanislav Ochotnicky - 1-5 +- Make package architecture specific for libdir usage + +* Mon Apr 08 2013 Stanislav Ochotnicky - 1-4 +- Add rpm macros and tooling + +* Mon Apr 08 2013 Stanislav Ochotnicky - 1-3 +- Add proper scl-utils-build requires + +* Fri Apr 05 2013 Stanislav Ochotnicky - 1-2 +- Add PYTHONPATH to configuration + +* Tue Mar 26 2013 Stanislav Ochotnicky - 1-1 +- Initial version of the Node.js Software Collection