remove RPM macros, etc. now that they've migrated to nodejs-packaging

This commit is contained in:
T.C. Hollingsworth 2013-07-10 03:03:28 -07:00
parent c10bc717a2
commit 06ed0ee13f
7 changed files with 7 additions and 362 deletions

View file

@ -1,2 +0,0 @@
uglify-js
inherits

View file

@ -1,54 +0,0 @@
#!/usr/bin/python
"""Modify a dependency listed in a package.json file"""
# Copyright 2013 T.C. Hollingsworth <tchollingsworth@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
# 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 'dependencies' not in md:
md['dependencies'] = {}
if sys.argv[1] == '-r':
dep = sys.argv[2]
del md['dependencies'][dep]
else:
dep = sys.argv[1]
if len(sys.argv) > 2:
ver = sys.argv[2]
else:
ver = '*'
md['dependencies'][dep] = ver
fh = open('package.json', 'w')
data = json.JSONEncoder(indent=4).encode(md)
fh.write(data)
fh.close()

View file

@ -1,77 +0,0 @@
#!/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 <tchollingsworth@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
# 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 sys
#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('/usr/share/node/multiver_modules').read().split('\n')
if '--check' 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)]
for path in modules:
os.chdir(path)
md = json.load(open('package.json'))
if 'dependencies' in md or (check and 'devDependencies' 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:
for dep, ver in md['dependencies'].iteritems():
if dep in mvpkgs:
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):
os.symlink(target, dep)
if check and '--no-devdeps' not in sys.argv and 'devDependencies' in md:
for dep, ver in md['devDependencies'].iteritems():
if dep in mvpkgs:
depver = ver.lstrip('~').split('.')[0]
target = os.path.join(sitelib, '{0}@{1}'.format(dep, depver))
else:
target = os.path.join(sitelib, dep)
if os.path.exists(target):
os.symlink(target, dep)

View file

@ -1,3 +0,0 @@
%__nodejs_provides %{_rpmconfigdir}/nodejs.prov
%__nodejs_requires %{_rpmconfigdir}/nodejs.req
%__nodejs_path ^/usr/lib.*/node_modules/.*/package\\.json$

View file

@ -1,45 +0,0 @@
#!/usr/bin/python
"""
Automatic provides generator for Node.js libraries.
Taken from package.json. See `man npm-json` for details.
"""
# Copyright 2012 T.C. Hollingsworth <tchollingsworth@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
# 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 sys
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 'name' in metadata and not ('private' in metadata and metadata['private']):
print 'npm(' + metadata['name'] + ')',
if 'version' in metadata:
print '= ' + metadata['version']
else:
print

View file

@ -1,148 +0,0 @@
#!/usr/bin/python
"""
Automatic dependency generator for Node.js libraries.
Parsed from package.json. See `man npm-json` for details.
"""
# Copyright 2012 T.C. Hollingsworth <tchollingsworth@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
# 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.
from __future__ import unicode_literals
import json
import re
import sys
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
#until the very end
deps = []
#it's highly unlikely that we'll ever get more than one file but we handle
#this like all RPM automatic dependency generation scripts anyway
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()
#write out the node.js interpreter dependency
req = 'nodejs(engine)'
if 'engines' in metadata and 'node' in metadata['engines']:
deps += process_dep(req, metadata['engines']['node'])
else:
deps.append(req)
if 'dependencies' in metadata:
for name, version in metadata['dependencies'].iteritems():
req = 'npm(' + name + ')'
deps += process_dep(req, version)
print '\n'.join(deps)
def process_dep(req, version):
"""Converts an individual npm dependency into RPM dependencies"""
deps = []
#there's no way RPM can do anything like an OR dependency
if '||' in version:
sys.stderr.write("WARNING: The {0} dependency contains an ".format(req) +
"OR (||) dependency: '{0}.\nPlease manually include ".format(version) +
"a versioned dependency in your spec file if necessary")
deps.append(req)
elif ' - ' in version:
gt, lt = version.split(' - ')
deps.append(req + ' >= ' + gt)
deps.append(req + ' <= ' + lt)
else:
m = re.match(RE_VERSION, version)
if m:
deps += convert_dep(req, m.group(1), m.group(2))
#There could be up to two versions here (e.g.">1.0 <3.1")
if len(version) > m.end():
m = re.match(RE_VERSION, version[m.end():])
if m:
deps += convert_dep(req, m.group(1), m.group(2))
else:
deps.append(req)
return deps
def convert_dep(req, operator, version):
"""Converts one of the two possibly listed versions into an RPM dependency"""
deps = []
#any version will do
if not version or version == '*':
deps.append(req)
#any prefix but ~ makes things dead simple
elif operator in ['>', '<', '<=', '>=', '=']:
deps.append(' '.join([req, operator, version]))
#oh boy, here we go...
else:
#split the dotted portions into a list (handling trailing dots properly)
parts = [part if part else 'x' for part in version.split('.')]
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
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
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 == '~':
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
else:
deps.append('{0} = {1}'.format(req, version))
# ~1.2
else:
deps.append('{0} >= {1}'.format(req, version))
deps.append('{0} < {1}'.format(req, parts[0]+1))
return deps
if __name__ == '__main__':
main()

View file

@ -15,14 +15,10 @@ ExclusiveArch: %{ix86} x86_64 %{arm}
Source0: node-v%{version}-stripped.tar.gz Source0: node-v%{version}-stripped.tar.gz
Source100: %{name}-tarball.sh Source100: %{name}-tarball.sh
Source1: macros.nodejs # The native module Requires generator remains in the nodejs SRPM, so it knows
Source2: nodejs.attr # the nodejs and v8 versions. The remainder has migrated to the
Source3: nodejs.prov # nodejs-packaging SRPM.
Source4: nodejs.req
Source5: nodejs-symlink-deps
Source6: nodejs-fixdep
Source7: nodejs_native.attr Source7: nodejs_native.attr
Source8: multiver_modules
# Disable running gyp on bundled deps we don't use # Disable running gyp on bundled deps we don't use
Patch1: nodejs-disable-gyp-deps.patch Patch1: nodejs-disable-gyp-deps.patch
@ -83,16 +79,6 @@ BuildArch: noarch
%description docs %description docs
The API documentation for the Node.js JavaScript runtime. The API documentation for the Node.js JavaScript runtime.
%package packaging
Summary: RPM macros and utilities for Node.js packaging
Group: Development/Tools
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
%description packaging
This package contains RPM macros and other utilities useful for packaging
Node.js modules and applications in RPM-based distributions.
%prep %prep
%setup -q -n node-v%{version} %setup -q -n node-v%{version}
@ -135,18 +121,9 @@ install -Dpm0755 out/Debug/node %{buildroot}/%{_bindir}/node_g
# own the sitelib directory # own the sitelib directory
mkdir -p %{buildroot}%{_prefix}/lib/node_modules mkdir -p %{buildroot}%{_prefix}/lib/node_modules
# install rpm magic
install -Dpm0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/macros.nodejs
install -Dpm0644 %{SOURCE2} %{buildroot}%{_rpmconfigdir}/fileattrs/nodejs.attr
install -pm0755 %{SOURCE3} %{buildroot}%{_rpmconfigdir}/nodejs.prov
install -pm0755 %{SOURCE4} %{buildroot}%{_rpmconfigdir}/nodejs.req
install -pm0755 %{SOURCE5} %{buildroot}%{_rpmconfigdir}/nodejs-symlink-deps
install -pm0755 %{SOURCE6} %{buildroot}%{_rpmconfigdir}/nodejs-fixdep
install -Dpm0644 %{SOURCE7} %{buildroot}%{_rpmconfigdir}/fileattrs/nodejs_native.attr
install -Dpm0644 %{SOURCE8} %{buildroot}%{_datadir}/node/multiver_modules
# ensure Requires are added to every native module that match the Provides from # ensure Requires are added to every native module that match the Provides from
# the nodejs build in the buildroot # the nodejs build in the buildroot
install -Dpm0644 %{SOURCE7} %{buildroot}%{_rpmconfigdir}/fileattrs/nodejs_native.attr
cat << EOF > %{buildroot}%{_rpmconfigdir}/nodejs_native.req cat << EOF > %{buildroot}%{_rpmconfigdir}/nodejs_native.req
#!/bin/sh #!/bin/sh
echo 'nodejs(abi) = %nodejs_abi' echo 'nodejs(abi) = %nodejs_abi'
@ -176,6 +153,8 @@ cp -p common.gypi %{buildroot}%{_datadir}/node
%{_mandir}/man1/node.* %{_mandir}/man1/node.*
%dir %{_prefix}/lib/node_modules %dir %{_prefix}/lib/node_modules
%dir %{_datadir}/node %dir %{_datadir}/node
%{_rpmconfigdir}/fileattrs/nodejs_native.attr
%{_rpmconfigdir}/nodejs_native.req
%files devel %files devel
%{_bindir}/node_g %{_bindir}/node_g
@ -185,16 +164,11 @@ cp -p common.gypi %{buildroot}%{_datadir}/node
%files docs %files docs
%{_defaultdocdir}/%{name}-docs-%{version} %{_defaultdocdir}/%{name}-docs-%{version}
%files packaging
%{_sysconfdir}/rpm/macros.nodejs
%{_rpmconfigdir}/fileattrs/nodejs*.attr
%{_rpmconfigdir}/nodejs*
%{_datadir}/node/multiver_modules
%changelog %changelog
* Wed Jul 10 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.10.13-1 * Wed Jul 10 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.10.13-1
- new upstream release 0.10.13 - new upstream release 0.10.13
http://blog.nodejs.org/2013/07/09/node-v0-10-13-stable/ http://blog.nodejs.org/2013/07/09/node-v0-10-13-stable/
- remove RPM macros, etc. now that they've migrated to nodejs-packaging
* Wed Jun 19 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.10.12-1 * Wed Jun 19 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.10.12-1
- new upstream release 0.10.12 - new upstream release 0.10.12