This is a module for nodejs ports that would otherwise use npm install to install. In addition to the module file itself, this also includes:
* patch to network.conf.template to add master site for npm registry * switch lang/coffeescript over to use node module * patch to port-modules.5 Attached are also 4 new node ports: * bcrypt: bcrypt hashing * fibers: coroutine support to avoid nested callback hell * pg: postgresql database driver * generic-pool: required by pg Tested on amd64 and i386. OKs? Jeremy This patch applies in ports: Index: www/node/node.port.mk =================================================================== RCS file: www/node/node.port.mk diff -N www/node/node.port.mk --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ www/node/node.port.mk 10 Feb 2012 17:29:06 -0000 @@ -0,0 +1,82 @@ +# $OpenBSD: ruby.port.mk,v 1.50 2011/12/09 21:41:43 jeremy Exp $ + +# node module + +CATEGORIES += www/node + +BUILD_DEPENDS += www/node +RUN_DEPENDS += www/node + +.if ${CONFIGURE_STYLE:L:Mnpm} +. if ${CONFIGURE_STYLE:L:Mext} +# Node C++ extensions are specific to an arch and are loaded as +# shared libraries, so set SHARED_ONLY and make sure PKG_ARCH=* is +# not set. +. if defined(PKG_ARCH) && ${PKG_ARCH} == * +ERRORS += "Fatal: Should not have PKG_ARCH=* when compiling extensions" +. endif +SHARED_ONLY = Yes +# All node extensions appear to link against these two libraries +WANTLIB += m stdc++ +. else +# Node libraries that don't contain C++ extensions should run on +# any arch. +PKG_ARCH ?= * +. endif + +# The npm package repository separates packages in different directories, +# so to eliminate duplication, you need to set the NPM_NAME and VERSION +# variables so it can use the correct DISTNAME and MASTER_SITES. The +# NPM_NAME is required anyway during the install tasks, so it may as +# well be used here. +DISTNAME ?= ${NPM_NAME}-${VERSION} +MASTER_SITES ?= ${MASTER_SITE_NPM}${NPM_NAME}/-/ +EXTRACT_SUFX ?= .tgz +PKGNAME ?= node-${DISTNAME} + +MODNODE_BIN_NPM = ${LOCALBASE}/bin/npm +NPM_INSTALL_FILE = ${WRKDIR}/${DISTNAME}.tgz +NPM_TAR_DIR = package +WRKDIST = ${WRKDIR}/${NPM_TAR_DIR} + +# List of npm package names to depend on. Only necessary +# if the current port depends on other node ports. +MODNODE_DEPENDS ?= + +# Link all dependencies first so that npm will install without complaining. +# Then rebuild the distfile, since it make contain local patches. +# Then use npm install to install the package to a local node_modules dir. +MODNODE_BUILD_TARGET = \ + cd ${WRKDIST} && find . -type f -name '*.orig' -print0 | \ + xargs -r0 rm; \ + for dep in ${MODNODE_DEPENDS}; do \ + cd ${WRKDIR} && ${MODNODE_BIN_NPM} link $$dep; \ + done; \ + cd ${WRKDIR} && tar -zcf ${NPM_INSTALL_FILE} ${NPM_TAR_DIR}; \ + cd ${WRKDIR} && HOME=${WRKDIR} ${MODNODE_BIN_NPM} install \ + ${NPM_INSTALL_FILE} + +# Move just this package from the local node_modules dir to the global +# node_modules dir. If there are any binaries in the package, create +# symlinks in the default PATH that point to them. +MODNODE_INSTALL_TARGET = \ + mkdir ${PREFIX}/lib/node_modules; \ + mv ${WRKDIR}/node_modules/${NPM_NAME} ${PREFIX}/lib/node_modules; \ + chown -R ${SHAREOWN}:${SHAREGRP} ${PREFIX}/lib/node_modules; \ + if [ -d ${PREFIX}/lib/node_modules/${NPM_NAME}/bin ]; then \ + cd ${PREFIX}/lib/node_modules/${NPM_NAME}/bin && \ + for bin in *; do \ + ln -s ${TRUEPREFIX}/lib/node_modules/${NPM_NAME}/bin/$$bin \ + ${PREFIX}/bin/$$bin; \ + done; \ + fi; + +. if !target(do-build) +do-build: + ${MODNODE_BUILD_TARGET} +. endif +. if !target(do-install) +do-install: + ${MODNODE_INSTALL_TARGET} +. endif +.endif Index: infrastructure/templates/network.conf.template =================================================================== RCS file: /cvs/ports/infrastructure/templates/network.conf.template,v retrieving revision 1.170 diff -u -p -r1.170 network.conf.template --- infrastructure/templates/network.conf.template 11 Nov 2011 16:58:09 -0000 1.170 +++ infrastructure/templates/network.conf.template 1 Feb 2012 18:58:24 -0000 @@ -272,8 +272,11 @@ MASTER_SITE_MYSQL+= \ MASTER_SITE_PYPI += \ http://pypi.python.org/packages/source/ -MASTER_SITE_RUBYGEMS+= \ +MASTER_SITE_RUBYGEMS += \ http://rubygems.org/downloads/ + +MASTER_SITE_NPM += \ + https://registry.npmjs.org/ MASTER_SITE_ISC += \ http://ftp.isc.org/isc/ \ Index: lang/coffeescript/Makefile =================================================================== RCS file: /cvs/ports/lang/coffeescript/Makefile,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Makefile --- lang/coffeescript/Makefile 19 Dec 2011 22:21:47 -0000 1.1.1.1 +++ lang/coffeescript/Makefile 10 Feb 2012 16:48:32 -0000 @@ -2,8 +2,11 @@ COMMENT = little language that compiles to javascript -DISTNAME = coffeescript-1.2.0 +VERSION = 1.2.0 +NPM_NAME = coffee-script +PKGNAME = coffeescript-${VERSION} CATEGORIES = lang +REVISION = 0 HOMEPAGE = http://coffeescript.org @@ -13,24 +16,8 @@ PERMIT_PACKAGE_FTP = Yes PERMIT_DISTFILES_CDROM = Yes PERMIT_DISTFILES_FTP = Yes -MASTER_SITES = http://distfiles.nl/ +MODULES = www/node -BUILD_DEPENDS = ${RUN_DEPENDS} -RUN_DEPENDS = www/node - -GIT_SHA1 = 9abe614 -WRKDIST = ${WRKDIR}/jashkenas-coffee-script-${GIT_SHA1} - -NO_BUILD = Yes - -pre-configure: - ${SUBST_CMD} ${WRKSRC}/Cakefile - -do-install: - cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} HOME=${WRKSRC} \ - ${SUDO} bin/cake --prefix ${PREFIX} install - -do-regress: - cd ${WRKSRC} && bin/cake test +CONFIGURE_STYLE = npm .include <bsd.port.mk> Index: lang/coffeescript/distinfo =================================================================== RCS file: /cvs/ports/lang/coffeescript/distinfo,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 distinfo --- lang/coffeescript/distinfo 19 Dec 2011 22:21:47 -0000 1.1.1.1 +++ lang/coffeescript/distinfo 10 Feb 2012 16:48:38 -0000 @@ -1,5 +1,5 @@ -MD5 (coffeescript-1.2.0.tar.gz) = Xfw+4hIU8bfobAU19ThqNQ== -RMD160 (coffeescript-1.2.0.tar.gz) = YnbH/znZSUxB+DIL/BrLveJs51k= -SHA1 (coffeescript-1.2.0.tar.gz) = iKUwy6jLaTzQZ/k3aFIJOFM31vQ= -SHA256 (coffeescript-1.2.0.tar.gz) = 9QJxODduCW+//O8G93chO4o72FKvshD/LH0e6P/bCeA= -SIZE (coffeescript-1.2.0.tar.gz) = 452704 +MD5 (coffee-script-1.2.0.tgz) = wo3P9YiEGZsFnZ3k+oLARA== +RMD160 (coffee-script-1.2.0.tgz) = 69HVJuIn31Wg6cJChJzHeK6mcMM= +SHA1 (coffee-script-1.2.0.tgz) = teYeVfHKjEqeuH1TqgZX6kMSW5E= +SHA256 (coffee-script-1.2.0.tgz) = PxvKYTAgMwLpE7Tg19lVzfXdo0Sb6GQ+ge16W5N9e8Q= +SIZE (coffee-script-1.2.0.tgz) = 71680 Index: lang/coffeescript/patches/patch-Cakefile =================================================================== RCS file: lang/coffeescript/patches/patch-Cakefile diff -N lang/coffeescript/patches/patch-Cakefile --- lang/coffeescript/patches/patch-Cakefile 19 Dec 2011 22:21:47 -0000 1.1.1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,23 +0,0 @@ -$OpenBSD: patch-Cakefile,v 1.1.1.1 2011/12/19 22:21:47 jeremy Exp $ ---- Cakefile.orig Tue Nov 8 15:01:45 2011 -+++ Cakefile Tue Dec 13 14:52:16 2011 -@@ -50,17 +50,12 @@ task 'install', 'install CoffeeScript into /usr/local - base = options.prefix or '/usr/local' - lib = "#{base}/lib/coffee-script" - bin = "#{base}/bin" -- node = "~/.node_libraries/coffee-script" - console.log "Installing CoffeeScript to #{lib}" -- console.log "Linking to #{node}" -- console.log "Linking 'coffee' to #{bin}/coffee" - exec([ - "mkdir -p #{lib} #{bin}" - "cp -rf bin lib LICENSE README package.json src #{lib}" -- "ln -sfn #{lib}/bin/coffee #{bin}/coffee" -- "ln -sfn #{lib}/bin/cake #{bin}/cake" -- "mkdir -p ~/.node_libraries" -- "ln -sfn #{lib}/lib/coffee-script #{node}" -+ "ln -sfn ${TRUEPREFIX}/lib/coffee-script/bin/coffee #{bin}/coffee" -+ "ln -sfn ${TRUEPREFIX}/lib/coffee-script/bin/cake #{bin}/cake" - ].join(' && '), (err, stdout, stderr) -> - if err then console.log stderr.trim() else log 'done', green - ) Index: lang/coffeescript/pkg/PLIST =================================================================== RCS file: /cvs/ports/lang/coffeescript/pkg/PLIST,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 PLIST --- lang/coffeescript/pkg/PLIST 19 Dec 2011 22:21:47 -0000 1.1.1.1 +++ lang/coffeescript/pkg/PLIST 10 Feb 2012 16:56:39 -0000 @@ -1,40 +1,30 @@ @comment $OpenBSD: PLIST,v 1.1.1.1 2011/12/19 22:21:47 jeremy Exp $ bin/cake bin/coffee -lib/coffee-script/ -lib/coffee-script/LICENSE -lib/coffee-script/README -lib/coffee-script/bin/ -lib/coffee-script/bin/cake -lib/coffee-script/bin/coffee -lib/coffee-script/lib/ -lib/coffee-script/lib/coffee-script/ -lib/coffee-script/lib/coffee-script/browser.js -lib/coffee-script/lib/coffee-script/cake.js -lib/coffee-script/lib/coffee-script/coffee-script.js -lib/coffee-script/lib/coffee-script/command.js -lib/coffee-script/lib/coffee-script/grammar.js -lib/coffee-script/lib/coffee-script/helpers.js -lib/coffee-script/lib/coffee-script/index.js -lib/coffee-script/lib/coffee-script/lexer.js -lib/coffee-script/lib/coffee-script/nodes.js -lib/coffee-script/lib/coffee-script/optparse.js -lib/coffee-script/lib/coffee-script/parser.js -lib/coffee-script/lib/coffee-script/repl.js -lib/coffee-script/lib/coffee-script/rewriter.js -lib/coffee-script/lib/coffee-script/scope.js -lib/coffee-script/package.json -lib/coffee-script/src/ -lib/coffee-script/src/browser.coffee -lib/coffee-script/src/cake.coffee -lib/coffee-script/src/coffee-script.coffee -lib/coffee-script/src/command.coffee -lib/coffee-script/src/grammar.coffee -lib/coffee-script/src/helpers.coffee -lib/coffee-script/src/index.coffee -lib/coffee-script/src/lexer.coffee -lib/coffee-script/src/nodes.coffee -lib/coffee-script/src/optparse.coffee -lib/coffee-script/src/repl.coffee -lib/coffee-script/src/rewriter.coffee -lib/coffee-script/src/scope.coffee +lib/node_modules/coffee-script/ +lib/node_modules/coffee-script/.npmignore +lib/node_modules/coffee-script/LICENSE +lib/node_modules/coffee-script/README +lib/node_modules/coffee-script/Rakefile +lib/node_modules/coffee-script/bin/ +lib/node_modules/coffee-script/bin/cake +lib/node_modules/coffee-script/bin/coffee +lib/node_modules/coffee-script/extras/ +lib/node_modules/coffee-script/extras/jsl.conf +lib/node_modules/coffee-script/lib/ +lib/node_modules/coffee-script/lib/coffee-script/ +lib/node_modules/coffee-script/lib/coffee-script/browser.js +lib/node_modules/coffee-script/lib/coffee-script/cake.js +lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js +lib/node_modules/coffee-script/lib/coffee-script/command.js +lib/node_modules/coffee-script/lib/coffee-script/grammar.js +lib/node_modules/coffee-script/lib/coffee-script/helpers.js +lib/node_modules/coffee-script/lib/coffee-script/index.js +lib/node_modules/coffee-script/lib/coffee-script/lexer.js +lib/node_modules/coffee-script/lib/coffee-script/nodes.js +lib/node_modules/coffee-script/lib/coffee-script/optparse.js +lib/node_modules/coffee-script/lib/coffee-script/parser.js +lib/node_modules/coffee-script/lib/coffee-script/repl.js +lib/node_modules/coffee-script/lib/coffee-script/rewriter.js +lib/node_modules/coffee-script/lib/coffee-script/scope.js +lib/node_modules/coffee-script/package.json This patch applies in src/share/man/man5: Index: port-modules.5 =================================================================== RCS file: /cvs/src/share/man/man5/port-modules.5,v retrieving revision 1.119 diff -u -p -r1.119 port-modules.5 --- port-modules.5 14 Dec 2011 18:32:46 -0000 1.119 +++ port-modules.5 10 Feb 2012 17:52:24 -0000 @@ -850,6 +850,42 @@ contains the list of dirs where .Ev AUTOCONF will be run during .Ar pre-configure . +.It www/node +Adds common dependencies to +.Ev RUN_DEPENDS +and +.Ev BUILD_DEPENDS . +Recognizes two additional types of +.Ev CONFIGURE_STYLE Ns s , +"npm" and "npm ext". "npm ext" should be used for npm packages that +contain C++ extensions which need to be compiled. "npm" should be used +for other npm packages. One of these these two +.Ev CONFIGURE_STYLE Ns s +should be used or the module doesn't affect anything except +.Ev RUN_DEPENDS +and +.Ev BUILD_DEPENDS . +Requires +.Ev NPM_NAME +to be set to the name of the npm package. +Uses +.Ev NPM_NAME +and +.Ev VERSION +to set +.Ev DISTNAME , +and +.Ev PKGNAME , +and +.Ev MASTER_SITES . +If the npm package depends on other npm packages, the npm package names it +depends on should be listed in +.Ev MODNODE_DEPENDS . +Adds default do_build and do_install tasks, and you can reference the default +implementations via +.Ev MODNODE_BUILD_TARGET +and +.Ev MODNODE_INSTALL_TARGET . .It www/pear Used for PHP PEAR ports. Sets default
node-bcrypt.tar.gz
Description: application/tar-gz
node-fibers.tar.gz
Description: application/tar-gz
node-generic-pool.tar.gz
Description: application/tar-gz
node-pg.tar.gz
Description: application/tar-gz