Basics of the Debian Package Management System

Basics of the Debian Package Management System

Introduction

Package managers are essential to successfully installing software on Linux systems. These tools eliminate the hassle of dealing with dependencies during software installation. Package managers automatically install dependencies so that the software functions as expected. This guide covers the basics of the Debian package management system. We’ll explore what it is and examine the contents of a package to help you get started.

             

Packagecloud is a cloud-based service that enables users to store all of the Debian packages that are required by their organization, regardless of OS or programming language, and repeatedly distribute them to their destination machines. Check out our free trial to set up your packages quickly. 

       

What Is A Debian Package?

A Debian package is an archive of the executable files, libraries, configuration files, and documentation associated with an application. Debian package names end with the “.deb” extension. Each Debian package consists of two package types: The binary package and the source package. A source package includes an archive of the application’s source code (the executables) libraries and instructions for building the app. A source package must be compiled. Binary packages are already compiled. The source package is usually comprised of three files:

.dsc: The Debian source control file is a text file that describes the files that are part of the package. It is signed by the maintainer to signify its authenticity. 

.orig.tar.gz: The original software source code. 

.debian.tar.xz (or .diff.gz): The changes (diff) made to the original source code. 

Binary packages consist of:

debian-binary: A file that contains the version of the deb file format.

control.tar.gz: metadata about the package.

data.tar.gz: data files for the package.

         

Debian Package Management Tools

Both APT and dpkg are command-line tools to install packages. You can use dpkg independently. However, APT provides more functionality by integrating with dpkg on the backend. In this way, APT is a more user-friendly tool that incorporates dpkg functionality with enhanced package management functionality.

       

Using APT, developers can get and install packages from a remote repository with one command. On the other hand, dpkg only lets developers install local files already downloaded. When it comes to dependencies, apt checks for and installs necessary dependencies, whereas dpkg does not. So which one should you use? In most cases, APT is the best choice. It helps ensure the package works as expected by downloading and undying the package while automatically checking for and installing all dependencies. 

       

Packagecloud is a cloud-based service for distributing software Debian packages to your machines and environments. Check out our free trial to set up your packages quickly. 

     

Anatomy of a Debian Package

A Debian package consists of a variety of control files and scripts for building packages. Unpacking a Debian package reveals the following:

   

The data.tar.gz

In the Debian package management system, the data.tar.gz archive holds the executables, libraries, and documentation for the package. These fills will be extracted from the package during installation. 

      

The debian-binary

The debian-binary is a text file containing the version of the .deb file package format.

          

The control.tar.gz

This archive file contains meta-information about the package as well as scripts to run before, during, or after installation. 

./postinst

./control

./conffiles

./prerm

./postrm

./preinst

./md5sums

  

Control File

The ./control directory contains a control file that contains information debian needs to calculate dependencies and display information about the file.

      

Maintainer Scripts

The following folders store maintainer scripts. Maintainer scripts are optional scripts that the package management system runs when a package is installed, upgraded, or removed.

./postinst — runs after package installation 

./prerm — Stops daemons before removing files associated with the package

./postrm — if the preinst fails, the postrm script runs to 

./preinst — runs before package installation. The script is typically used to stop services until package installation completes. 

     

Master Control File Basics

Each Debian binary package contains a master control file, which contains several fields. Each field begins with a tag, such as Package or Version (case insensitive), followed by a colon, and the body of the field. Let’s take a look at a sample file and a few of these fields.

Source: hello-debian

Section: utils

Priority: extra

Maintainer: Full Name <yourname@example.com>

Build-Depends: debhelper (>= 8.0.0)

Standards-Version: 3.9.3

Vcs-Git: git@github.com:streadway/hello-debian.git

Vcs-Browser: http://github.com/streadway/hello-debian

Package: hello-debian

Section: utils

Priority: extra

Architecture: any

Depends: ${shlibs:Depends}, ${misc:Depends}

Description: Example package maintenance (under 60 chars)

 The build output from a repository listing the steps to set up a Debian

 package in a long-format under 80 characters per line.

    

Package: package-name (required) 

The package name

      

Maintainer: fullname-email (recommended)

Name of the person who created the package 

      

Priority: priority

Sets the importance of this package to the system as a whole. Common priorities include:

  • Essential 
  • Required
  • Standard 
  • Optional 
  • Extra

       

Depends: package-list

List of additional packages that this package depends on. 

      

Pre-Depends: package-list

List of packages that must be installed and configured before this one

       

Recommends: package-list

List of recommended packages to install with this package. These files would typically be installed with this package for a standard installation. The package manager shows the user a warning if they attempt to install a package without the recommended packages listed here. 

       

Suggests: package-list

List of packages that could enhance this package's usefulness. However, these are only suggestions and the current package will install fine without them. 

          

The Debian Package Management System: Put an End To Dependency Management Nightmares

Managing dependencies for software installations is important for a stable app. Without the proper tools, managing it all can be tedious and frustrating. The Debian package management system removes the hassle. Using the tool, developers can install their apps and have all required dependencies automatically installed. 

      

Packagecloud is a cloud-based service for distributing software packages to your machines and environments. Packagecloud enables users to store all of the packages that are required by their organization, regardless of OS or programming language, and repeatedly distribute them to their destination machines. This enables users to efficiently, reliably, and securely set up and update machines without owning any of the infrastructures that are typically required to do that.

      

Check out the Packagecloud free trial to see how easy it is to distribute packages throughout your entire organization. Never worry about the scaling, consistency, or security of your packages again. Sign up for your packagecloud free trial here.

You might also like other posts...