Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37854878
en ru br
ALT Linux repositórios
S:0.20.7-alt2

Group :: Desenvolvimento/Outros
RPM: rpm-build-nodejs

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

rpm-build-nodejs-0.6/000075500000000000000000000000001221654671200145365ustar00rootroot00000000000000rpm-build-nodejs-0.6/LICENSE000064400000000000000000000021041221654671200155400ustar00rootroot00000000000000Copyright 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.
rpm-build-nodejs-0.6/macros.nodejs000064400000000000000000000023461221654671200172330ustar00rootroot00000000000000# 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}/nodejs-fixdep

# 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}
rpm-build-nodejs-0.6/macros.nodejs-tap000064400000000000000000000002211221654671200200030ustar00rootroot00000000000000# Macros to call tap in %%check
# in case we want to pass options to tap later on, e.g. to increase the timeout
%__tap /usr/bin/tap
%tap %{__tap}rpm-build-nodejs-0.6/multiver_modules000064400000000000000000000000221221654671200200520ustar00rootroot00000000000000uglify-js
inheritsrpm-build-nodejs-0.6/nodejs-fixdep000075500000000000000000000033361221654671200172300ustar00rootroot00000000000000#!/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()
rpm-build-nodejs-0.6/nodejs-symlink-deps000075500000000000000000000065461221654671200203760ustar00rootroot00000000000000#!/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


def symlink_deps(deps, check):
if isinstance(deps, dict):
for dep, ver in deps.iteritems():
if dep in mvpkgs and ver != '' and ver != '*':
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)

elif isinstance(deps, list):
for dep in deps:
target = os.path.join(sitelib, dep)
if not check or os.path.exists(target):
os.symlink(target, dep)

elif isinstance(deps, basestring):
target = os.path.join(sitelib, deps)
if not check or os.path.exists(target):
os.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]

#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:
symlink_deps(md['dependencies'], check)

if check and '--no-devdeps' not in sys.argv and 'devDependencies' in md:
symlink_deps(md['devDependencies'], check)
rpm-build-nodejs-0.6/nodejs.prov000075500000000000000000000033171221654671200167370ustar00rootroot00000000000000#!/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
rpm-build-nodejs-0.6/nodejs.prov.files000075500000000000000000000002711221654671200200340ustar00rootroot00000000000000#!/bin/sh -efu
while IFS=$'\t' read -r f t; do
if [ -z "${f##${RPM_BUILD_ROOT-}/usr/lib*/node_modules/*}" ]; then
case $f in
*/package.json)
echo "$f" ;;
esac
fi
done
rpm-build-nodejs-0.6/nodejs.req000075500000000000000000000136351221654671200165440ustar00rootroot00000000000000#!/usr/bin/python

"""
Automatic dependency generator for Node.js libraries.

Parsed from package.json. See `man npm-json` for details.
"""

# 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.

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 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 = 'npm(' + name + ')'
deps += process_dep(req, version)
elif isinstance(metadata['dependencies'], list):
for name in metadata['dependencies']:
req = 'npm(' + name + ')'
deps.append(req)
elif isinstance(metadata['dependencies'], basestring):
req = 'npm(' + metadata['dependencies'] + ')'
deps.append(req)
else:
raise TypeError('invalid package.json: dependencies not a valid type')

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()
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009