Skip to content

Instantly share code, notes, and snippets.

@orsonteodoro
Last active January 14, 2018 21:32
Show Gist options
  • Save orsonteodoro/8d11c66573df1b99870be40236481a0f to your computer and use it in GitHub Desktop.
Save orsonteodoro/8d11c66573df1b99870be40236481a0f to your computer and use it in GitHub Desktop.
Notes on packaging dev-nodejs packages on Gentoo Linux
License: Public Domain
Author: Orson Teodoro
Use this template below:
-----CUT HERE------
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
NODEJS_MIN_VERSION="0.4.0"
NODE_MODULE_DEPEND=""
NODE_MODULE_EXTRA_FILES=""
inherit node-module
DESCRIPTION=""
LICENSE=""
KEYWORDS="~amd64 ~x86"
DOCS=( )
-----CUT HERE------
1. Make a folder in dev-nodejs with the package name
2. Open the text editor with package-versionnumber.ebuild
3. Paste the ebuild template above.
4. Save it
5. Check if the package exist in jm-overlay first and also the oiledmachine-overlay. To do that, use:
find /var/lib/layman/jm-overlay -name "*PACKAGENAMEHERE*" | sort
6. If it exists, you can delete the template ebuild.
7. Do a:
ebuild package-versionnumber.ebuild digest clean unpack
8. Then inspect the contents of the package.json file (/var/tmp/portage/dev-nodejs/programname-programversion/work/package/*json)
and the ${WORKDIR}/package (i.e. /var/tmp/portage/dev-nodejs/programname-programver/work/package/) folder. You will extract
the description, the license [also inspect the LICENSE file inside because their may be a contradiction between the licence in
the package.json and the contents of the LICENSE FILE], dependencies, nodejs minimum version required for the package. You will
also extra files for NODE_MODULE_EXTRA_FILES
9. Fill in NODEJS_MIN_VERSION, NODE_MODULE_DEPEND, NODE_MODULE_EXTRA_FILES, DESCRIPTION, DOCS and delete the ones that are blank
or missing information. Some packages will not say what version of nodejs is required so delete NODEJS_MIN_VERSION. The files
mentioned automatically [see reference 1 below] added are the index.js, <packagename>.js, lib but not bin, dist, ... so they
need to be explicitly added. For NODE_MODULE_DEPEND, it should be package:versionnumber seperated by spaces.
To understand the package.json versioning scheme see [3].
10. You will do a breath first traversal for searching for more dependencies. Use:
find . -name *.ebuild | sort; grep -r -e "NODE_MODULE_DEPEND" ./
within the dev-nodejs to find the remaining ebuilds that need to be created.
11. Add more dependencies
12. Also check the test dependencies as well by:
find . -name *.ebuild | sort; grep -r -e "NODE_MODULE_TEST_DEPEND" ./
13. Use emerge -pv ROOT_PACKAGE_NAME to get the missing dependencies for the main packages.
For packages containing dotted names which emerge doesn't like see [2] below.
To create the root nodejs package see see app-editors/atom or dev-util/mocha::jm-overlay.
To add binaries use install_node_module_binary after the call to node-module_src_install. See dev-util/mocha::jm-overlay for
details. Check the package.json if it list the "bin" field for single binaries. Also see the "directories.bin" field to
symlink all the binaries in that directory. For details see [5] and [6] below. jm-overlay uses system wide /usr/bin.
oiledmachine-overlay currently uses /usr/local/bin (this can change later) to prevent name clashes and is slotted to allow
multiple versions.
For circular dependencies see [7] below.
-
References/Links/Notes:
For variable names used in the node-module eclass
[1] https://github.com/Jannis234/jm-overlay/blob/master/eclass/node-module.eclass
[2] Some packages contain periods in the name of the package. In the ebuild name, you will need to convert the periods into
hyphens. The dependencies with converted hyphens will be referenced by the RDEPEND in the parent ebuild. In the parent
ebuild, you need to put the dottedname:version as an argument to install_node_module_depend in src_install() to properly
generate the folder name. You also need to put the dotted name as NODE_MODULE_NAME before inherit node-module is called in the
child. Don't forget to call node-module_src_install before you call install_node_module_depend in the parent. See the
lodash-assign-4.0.9.ebuild and it's children for details how to properly do it.
[3] https://docs.npmjs.com/files/package.json#dependencies
[4] Some packages contain a Makefile which runs automated tests or attempts to update data but already contains a snapshot of
it when released. You can disable it by adding this boilerplate code:
src_compile() {
true
}
[5] https://docs.npmjs.com/files/package.json#bin
[6] https://docs.npmjs.com/files/package.json#directoriesbin
[7] If a package contains a circular dependency you must put the package in PDEPEND and manually create a symlink in
src_install. See dev-nodejs/babel-types::jm-overlay for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment