From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 894C91381F3 for ; Wed, 10 Jul 2013 12:28:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4D37FE0964; Wed, 10 Jul 2013 12:28:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C7C7CE0964 for ; Wed, 10 Jul 2013 12:28:00 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7A6D833E725 for ; Wed, 10 Jul 2013 12:27:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 0DFB8E468F for ; Wed, 10 Jul 2013 12:27:57 +0000 (UTC) From: "Jesus Rivero" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jesus Rivero" Message-ID: <1373459310.61edb1e2b0cf09ea22cd19b6defb10dcb1ea0432.neurogeek@gentoo> Subject: [gentoo-commits] dev/neurogeek:master commit in: eclass/ X-VCS-Repository: dev/neurogeek X-VCS-Files: eclass/npm.eclass X-VCS-Directories: eclass/ X-VCS-Committer: neurogeek X-VCS-Committer-Name: Jesus Rivero X-VCS-Revision: 61edb1e2b0cf09ea22cd19b6defb10dcb1ea0432 X-VCS-Branch: master Date: Wed, 10 Jul 2013 12:27:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: ca5fae66-ee35-4372-8e03-98094767662a X-Archives-Hash: 421d441fd2ac1a4e43d0142c61579b4b commit: 61edb1e2b0cf09ea22cd19b6defb10dcb1ea0432 Author: Jesus Rivero gmail com> AuthorDate: Wed Jul 10 12:28:30 2013 +0000 Commit: Jesus Rivero gentoo org> CommitDate: Wed Jul 10 12:28:30 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/neurogeek.git;a=commit;h=61edb1e2 Adding npm.eclass --- eclass/npm.eclass | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/eclass/npm.eclass b/eclass/npm.eclass new file mode 100644 index 0000000..d77b9ba --- /dev/null +++ b/eclass/npm.eclass @@ -0,0 +1,103 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: npm.eclass +# @MAINTAINER: +# Jesus Rivero +# @BLURB: Eclass for NodeJS packages available through the npm registry. +# @DESCRIPTION: +# This eclass contains various functions that may be useful when +# dealing with packages from the npm registry, for NodeJS. +# Requires EAPI=2 or later. + +case ${EAPI} in + 2|3|4|5) : ;; + *) die "npm.eclass: unsupported EAPI=${EAPI:-0}" ;; +esac + +inherit multilib + +# @ECLASS-VARIABLE: NPM_MODULE +# @DESCRIPTION: +# Name of the resulting NodeJS/npm module. +# The Default value for NPM_MODULE is ${PN} +# +# Example: NPM_MODULE="${MY_PN}" +NPM_MODULE="${PN}" + +# @ECLASS-VARIABLE: NPM_FILES +# @INTERNAL +# @DESCRIPTION: +# Files and directories that usually come in a standard +# NodeJS/npm module. +NPM_FILES="lib package.json index.js" + +# @ECLASS-VARIABLE: NPM_DOCS +# @INTERNAL +# @DESCRIPTION: +# Document files that usually come in a standard +# NodeJS/npm module. +NPM_DOCS="README* LICENSE HISTORY*" + +# @ECLASS-VARIABLE: NPM_EXTRA_FILES +# @DESCRIPTION: +# If additional dist files are present in the NodeJS/npm module +# that are not listed in NPM_FILES, then this is the place to put them in. +# Can be either files, or directories. +# Example: NPM_EXTRA_FILES="rigger.js modules" + +# @ECLASS-VARIABLE: NPM_EXTRA_DOCS +# @DESCRIPTION: +# Variable for additional document files that are not listed +# in NPM_DOCS +# Example: NPM_EXTRA_DOCS="docs index.html" + +HOMEPAGE="https://www.npmjs.org/package/${PN}" +SRC_URI="http://registry.npmjs.org/${PN}/-/${P}.tgz" + +# @FUNCTION: npm-src_unpack +# @DESCRIPTION: +# Default src_unpack function for NodeJS/npm packages. This funtions +# unpacks the source code, then renames the 'package' dir to $S + +npm_src_unpack() { + unpack "${A}" + mv "${WORKDIR}/package" ${S} +} + +# @FUNCTION: npm-src_compile +# @DESCRIPTION: +# This function does nothing. + +npm_src_compile() { + true +} + +# @FUNCTION: npm-src_install +# @DESCRIPTION: +# This function installs the NodeJS/npm module to an appropriate location, +# also taking care of NPM_FILES, NPM_EXTRA_FILES, NPM_DOCS and NPM_EXTRA_DOCS + +npm_src_install() { + local node_modules="${D}/usr/$(get_libdir)/node_modules/${NPM_MODULE}" + mkdir -p ${node_modules} || die "Could not create DEST folder" + + # These are basically the 'standard' files in an npm package + # We'll handle additional files in NPM_EXTRA_FILES + for f in "${NPM_FILES} ${NPM_EXTRA_FILES}" + do + if [[ -e "${S}/$f" ]]; then + cp -r "${S}/$f" ${node_modules} + fi + done + + for f in "${NPM_DOCS} ${NPM_EXTRA_DOCS}" + do + if [[ -e "${S}/$f" ]]; then + dodoc -r "${S}/$f" + fi + done +} + +EXPORT_FUNCTIONS src_unpack src_compile src_install