Skip to main content

How To Simply Build A Debian (.deb) Package?


Because of many reasons, Ubuntu now has became a very popular Linux Desktop Distribution (probably the most popular). As result, Debian package management (dpkg), also has grown very popular as well as Ubuntu. Now, many third party software developer (Adobe, Real Player, Foxit, etc), almost always, provides their software installer in Debian package (with .deb extension), alongside or even instead of RPM and other package managements in Linux.


Of course, this is not a sign that in the future, Debian package will be the only package management that will be used in every Linux distribution. Every Linux distribution has its own strength and weakness, so we must realize that all Linux distributions must live and grow bigger together, to pursue the ultimate advantage of the free and open source softwares (FOSS).


Now, I want to share a little tip to build a Debian package (.deb) using a basic element of Debian system called dpkg-dev. Dpkg-dev is a basic tool in Debian system to make simple modification, build and maintain Debian package management. This tip is useful (for me), to build an independent software or desktop themes or wallpapers to a .deb package, so in other time, we can simply and easily install and use them.


BASIC COMPREHENSION

In every Debian package, has a structure like this below :

  1. DEBIAN

    A folder including some files :

    a) control, is the package/software description (core file),

    b) md5sum (additional),

    c) postinst, a script of post/after install scripts (additional),

    d) postrm, a script of post/after remove scripts (additional) and other additional scripts (if necessary).

  2. Target Directory (Recrussive)

    A folder including the library, binary and core data files that used by the software. The files placed recrussively same as their destination. This folder might be consisted of more than one folder depending of the software/package structure. Usually, this folder consists of :

    a) usr

    Main directory that consists the binary, library and xdg standard desktop shortcut (with .desktop extension). Example : usr/share/lib/libk3blib.so etc; usr/bin/k3b; usr/share/applications/kde/k3b.desktop; usr/share/apps/k3b.

    b) opt

    Main directory if the software work directory is placed in opt

    c) etc

    Additional directory if necessary

    and other directories if necessary.


We has known the structure of dpkg. Now, what is the content of the software description file (DEBIAN/control)? This is the example :


Package: maknyus-wallpapers

Version: 0.1alwan1

Architecture: all

Maintainer: Alwan Rosyidi

Installed-Size: 8100

Replaces: ubuntu-wallpapers

Section: gnome

Priority: optional

Description: Wallpaper pengganti dan tambahan biar desktop Ubuntu terlihat lebih maknyus.

(one space)Wallpaper pengganti karo tambahan ben tampilane Ubuntu lewih maknyus.

(one space)A replacer and additional wallpapers to make Ubuntu desktop looks awesome :D

(one empty line)


There are few important notes we have to know in the control file :

Version must be started with number and then can be followed by characters (look at the example).

Replaces is a description if our package is another newer version of other package that has existed in the system, or, if our package has a file with the same name with another existing file in the system that is the part of a package. For example : I made a wallpaper to be the main wallpaper and replace the default Ubuntu wallpaper, so I have to replace the ubuntu-wallpapers package in this description file. If we miss this column, our package will not be able to be installed completely. Even, our package will contaminate our apt database an our apt and dpkg system will be error.

Description must be ended by an empty line. If we need sub-descriptions in the new line/paragraphs, we must put one space in the beginning of the paragraphs/line (look at the example).


BUILDING

As an example, now, I want to build a package called maknyus-wallpapers, an additional wallpaper set to eyecandize Ubuntu desktop. This is the folder structure and its files inside :


maknyus-wallpaper :

DEBIAN/control

usr/share/backgrounds/files.jpeg


Now, we just have to build the package by typing this simple magical command :


sudo folder-name folder-name_version_architecture.deb


sudo dpkg -b maknyus-wallpapers maknyus-wallpapers_0.1alwan1_all.deb


Important notes : we must confirm that the package name must be same as in the description in the control file. One different character will make our package recognized as another different package. Example : in the control file, I've written the package name as maknyus-wallpapers (with s), so in the package name I must type the same name (with s). If we miss this, our package will be actually installed, but will not be recognized well as an installed package.


Now I have a package called maknyus-wallpapers_0.1alwan1_all.deb and can be installed manually by terminal or graphically by gdebi (look at the screenshot above). Enjoy! :)

Comments

Popular posts from this blog

Ubuntu Kylin 19.04 Review : A Gorgeous Windows 10 Clone

It's been quite a while since the last post I wrote in this blog. My daily life prevents me to write another stuff about Linux Desktop, and now I'm curious to take a look to the Ubuntu Kylin 19.04. Ubuntu is always be my favorite distro. It supports huge number of hardwares, it has probably the largest Linux software repository. It is also --the most important thing-- very easy to install, even for beginners.  But for some couple of years, because of technical reason, I stopped to play around with the Ubuntu releases. I stood for KDE Neon and became my primary OS because of its simplicity and the look. Few days ago Ubuntu has released its newer version, Ubuntu 19.04 codenamed Disco Dingo. I'm yes impressed by the progress Ubuntu developer has made, especially the way they arrange the GNOME desktop to match the Ubuntu theme. But the most interesting flavor of this release is Ubuntu Kylin. It's an official Ubuntu flavor, designed for Chinese People with its own...

How To Speed Up Your KDE Plasma Desktop (KDE4)

KDE is one of the oldest desktop environment in Linux. While GNOME (the other desktop that as old as KDE) is trying to built its own style of user interface, KDE from the beginning seems to mimics the Microsoft Windows' "classic" user interface. Thus, KDE has its own user base, especially for them who still in love with the Windows' philosophy : a simple desktop, with a single taskbar in the bottom, and a start menu in the left. Personally, I love KDE. It's gorgeous and eyecandy. But sometimes, I feel KDE is little bit slow in my older hardwares. So, after some experiences, I've found some tweak how to make KDE Plasma Desktop Runs Faster . 1. Change The Compositing Engine  Go to System Settings>Desktop Effect>Advanced , and change the Compositing type from OpenGL 2.0 to XRender. 2. Remove All Bloatware Apps There are some uneeded apps installed in Kubuntu (my favorite KDE distro) and you could safely remove them. Here are my list : ...

BAM Huawei Mobile Partner For Linux. Download and Install.

Click to enlarge Profile management Broadband connection is one of the most used internet connections, alongside wired and wi-fi internet connection. And the most used device to use broadband connection is USB Modem (GSM/CDMA), and one of the most used brands is Huawei, a world-recognized Chinese manufacture that focuses to produce great networking devices (modems, router etc). It is probably the most popular brand from China and I have to say that Huawei is a great product. Because of this I decided to buy a CDMA USB modem from Huawei. And greatly, this has already been recognized by Linux from so long time ago and so I can use the modem easily with GNOME's Network Manager. But later I found a problem : how to top up my prepaid internet account? To top up my prepaid internet account, I have to send a SMS to the provider and I can't do this on Linux. With forced, I temporarily used Mobile Partner application on Windows to buy / top up my prepaid internet account. ...