Debian Package Structure

One can find lots of .deb files in directory ‘/var/cache/apt/archives/.

From there I'm taking package “youtube-dl_2012.02.27-1ubuntu0.1_all.deb” to explain structure of Debian package.

As you can see, the package further contains two folders: DEBIAN and usr.

DEBIAN has two files:md5sums and control.

'md5sums' contains for each file in data.tar.gz the md5sum.

The MD5 protection that exists in dpkg is really only useful for accidental corruption, and not necessary to protect the installation path.

You might be interested in the debsums package, but since it uses MD5s, it also is only useful for checking for accidental corruption.

In our example the content looks like this:

....................................................................................................................................

43678cad6a1b4ff3330c2fada3206894 usr/bin/youtube-dl 
2fcb94a9ce36afaeecf4265b19244727 usr/share/doc/youtube-dl/NEWS.Debian.gz 
77da787ff167347b77383440c31891c1 usr/share/doc/youtube-dl/changelog.Debian.gz 
705df117892f3fd870fb153fb3a530a8 usr/share/doc/youtube-dl/copyright 
33ccd4dcbefa3eb9daf7d3774d7734fa usr/share/man/man1/youtube-dl.1.gz

.............................................................................................................................................

Control file : Each Debian package contains the master `control' file, which contains a number of fields, or comments when the line starts with '#'. Each field begins with a tag, such as Package or Version (case insensitive), followed by a colon, and the body of the field. Fields are delimited only by field tags. In other words, field text may be multiple lines in length, but the installation tools will generally join lines when processing the body of the field

Here are contents of control file from my example:

Package: youtube-dl 
Version: 2012.02.27-1ubuntu0.1 
Architecture: all 
Maintainer: Ubuntu Developers  
Installed-Size: 205 
Depends: python (>= 2.5) 
Recommends: ffmpeg, ffmpeg (>= 4:0.6) | ffprobe, rtmpdump 
Section: web 
Priority: extra 
Homepage: http://rg3.github.com/youtube-dl/ 
Description: downloader of videos from YouTube and other sites 
 youtube-dl is a small command-line program to download videos from 
 YouTube.com and other sites that don't provide direct links to the 
 videos served. 
 . 
 youtube-dl allows the user, among other things, to choose a specific video 
 quality to download (if available) or let the program automatically 
 determine the best (or worst) quality video to grab. It supports 
 downloading entire playlists and all videos from a given user. 
 . 
 Currently supported sites are: CollegeHumor, Comedy Central, Dailymotion, 
 Facebook, Metacafe, MyVideo, Photobucket, The Escapist, Vimeo, Yahoo!, 
 YouTube, blip.tv, depositfiles.com, video.google.com, xvideos, Soundcloud, 
 InfoQ, Mixcloud, OpenClassRoom. 
Original-Maintainer: Rogério Brito 

............................................................................................................................................

'man deb-control' has more information about it.

'postinst' and 'prerm' files are not mandatory for your first package. But every proper official Debian package has them for good reasons.

‘prerm’ and ‘postinst’ seem to take care of removing old documentation files and adding a link from doc to share/doc.

Here are contents of prerm file from package “python-apt_0.8.3ubuntu7.1_i386.deb”.

……………………………………………………………………………………………………………………….

#!/bin/sh
set -e

# Automatically added by dh_python2:
if which pyclean >/dev/null 2>&1; then
pyclean -p python-apt
else
dpkg -L python-apt | grep \.py$ | while read file
do
rm -f "${file}"[co] >/dev/null
done
fi

# End automatically added section

……………………………………………………………………………………………………………………………….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s