use nodejs-mod_src_install in a similar way as with distutils-r1_python_install

Fix function names in nodejs-mod.eclass
remove dep files in nodejs-pack.eclass too
This commit is contained in:
Fco Javier Felix 2023-02-24 20:25:21 +01:00
parent 3050b7a8c4
commit db5cba5d7c
5 changed files with 36 additions and 34 deletions

View File

@ -3,7 +3,7 @@
EAPI=8
inherit nodejs nodejs-pack systemd tmpfiles
inherit nodejs-mod systemd tmpfiles
DESCRIPTION="A visual tool for wiring the Internet of Things."
HOMEPAGE="https://nodered.org"
@ -22,26 +22,23 @@ RDEPEND="
NODEJS_EXTRA_FILES="packages"
src_prepare() {
default
default
# TODO: remove bcrypt fail to compile
rm -rf node_modules/bcrypt || die
# TODO: remove bcrypt fail to compile
rm -rf node_modules/bcrypt || die
}
src_install() {
# Remove jsdoc-nr-template, prune use git to get the version
rm -rf node_modules/jsdoc-nr-template/ || die
sed -i -e '/jsdoc-nr-template/d' package.json || die
# Remove jsdoc-nr-template, prune use git to get the version
rm -rf node_modules/jsdoc-nr-template/ || die
sed -i -e '/jsdoc-nr-template/d' package.json || die
nodejs_docs
nodejs-mod_src_install
enpm_clean
enpm_install
dotmpfiles "${FILESDIR}"/node-red.conf
dotmpfiles "${FILESDIR}"/node-red.conf
doinitd "${FILESDIR}"/${PN}
systemd_dounit "${FILESDIR}/${PN}.service"
doinitd "${FILESDIR}"/${PN}
systemd_dounit "${FILESDIR}/${PN}.service"
}
pkg_postinst() {

View File

@ -12,7 +12,7 @@ else
https://raw.githubusercontent.com/inode64/inode64-overlay/main/dist/${P}-node_modules.tar.xz"
fi
inherit nodejs nodejs-pack systemd tmpfiles
inherit nodejs-mod systemd tmpfiles
DESCRIPTION="It bridges events and allows you to control your Zigbee devices via MQTT"
HOMEPAGE="https://www.zigbee2mqtt.io/"
@ -38,8 +38,7 @@ src_install() {
echo -e " pan_id: GENERATE" >>data/configuration.yaml
echo -e " log_directory: /var/log/${PN}" >>data/configuration.yaml
enpm_clean
enpm_install
nodejs-mod_src_install
keepdir /var/log/${PN}

View File

@ -34,23 +34,21 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ -z ${_NODEJS-MODE_ECLASS} ]]; then
_NODEJS-MODE_ECLASS=1
if [[ -z ${_NODEJS-MOD_ECLASS} ]]; then
_NODEJS-MOD_ECLASS=1
inherit nodejs
if has nodejs-pack ${INHERITED}; then
eerror "nodejs-mod and nodejs-pack eclass are incompatible"
eerror "nodejs-mod and nodejs-pack eclass are incompatible"
fi
EXPORT_FUNCTIONS src_compile src_install src_prepare src_test
RDEPEND+=" net-libs/nodejs:="
# @FUNCTION: nodejs-pack_src_prepare
# @FUNCTION: nodejs-mod_src_prepare
# @DESCRIPTION:
# Nodejs preparation phase
nodejs-pack_src_prepare() {
nodejs-mod_src_prepare() {
debug-print-function "${FUNCNAME}" "${@}"
if [[ ! -e package.json ]]; then
@ -62,10 +60,10 @@ nodejs-pack_src_prepare() {
default_src_prepare
}
# @FUNCTION: nodejs-pack_src_compile
# @FUNCTION: nodejs-mod_src_compile
# @DESCRIPTION:
# General function for compiling a nodejs module
nodejs-pack_src_compile() {
nodejs-mod_src_compile() {
debug-print-function "${FUNCNAME}" "${@}"
if [[ -d node_modules ]]; then
@ -84,10 +82,10 @@ nodejs-pack_src_compile() {
fi
}
# @FUNCTION: nodejs-pack_src_test
# @FUNCTION: nodejs-mod_src_test
# @DESCRIPTION:
# General function for testing a nodejs module
nodejs-pack_src_test() {
nodejs-mod_src_test() {
debug-print-function "${FUNCNAME}" "${@}"
if nodejs_has_test; then
@ -98,7 +96,7 @@ nodejs-pack_src_test() {
# @FUNCTION: nodejs_src_install
# @DESCRIPTION:
# Function for installing the package
nodejs-pack_src_install() {
nodejs-mod_src_install() {
debug-print-function "${FUNCNAME}" "${@}"
nodejs_docs
@ -106,4 +104,7 @@ nodejs-pack_src_install() {
enpm_clean
enpm_install
}
fi
EXPORT_FUNCTIONS src_prepare src_compile src_test src_install

View File

@ -18,7 +18,6 @@
# https://github.com/gentoo-mirror/lanodanOverlay/blob/master/eclass/nodejs.eclass
# https://github.com/Tatsh/tatsh-overlay/blob/master/eclass/yarn.eclass
case ${EAPI} in
7 | 8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
@ -30,7 +29,7 @@ _NODEJS_PACK_ECLASS=1
inherit nodejs
if has nodejs-mod ${INHERITED}; then
eerror "nodejs-mod and nodejs-pack eclass are incompatible"
eerror "nodejs-mod and nodejs-pack eclass are incompatible"
fi
RDEPEND+=" net-libs/nodejs"
@ -38,15 +37,13 @@ RDEPEND+=" net-libs/nodejs"
# Upstream does not support stripping go packages
RESTRICT="test strip"
EXPORT_FUNCTIONS src_compile src_install src_prepare
# @FUNCTION: nodejs-pack_src_prepare
# @DESCRIPTION:
# Nodejs preparation phase
nodejs-pack_src_prepare() {
debug-print-function "${FUNCNAME}" "${@}"
if ! nodejs_has_package && ! test -e package.json ; then
if ! nodejs_has_package && ! test -e package.json; then
eerror "Unable to locate package.json"
eerror "Consider not inheriting the nodejs-pack eclass."
die "FATAL: Unable to find package.json"
@ -77,5 +74,12 @@ nodejs-pack_src_install() {
enpm --prefix "${ED}"/usr --global \
install \
"$(nodejs_package)-$(nodejs_version).tgz" || die "install failed"
pushd "${ED}/$(_NODEJS_MODULES)" >/dev/null || die
nodejs_remove_dev
popd >/dev/null || die
}
fi
EXPORT_FUNCTIONS src_prepare src_compile src_install

View File

@ -301,4 +301,5 @@ enpm_install() {
fi
done
}
fi