Fix whoops with bracket
|Deletions are marked like this.||Additions are marked like this.|
|Line 18:||Line 18:|
|0. '''should''' be installed to `/usr/lib/nodejs/` or `/usr/lib/nodejs/foo/`, depends whether the module is contained in a single file or in multiple files||0. '''should''' be installed to `/usr/lib/node/` or `/usr/lib/node/foo/`, depends whether the module is contained in a single file or in multiple files|
|Line 20:||Line 20:|
|0. '''should''' have `package.json` shipped in `/usr/lib/nodejs/foo/package.json`||0. '''should''' have `package.json` shipped in `/usr/lib/node/foo/package.json`|
|Line 39:||Line 39:|
|Line 46:||Line 46:|
|usr/lib/nodejs/<module>/bin/<mybin>.js usr/bin/<mybinOrRenameProperly>||usr/lib/node/<module>/bin/<mybin>.js usr/bin/<mybinOrRenameProperly>|
|Line 53:||Line 53:|
|This usually allows source to be kept unpatched (except for the nodejs rename):||This usually allows source to be kept unpatched:|
|Line 100:||Line 100:|
|nodejs -e "require('foo');"||node -e "require('foo');"|
|Line 106:||Line 106:|
|While the entire world use '''node''' as command name for Node.js framework, in Debian the correct name is '''nodejs''', because it conflicts with another package called ''node'' as well.||While the entire world used '''node''' as command name for Node.js framework, in Debian the correct name was '''nodejs''', because it conflicted with another package called ''node'' as well.|
|Line 110:||Line 110:|
|To comply to this, it is often as simple as:||To comply to this, node packages required patching, for example:|
|Line 116:||Line 116:|
|Some programs are a bit less obvious to fix, for example they can spawn nodejs instances using "node" name.||Now that the original node package has been removed from Debian, the Technical committee has reversed its decision [[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862051|Rename nodejs back to node for buster]]. Therefore, uploads to unstable shall now drop the old patches which rename node to nodejs.|
This document is still work in progress.
Please check the mailing list archives for the latest discussions about it.
Node.js modules policy
This page describes the policy that packages with Node.js modules should follow.
Policy in brief
the binary and the source package should be called node-foo
must build depends on nodejs
should be installed to /usr/lib/node/ or /usr/lib/node/foo/, depends whether the module is contained in a single file or in multiple files
should have package.json shipped in /usr/lib/node/foo/package.json
should integrate automatic tests checking require('foo') works correctly
compiled c++ addons should Depend on nodejs-abi-<process.versions.modules>
Policy in details
A module typically has already a source tree layout with directories like "lib", "bin", and a package.json file at its root.
Installing is as simple as:
lib usr/lib/node/<module> bin usr/lib/node/<module> package.json usr/lib/node/<module>
This usually allows source to be kept unpatched:
relative require statements like require('..') work
lookups in package.json like require('./package').version
load module from NODE_PATH : require('mymodule'); still work
Please refer to the upstream documentation (also available in /usr/share/doc/nodejs/api/modules.html#modules_folders_as_modules) to understand how to correctly Node.js looks up for modules.
Excluding auto-generated files from source
Strict application of DFSG requires files generated from source in upstream tarball to be excluded, unless it is possible to regenerate the files and prove they are identical to the ones in the tarball.
Minified files and browserified files are examples of such files that could be excluded for that reason. A convenient way to achieve this is to use the Files-Excluded field in debian/copyright, for more information please see UscanEnhancements.
Declare a build-dependency on nodejs
The nodejs package depends on libv8 and doesn't build on some architectures. Because of that, node-* packages having "Architecture: all" are available on architectures where nodejs isn't available - and so are uninstallable on those architectures. To work around that inconvenience to the users, simply declare an unversioned "Build-Depends: nodejs".
Declaring that build-dependency is also quite natural in the case of a package running its test suite during its build.
Autopkgtest - automatic tests
The package should provide automatic tests to check require(foo); works correctly in Debian. For more information about autopkgtest, please see DEP 8 specification.
This script can help you to add automatically autopkgtest support to your packages: node-autopkgtest.sh
If you want edit manually your package, you must do the following:
add this line to debian/control
create debian/tests/control and put:
Tests: require Depends: node-foo
replace node-foo with the name of the binary package contains the module foo
create debian/tests/require and put:
#!/bin/sh set -e node -e "require('foo');"
replace foo with the correct name of the module provided along with the package.
Patching binaries shebang
While the entire world used node as command name for Node.js framework, in Debian the correct name was nodejs, because it conflicted with another package called node as well.
Technical committee decided to fix this by renaming node to nodejs.
To comply to this, node packages required patching, for example:
- change shebangs to #!/usr/bin/nodejs
- rename node to nodejs in makefiles
- do not depend on nodejs-legacy
Now that the original node package has been removed from Debian, the Technical committee has reversed its decision Rename nodejs back to node for buster. Therefore, uploads to unstable shall now drop the old patches which rename node to nodejs.
Declaring a dependency on nodejs-abi-<process.versions.modules> for c++ addons
nodejs (>= 4.1.2~) provides a virtual package called nodejs-abi-<version>, where <version> is obtained with nodejs -e "console.log(process.versions.modules)" (or similar). This allows c++ addons compiled using nodejs-dev or node-gyp to declare a dependency upon a specific nodejs modules ABI.
Many thanks to Jonas Smedegaard for the idea https://bugs.debian.org/785748 and the essential part of the work.
Why Depend: nodejs-abi-<version>
It makes transitioning compiled Node.js addons to newer Node.js versions less painful. Without that, a bump in the abi means all packaged c++ addons report runtime failures. With that, a systematic binNMU of all concerned packages can be requested, and build failures can be dealt with properly.
See also https://bugs.debian.org/685540#20 for an example about how binNMU-ability is important.
How to use it ?
Build-Depends: nodejs-dev (>= 4.1.2~)
For dh-style packages
Using a dh addon:
dh $@ --with nodejs
or the dh_nodejs helper:
For cdbs-style packages
binary-post-install/$(pkg): dh_nodejs -p$(cdbs_curpkg)
Is it mandatory ?
No, though i propose to make it a release goal for Stretch.