1. Home
  2. [Linux] Create a Basic Debian Package Using dpkg-deb Tool

[Linux] Create a Basic Debian Package Using dpkg-deb Tool

Introduction

This document describes a simple way to create a basic Debian package. 

Create a C Hello-world program

  1. Create a C hello world program.
  1. Compile the helloWorld.c
  1. Test run the C hello world program

Debian Package preparation

  1. Create a new directory to store the contents of the package, eg. hello-1.0, which will be built into a .deb package later. 
  1. Create a special folder called DEBIAN inside the main project directory.
  1. Create a control file inside the DEBIAN folder, the control file contains all the metadata about the package. 
  1. Create a bin folder to store all the binary or executable files. Note that all the files will be installed at the same given location. For example, if we moved the compiled helloworld c program exe file to helloworld-1.0/usr/bin/helloworld, the file will be located at /usr/bin/ after installation.
  1. Copy the binary/executable file into the bin folder. 
  1. Tree structure of the hello-1.0 Debian package directory

Build the Debian Package

  1. Build the hello-1.0 Debian package using the dpkg-deb tool.

Install and Run the Debian Package

  1. Install the built hello-1.0.deb package using apt-get.
  1. Show the package info using apt-cache show.
  1. The helloworld program is located in the /usr/bin/ directory after installation.
  1. Run the installed helloworld program, it will print "Hello World" on the terminal.

Uninstall the Debian Package

  1. Uninstall the helloworld program from the Linux system.
  1. The helloworld exe file is removed automatically from the /usr/bin/ directory.

Reference

  1. How To Make A .deb For Your Program
  2. Creating a custom Debian package
  3. Create a Debian package using dpkg-deb tool 

Updated on March 1, 2021