Basic Guide for Debian Packaging (NodeJS)

What Is Debian?

Debian is a universal Linux based operating system. Debian systems currently use the Linux kernel or the FreeBSD kernel.

The need for people is application software: programs to help them get what they want to do done, from editing documents to running a business to playing games to writing more software. Debian comes with over 51,000 packages (precompiled software that is bundled up in a nice format for easy installation on your machine), a package manager (APT), and other utilities that make it possible to manage thousands of packages on thousands of computers as easily as installing a single application. All of it is free.

It’s like a tower. At the base is the kernel. On top of that are all the basic tools. Next, is all the software that you run on the computer. At the top of the tower is Debian carefully organizing and fitting everything so it all works together.

What Is an Operating System?

An operating system is the set of basic programs and utilities that make your computer run. At the core of an operating system is the kernel. The kernel is the most fundamental program on the computer and does all the basic housekeeping and lets you start other programs.

Still thinking, "Why use Linux?"

What Is Debian Packaging?

Ever done Sudo apt install (anything)? Wondered how apt install works and what file it fetches and how the file gets auto-installed? So, here comes the Debian Packaging task. Packaging aims to allow the automation of installing, upgrading, configuring, and consistently removing computer programs for Debian.

To be simple, its like making .deb of any software or module like in windows we have .exe file

By doing Debian packaging we make Debian packages, which is a collection of files that allow for applications or libraries to be distributed via the Debian package management system.

Check out some more info.

Enough of this knowledge, get me to the coding part, and let's do the packaging.

Let's Start With Prerequisites

First, we need a Debian SID environment. Oops, I have an ubuntu/arch/Gentoo/mac machine and installing another OS, nah, not ready for a new OS - if that's what you are thinking now, don’t worry. We have Docker, lxc or virtual machine for you.

See instructions given below to setup Debian Sid.

I prefer Docker, and when I started with Debian packaging, I started with Docker container.

Tips for Linux users, who use apt package manager, to install docker is now really easy, just do “sudo apt install docker.io”

You can go with the above setup link or the way I installed it.

My way of installation of Docker SID environment:

Work to be done Code
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 packages apt-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.

“sudo docker start sid && sudo docker attach sid”

Now, we need tools to work with:

Install packaging tools inside the container # apt-get install dh-make OR # apt-get install gem2deb OR # apt-get install npm2deb as required.

# apt-get install git-buildpackage sbuild dh-buildinfo quilt lintian these packages must be installed.

For Nodejs modules, use npm2deb; for ruby gems, use gem2deb; for go packages, use dh-make-golang. If there is no tool specific to a language, dh-make can be used as a generic tool for any language.

Still Having an Issue With Set-Up?

Join our real-time chat group using one of the 4 options and say hi. If you have difficulty with pre-requisites please ask here or on chat rooms.

  1. Matrix: #debian-browserify:diasp.in
  2. IRC: #debian-browserify on irc.oftc.net
  3. Telegram: https://t.me/debian_browserify

If you are new to these technologies, I suggest you try matrix. See https://matrix.org for details. https://riot.im has a list of apps you can use.

http://webchat.oftc.net/?channels=debian-browserify&uio=MT11bmRlZmluZWQb1 to join the IRC room

Okay to start with packaging, start with nodejs packages and understand the workflow and then you can shift with other language modules and then to higher multi-language modules. - Manas Kashyap


Lets, do it then!

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

Java
 




xxxxxxxxxx
1


 
1
export DEBEMAIL=your@email.domain
2
export DEBFULLNAME='Your Name'
3
alias lintian='lintian -iIEcv --pedantic --color auto'
4
alias git-import-dsc='git-import-dsc --author-is-committer --pristine-tar'
5
alias clean='fakeroot debian/rules clean'
6
export LANG=C.UTF-8
7
export LC_ALL=C.UTF-8


Java
 




xxxxxxxxxx
1


 
1
source ~/.bashrc


Workflow (We Are Taking Example of Node Module Qw)

1) Check dependency use npm2deb depends

Java
 




xxxxxxxxxx
1


 
1
$ npm2deb depends -b -r qw


2) Search for existing work using npm2deb search

Java
 




xxxxxxxxxx
1


 
1
$ npm2deb search qw


3) Preview more info using npm2deb view

Java
 




xxxxxxxxxx
1


 
1
$ npm2deb view qw


4) Automate debian package creation using npm2deb create.

Java
 




xxxxxxxxxx
1


 
1
$ npm2deb create qw


5) Import package to git

Java
 




xxxxxxxxxx
1


 
1
$ gbp import-dsc --pristine-tar node-qw_1.0.1-1.dsc


6) File ITPFiling itp is a method by which we take ownership of the module by mailing to submit@bugs.debian.org, in return, we get a bug number, a sample mailing template is created by npm2deb for our use

7) Make package lintian clean

Java
 




xxxxxxxxxx
1


 
1
/qw/node-qw$ dpkg-buildpackage && lintian ../node-qw_1.0.1-1.dsc


8) Enable tests if present any, find the test command from package.json

Java
 




xxxxxxxxxx
1
17


 
1
  $ cat package.json
2
 
          
3
  {
4
  "name": "qw",
5
  "version": "1.0.1",
6
  "description": "Quoted word literals!",
7
  "main": "qw.js",
8
  "scripts": {
9
  "test": "tap test"
10
  },
11
  "keywords": [],
12
  "author": "Rebecca Turner <me@re-becca.org> (http://re-
13
  becca.org/)",
14
  "license": "ISC",
15
  "devDependencies": {
16
  "tap": "^8.0.0"
17
  },


Java
 




xxxxxxxxxx
1


 
1
override_dh_auto_test:
2
 
          
3
 tap -J test/*.js


Java
 




xxxxxxxxxx
1


 
1
$ cat tests/control
2
  Tests: require
3
  Depends: node-qw
4
  Test-Command: tap -J test/*.js
5
  Depends: @, node-tap


9) upload to https://salsa.debian.org ( as the team maintains it)

10) Clean build with sbuild

Java
 




xxxxxxxxxx
1


 
1
$ sudo sbuild-adduser $LOGNAME


Java
 




xxxxxxxxxx
1


 
1
 $ sudo sbuild -A -d unstable ../node-qw_1.0.1-1.dsc


11)Install deb package

Java
 




x


 
1
  apt-get install autopkgtest
2
  dpkg -i ../node-qw_1.0.1-1_all.deb



 

 

 

 

Top