Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic nodejs eclass, + dev-nodejs package category #651

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-nodejs/configurable-http-proxy/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST configurable-http-proxy-4.5.0.tgz 25227 BLAKE2B b5a373a886949196b8968c49bea93e509379ac89ab814d66a50d19b9acac4f10771d691d834d6134f0f3bd4dde1ffe6873ef3629742de7ab6f85268128ff4f52 SHA512 8ae686f39103588a74d839b52d9b22eef444e021f9711c28dbe19a104022e9f817ddd44ba6dfe385073bca5c1789b8b89148ccbe957fc5b3308d146619c83835
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

NODEJS_MIN_VERSION="10"
NODE_MODULE_DEPEND=""
NODE_MODULE_EXTRA_FILES=""

inherit nodejs

DESCRIPTION="A simple wrapper around node-http-proxy"

LICENSE="BSD-3"
KEYWORDS="~amd64"

SLOT="0"
11 changes: 11 additions & 0 deletions dev-nodejs/configurable-http-proxy/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>[email protected]</email>
<name>Adjust Ops Team</name>
</maintainer>
<use>
<flag name="ldapauthenticator">foo</flag>
</use>
</pkgmetadata>
82 changes: 82 additions & 0 deletions eclass/nodejs.eclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: nodejs.eclass
# @MAINTAINER:
# Jannis Mast <[email protected]>
# @SUPPORTED_EAPIS: 7
# @BLURB: eclass for node.js packages
# @DESCRIPTION:
# This eclass takes care of installing node.js packages and their dependencies

case ${EAPI:-0} in
0|1|2|3|4|5|6)
die "EAPI=${EAPI} is not supported by nodejs.eclass (too old)"
;;
7|8)
;;
*)
die "EAPI=${EAPI} is not supported by nodejs.eclass"
;;
esac

EXPORT_FUNCTIONS src_unpack src_install

# @ECLASS-VARIABLE: NODE_MODULE_NAME
# @DESCRIPTION:
# The name of the node module that belongs to the package.
# Defaults to ${PN} if not set
if [ -z ${NODE_MODULE_NAME} ]; then
NODE_MODULE_NAME="${PN}"
fi
# @ECLASS_VARIABLE: NODE_DEPEND
# @DESCRIPTION:
# A list of all node.js modules that this package depends on
# Entries should have the format "name:version"
# @ECLASS_VERIABLE: NODE_BIN
# @DESCRIPTION:
# List of scripts that should be linked into /usr/bin
# Entries should have the format "name:path"
# where "name" is the destination filename in /usr/bin
# and "path" is the relative path of the script in the module's directory
# @ECLASS_VARIABLE: NODEJS_MIN_VERSION
# @DESCRIPTION:
# Minimum version of net-libs/noejs for this package (optional)

SRC_URI="http://registry.npmjs.org/${NODE_MODULE_NAME}/-/${NODE_MODULE_NAME}-${PV}.tgz"
for pkg in ${NODE_DEPEND}; do
pkg_name="${pkg%:*}"
pkg_version="${pkg#*:}"
SRC_URI="${SRC_URI} http://registry.npmjs.org/${pkg_name}/-/${pkg_name}-${pkg_version}.tgz"
done
S="${WORKDIR}/${NODE_MODULE_NAME}"

DEPEND=""
if [ -z ${NODEJS_MIN_VERSION} ]; then
RDEPEND="net-libs/nodejs"
else
RDEPEND=">=net-libs/nodejs-${NODEJS_MIN_VERSION}"
fi

nodejs_src_unpack() {
unpack "${NODE_MODULE_NAME}-${PV}.tgz"
mv "package" "${NODE_MODULE_NAME}" || die
mkdir "${NODE_MODULE_NAME}/node_modules" || die
for pkg in ${NODE_DEPEND}; do
pkg_name="${pkg%:*}"
pkg_version="${pkg#*:}"
unpack "${pkg_name}-${pkg_version}.tgz"
mv "package" "${NODE_MODULE_NAME}/node_modules/${pkg_name}" || die
done
}

nodejs_src_install() {
insinto "/usr/$(get_libdir)/node_modules/${NODE_MODULE_NAME}"
doins -r .
for i in ${NODE_BIN}; do
src="${i#*:}"
dest="${i%:*}"
dosym "${EROOT}/usr/$(get_libdir)/node_modules/${NODE_MODULE_NAME}/${src}" "/usr/bin/${dest}"
fperms +x "/usr/$(get_libdir)/node_modules/${NODE_MODULE_NAME}/${src}"
done
}
1 change: 1 addition & 0 deletions profiles/categories
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev-nodejs