Add www/node module for packaging nodejs libraries that are typically
installed via npm install. OK sthen@, Aaron Bieber (www/node MAINTAINER)
This commit is contained in:
parent
0b6e3d3de8
commit
cd034fd16a
84
www/node/node.port.mk
Normal file
84
www/node/node.port.mk
Normal file
@ -0,0 +1,84 @@
|
||||
# $OpenBSD: node.port.mk,v 1.1 2012/04/03 18:32:12 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}
|
||||
|
||||
NO_REGRESS ?= Yes
|
||||
|
||||
# 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 may 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%.js}; \
|
||||
done; \
|
||||
fi;
|
||||
|
||||
. if !target(do-build)
|
||||
do-build:
|
||||
${MODNODE_BUILD_TARGET}
|
||||
. endif
|
||||
. if !target(do-install)
|
||||
do-install:
|
||||
${MODNODE_INSTALL_TARGET}
|
||||
. endif
|
||||
.endif
|
Loading…
Reference in New Issue
Block a user