Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to create a Debian package from its contents.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

How to create a Debian package from its contents.

#1 Post by edbarx »

Sometimes the need arises to create your own packages from sources that you write and you find yourself struggling to make sense of the package development tools. This howto is a shortcut to have your task done without using such tools. All you need are, obviously, the files you want your package to install and two or three other text files which Debian (obstinately :P) mandates that you must have.

Suppose that we want to install a library like libsystemd-login0. The directory tree for that package is as follows:

Code: Select all

libsystemd-login0
├── DEBIAN
│   ├── control
│   └── md5sums
├── lib
│   └── x86_64-linux-gnu
│       ├── liblogin.so
│       ├── libsystemd-login.so.0 -> ./liblogin.so
│       └── libsystemd-login.so.0.2.1 -> ./liblogin.so
└── usr
    └── share
        └── libsystemd-login0
            ├── changelog
            └── copyright

6 directories, 7 files
Essentially, the files that you need to add to have Debian accept your tree as the legitimate contents of a package is to add the DEBIAN directory as shown which should contain the control text file and md5sums. The latter is obtained by issuing the command while at the parent directory of the root directory of the tree:

Code: Select all

find usr -type f -exec md5sum {} \;  > DEBIAN/mdsums
You can create the control file using any text editor. Be informed that you have to follow some rules as this file is used by the package management backends. For more information you can consult:
a) man deb-control
b) critically view, ie study, the control files of existing packages to get an idea of how the various fields in the file are used

You will also need to add a changelog file. This file also follows a set of predefined rules. Consult other packages' changelog files to get an idea. The same thing applies for the copyright file. Follow the existing formats.

When your tree is ready, become root, cd to the tree's root parent directory and issue this chown command. Be careful when you are root using chown in this way as it can ruin your entire installation. Now you are warned. Like a paranoid on the most powerful antiparanoid pills, make sure that you are really at the parent directory of the root of your package's tree. Then, issue the command:

Code: Select all

chown -R root:root tree-root
Finally, build your package as follows. Again, do this at the parent of the root of your package's tree.

Code: Select all

dpkg -b tree-root your-package-name-in-conformity-to-debian-rules.deb
Enjoy! :)
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

Post Reply