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 1

Step 1. Check dependencies

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.

Step 2. Search for existing work

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.

Step 3. Preview more information

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.

Step 4. Create packaging files

Next step, make the debianization:

Note: Make sure you ?setup your name and email properly in environment variables.

$ 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

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.

Step 5. Download source tarball

Use uscan to get orig source files. Fix debian/watch and then run

$ cd monocle/node-monocle           
$ uscan --download-current-version

You can see "Workflow example 2" below if you are unable to download source tarball with generated debian/watch file.

Step 6. Create the package

Follow steps 3-7 from "Workflow example 2" below

For more information about Javascript Team Infrastracture please read the Javascript page.

Workflow example 2

Where uscan does not work because the upstream repo is missing tags. The node module we use is 'require-directory'.

Step 1. Create packaging files

Follow steps 1-4 from "Workflow example 1" above,

Step 2. 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) or download the tarball from npmjs.org.

Option 1: Download via npmjs.org

This is the easier method.

$ cd require-directory
$ npm view require-directory dist.tarball
https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz
$ wget https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz

Option 2: Download via github.com commit snapshot

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.tgz https://github.com/troygoode/node-require-directory/archive/cc71c23dd0c16cefd26855303c16ca1b9b50a36d.tar.gz

Step 3. Create debian source package

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.tgz

Switch to package directory and remove the extra line "* New upstream release" from debian/changelog

$ cd ../node-require-directory-2.1.1
$ dch -e
$ dpkg-source -b .

Step 4. Build the binary package

$ dpkg-buildpackage
$ lintian ../node-require-directory_2.1.1-1_amd64.changes

Make sure you fix all the errors and warnings shown by lintian.

$ licensecheck --deb-machine * -r

Update debian/copyright with any missing information.

Step 5. Import your package to git

For importing your package to git, refer ?using gbp import-dsc page

Note: gem2deb automates upto step 4. You'll need to complete upto Step 3 to import the dsc file.

Step 6. Request sponsorship

Step 7. Push your repo to alioth

Once you are added to pkg-javascript team on alioth, you can push your changes directly to alioth.

$ ssh git.debian.org
$ cd /git/pkg-javascript
$ ./setup-repository node-require-directory 'Packaging for node-require-directory'

* Add alioth as origin for your repo

$ git remote add origin git+ssh://git.debian.org/git/pkg-javascript/node-require-directory.git
$ git push --all && git push --tags
$ git branch upstream --track origin/upstream
$ git branch pristine-tar --track origin/pristine-tar