Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Debian Packaging Guide for Beginners
Debian packaging (noob guide)
Disclaimer :- There is a well flourished guide on the subject already ,this is just
my version of it .
• (Debian Packaging pre requisites)
• (Detailed Wiki guide )
• (Get info regarding node-modules)
• (Debian package tracker)
• (Share long output & errors) - just a suggestion feel free to use your own
• (Choose a node-module from here)
From the Debian Packaging pre requisites link I followed docker setup
Arch based distros (installation)
Install docker by running pacman -Sy docker
Start and enable docker systemctl start docker && systemctl enable docker
Pull Debian Sid image from docker hub using the following command
docker pull debian:sid
Create a container with it and start bash on it
docker run --privileged --name "sid" -it debian:sid /bin/bash
Update and upgrade to latest versions of packagesapt-get update && apt-get upgrade
Exit after your work is done. If you need to connect to it later, use the following
commands which will take you to the bash prompt , if you encounter permission
issues try with sudo
docker start sid
docker attach sid
If successful you will be presented with a shell similar to this
Setup password for root account
passwd root
Its better to add a normal user and set a password
useradd -m -s /usr/bin/bash -G sudo username && passwd username
Install a text editor (I like vim , for installation run sudo apt install vim ) and
update .bashrc of docker container with the following environment variables
export DEBEMAIL=your@email.domain
export DEBFULLNAME='Your Name'
alias lintian='lintian -iIEcv --pedantic --color auto'
alias git-import-dsc='git-import-dsc --author-is-committer --pristine-tar'
alias clean='fakeroot debian/rules clean'
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
Command ls -la shows the hidden .bashrc file , to edit with vim do vim .bashrc and
add the above and the very end , update your current environment by running
source ~/.bashrc
vim tips
i – insert mode to enter text ,
:wq – write and exit ,:q!– exit without saving
Install the packages
sudo apt install npm2deb git-buildpackage dh-buildinfo
Setup username and email address for git
git config --global "Your name"
git config --global email@domain.tld
Took a node- module called “qw” from
(make sure you add your name next to it to avoid ownership confliction )
1) Check depedency use npm2deb depends
$ npm2deb depends -b -r qw
Module qw has no dependencies.
Here qw has no depedencies
2) Search for existing work using npm2deb search
$ npm2deb search monocle
Looking for similiar package:
Looking for existing repositories:
Looking for wnpp bugs:
Output shows no existing work and one can start work on it
3) Preview more info using npm2deb view
$ npm2deb view qwName: qw
Version: 1.0.1
Description: None
License: ISC
Debian: None (None)
License is automatically recognize as BSD, if this does not happen, please
--upstream-license option during creation to set a correct license.
4) Automate debian package creation using npm2deb create . npm2deb fails to do
completely ,our job is to fix those error which is shown by the prefix FIX_ME
$ npm2deb create qw
You may want fix first these issues:
qw/node-qw-1.0.1/debian/control:Description: FIX_ME write the Debian
qw/node-qw_itp.mail:Subject: ITP: node-qw -- FIX_ME write the Debian
qw/node-qw_itp.mail: Description
: FIX_ME write the Debian package
qw/node-qw_itp.mail: FIX_ME: This ITP report is not ready for submission,
until you are
qw/node-qw_itp.mail:FIX_ME: Explain why this package is suitable for adding
Debian. Is
qw/node-qw_itp.mail:FIX_ME: Explain how you intend to consistently
this package
ls command shows npm2deb created a dir called qw , change directory to
qw it
has the following contents$ ls
$ cd qw/
$ ls
qw_1.0.1- 1_amd64.buildinfo node-qw_1.0.1.orig.tar.gz
node-qw-1.0.1 node-qw_1.0.1-1.debian.tar.xz node-qw_1.0.1-1_all.deb
node- qw_1.0.1-1_amd64.changes node-qw_itp.mail
node-qw is a buggy folder created by npm2deb its better to delete it to
confusion later
$ rm -rf node-qw
5) Import package to git
$ gbp import-dsc --pristine-tar node-qw_1.0.1-1.dsc
now we get a new dir called node-qw which is git tracked , cd into the new
created dir node-qw and see git branch and git tag
$ git branch
* master
$ git tag
Delete the debian tag by running git tag -d debian/1.0.1-1
6) File ITPFiling itp is a method by which we take ownership of the module by mailing
to , in return we get a bug number , a sample mailing
templete is created by npm2deb for our use
$ cat node-qw_itp.mail (to view the template )
update the template by fixing the error with the prefix FIX_ME:
sample itp is attached below
7) Make package lintian clean
/qw/node-qw$ ls
LICENSE debian package.json qw.js test
/qw/node-qw$ dpkg-buildpackage && lintian ../node-qw_1.0.1-1.dsc
lintian points out the errors we need to fix
I: node-qw source: file-contains-fixme-placeholder debian/control:20
W: node-qw source: out-of-date-standards-version 4.1.1 (current is 4.1.2)
places where errors where fixed regarding this module
make sure to commit your changes as they are fixed by using the git
git commit -m “ commnet description” path/of/fixed/file
for reference -
8) Enable tests if presentfind the test command from package.json
$ cat package.json
"name": "qw",
"version": "1.0.1",
"description": "Quoted word literals!",
"main": "qw.js",
"scripts": {
"test": "tap test"
"keywords": [],
"author": "Rebecca Turner <> (http://re-",
"license": "ISC",
"devDependencies": {
"tap": "^8.0.0"
add the test command under override_dh_auto_test from debian/rules
tap -J test/*.js
add the test framework (mocha, node-tape etc) as a build dependency in
debhelper (>= 9)
, dh-buildinfo, nodejs
, node-tap
Standards-Version: 4.1.2
add a Test-Command section to debian/tests/control
$ cat tests/control
Tests: require
Depends: node-qw
Test-Command: tap -J test/*.js
Depends: @, node-tap
refrence link ;-
run dpkg-buildpackage and check if the tests ran sucessfully and change
debian/changelog to release by running dch -r.
9) upload to (recomment this since its a freesoftware
the team manintains it)
create a new project as per your node-module name
git remote add origin
module-name.git (eg link)
git push -u origin --all –follow-tags
this is a temperory repo once you mature ,will get officail repo access
10) Clean build with sbuild
$ sudo apt-get install sbuild
$ sudo sbuild-adduser $LOGNAME
... *logout* and *re-login* or use `newgrp sbuild` in your current shell$ sudo sbuild-createchroot --include=eatmydata,ccache,gnupg unstable
$ sudo sbuild -A -d unstable ../node-qw_1.0.1-1.dsc
11)Install deb package
apt-get install autopkgtest
dpkg -i ../node-qw_1.0.1-1_all.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment