Npm2Deb
npm2deb is an automatic tool which permits to fast deploy debian/* files starting from a module downloaded via npm.
sudo apt-get install npm2deb
If you want help in developing:
git clone https://github.com/LeoIannacone/npm2deb
For usage information, please refer to npm2deb man page.
Workflow example
A simple workflow is check if a node_module has all dependencies already satisfied in Debian, you can use npm2deb depends to get this info.
In this example we will check jade module which at the moment is not packaged for Debian:
$ npm2deb depends -b -r jade Dependencies: NPM Debian jade (1.3.1) None ├─ monocle (1.1.51) None │ └─ readdirp (~0.2.3) node-readdirp (0.2.4-2) ├─ transformers (2.1.0) None │ ├─ uglify-js (~2.2.5) uglifyjs (1.3.5-1) │ ├─ promise (~2.0) None │ │ └─ asap (~1.0.0) None │ └─ css (~1.0.8) None │ ├─ css-stringify (1.4.1) None │ │ └─ source-map (~0.1.31) None │ │ └─ amdefine (>=0.0.4) None │ └─ css-parse (1.7.0) None ├─ character-parser (1.2.0) None ├─ mkdirp (~0.3.5) node-mkdirp (0.3.5-1) ├─ commander (2.1.0) node-commander (2.0.0-1) ├─ constantinople (~2.0.0) None │ └─ uglify-js (~2.4.0) uglifyjs (1.3.5-1) └─ with (~3.0.0) None └─ uglify-js (~2.4.12) uglifyjs (1.3.5-1)
As you can see, there are many modules not packaged for debian. npm2deb was written to reach this goal, have a tool to fast and easy package new nodejs module.
In this example we will take care about monocle module.
First of all, use npm2deb search to know if someone else has already started working on this module:
$ npm2deb search monocle Looking for similiar package: None Looking for existing repositories: None Looking for wnpp bugs: None
As you can see, there no info about monocle in Debian. So you can start to work on. Use npm2deb view command to get a preview information about module:
$ npm2deb view monocle Name: monocle Version: 1.1.51 Description: a tool for watching directories for file changes Homepage: https://github.com/samccone/monocle License: BSD Debian: None
License is automatically recognize as BSD, if this does not happen, please pass --upstream-license option during creation to set a correct license.
Next step, make the debianization:
$ npm2deb create monocle This is not a crystal ball, so please take a look at auto-generated files. You may want fix first these issues: monocle/node-monocle/debian/control: FIX_ME long description Use uscan to get orig source files. Fix debian/watch and then run $ uscan --download-current-version
This command creates <module_name>/node-<module_name>/debian directory which contains the basic information about the module.
You have to fix every occurrence of FIX_ME in those files.
By default npm2deb set Vcs-* fields to ?git in pkg-javascript. For more information about git, please read GitPackaging.
For more information about Javascript Team Infrastracture please read the Javascript page.
For importing your package to git, refer ?using gbp import-dsc page
Another example workflow
Where uscan does not work because the upstream repo is missing tags. The node module we use is 'require-directory'
Create debian directory for 'require-directory'
$ npm2deb create require-directory
Download source tarball: Usually this can be done by uscan --verbose --download-current-version but some projects does not create git tags for their releases so we have to visit their home page (given in 'debian/control') and find out the commit for the release (from their 'commits' page).
Homepage: https://github.com/troygoode/node-require-directory Commits page: https://github.com/troygoode/node-require-directory/commits/master
In this case 'bump to v2.1.1' commit is what we want Click on '<>' button on the right of this commit to browse repository on this commit.
'bump to v2.1.1 commit page: https://github.com/troygoode/node-require-directory/tree/cc71c23dd0c16cefd26855303c16ca1b9b50a36d
Click on the 'Clone or download' button Right click on 'Download ZIP' and copy its url
ZIP download url: https://github.com/troygoode/node-require-directory/archive/cc71c23dd0c16cefd26855303c16ca1b9b50a36d.zip
Paste the link on the terminal and change .zip to .tar.gz and use wget command to download this file and give -O option to set a different name for the downloaded file
$ cd require-directory/ $ wget -O node-require-directory-2.1.1.tar.gz https://github.com/troygoode/node-require-directory/archive/cc71c23dd0c16cefd26855303c16ca1b9b50a36d.tar.gz
Now combine the 'debian' directory we created earlier to the tar.gz file we downloaded
$ cd node-require-directory $ uupdate -b ../node-require-directory-2.1.1.tar.gz
Now build the package and check with lintian
$ cd ../node-require-directory-2.1.1 $ dpkg-buildpackage $ lintian ../node-require-directory_2.1.1-1_amd64.changes