SlideShare a Scribd company logo
1 of 36
Download to read offline
Miriam Ruiz <miriam@debian.org>
Understanding Debian Packages
A very brief introduction to what's inside Debian binary packages
2 / 36
Contents
What is a Package?
Questions and Answers
What's inside a package
Relationship between packages
The scripts inside the packages
Debian Configuration: Debconf
3 / 36
What is a Package?
4 / 36
What is a Package?
● Minimal Unit of Installation and Removal
● A Debian package can include:
● The files needed to provide some functionality to the system
(software, artwork, configuration files, program data, etc)
● Some administrative information regarding that package:
Description, Dependencies, Maintainer, etc.
● The copyright/licensing information about the contents
included in that package, though this can't be read until the
package is open.
● Configuration scripts to install/deinstall/upgrade/purge the
software
● Checksums to check if the files contained in the file have
not been modified. Keep in mind that these are not provided
for security against attacks.
● A mechanism (debconf) to configure some parameters
about the package.
5 / 36
What can you do with a Package?
● Install it: dpkg ––install <file.deb>
● Show information about it: dpkg ––info <file.deb>
● List its contents: dpkg ––contents <file.deb>
● Extract its files: dpkg ––extract <file.deb> <directory>
● Extract and show files: dpkg ––vextract <file.deb> <directory>
● Lists the installed packages: dpkg ––list <pattern>
● List the files installed from a package: dpkg ––listfiles <package>
● Shows information about a package: dpkg ––print-avail <package>
● Packages where a given filename is found: dpkg ––search <filename>
● Shows the status of a fiven package: dpkg ––status <package>
● Remove package: dpkg ––remove <package>
● Remove it and purge its configuration: sudo dpkg ––purge <package>
See: https://www.debian.org/doc/manuals/debian-reference/ch02.en.html
6 / 36
What's inside a Package?
7 / 36
How is a package inside?
Files Metadata (aka. DEBIAN)
Package
8 / 36
How are these things stored?
Package
data.tar + compression control.tar + compr.debian-binary
2.0
BSD ar file (uncompressed)
See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
9 / 36
How can I extract the contents?
● Extract the archived contents: ar x <file.deb>
● Result: control.tar.gz data.tar.gz debian-binary
● Standards version of the binary package : cat debian-binary
● Which files are distributed: tvfJ data.tar.xz
● Which metadata files are included: tvfz control.tar.gz
● Some files that we can find: control, prerm. postrm, preinst,
postinst, shlibs, conffiles, config, templates,
md5sums
● It is easier to work with the dpkg-deb command:
● Show information about a package: dpkg ––info <file.deb>
● Show a control field: dpkg ––field <file.deb> <field>
● Show a control file: dpkg ––info <file.deb> <control_file>
● Show the data contents: dpkg ––contents <file.deb>
● Extract all: dpkg ––raw-extract <file.deb> <directory>
● Build a package: dpkg ––build <directory> <directory>
10 / 36
The control data of a package
11 / 36
Control Fields: DEBIAN/control
Package: [package name]
Version: [version-deb]
Architecture: [all or architecture_id. Try 'dpkg-architecture -L']
Maintainer: [Name <email@debian.org>]
Installed-Size: [est. inst. size in bytes, div. By 1024, rounded up]
Pre-Depends: [packages needed before even starting the installation]
Depends: [absolute dependency]
Recommends: [strong, but not absolute, dependency]
Suggests: [one package may be more useful with one or more others]
Enhances: [can enhance the functionality of another package]
Breaks: [will not be unpacked unless other package is deconfigured]
Conflicts: [will not be unpacked in the system at the same time]
Provides: [virtual packages]
Replaces: [overwrites files in other packages or replaces them]
Section: [application area]
Priority: [extra, optional, standard, important, required, essential]
Homepage: [web page]
Description: short description
This is the long description of the package
See: https://www.debian.org/doc/debian-policy/ch-controlfields.html
See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
12 / 36
Relationship with other packages
● Pre-Depends: Forces dpkg to complete installation of the packages named before
even starting the installation of the package which declares the pre-dependency
● Depends: A package will not be configured unless all of the packages listed in its
Depends field have been correctly configured (unless there is a circular
dependency).
●
Recommends: A strong, but not absolute, dependency. Packages that would be
found together with this one in all but unusual installations.
● Suggests: Packages that are related to this one and can perhaps enhance its
usefulness, but that installing this one without them is perfectly reasonable.
● Enhances: Similar to Suggests but works in the opposite direction. A package can
enhance the functionality of another package.
● Breaks: The package won't be unpacked unless the broken package is deconfigured
first, and it will refuse to allow the broken package to be reconfigured.
● Conflicts: The packages won't be unpacked on the system at the same time.
● Replaces: If the overwriting package declares that it Replaces the one containing
the file being overwritten, then dpkg will replace the file from the old package with
that from the new. Normally, Breaks should be used in conjunction with Replaces.
● Provides: A virtual package is one which appears in the Provides control field of
another package. The effect is as if the package(s) which provide a particular virtual
package name had been listed by name everywhere the virtual package name
appears.
See: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles
13 / 36
What are conffiles (DEBIAN/conffiles)?
● List of configuration packages thet dpkg will not overwrite when the package
is upgraded
● Those files are usually placed in /etc/
● To determine exactly which files are preserved during an upgrade, for a
package you have already installed, you can run:
● dpkg ––status <package>
● To see the conffiles in a debian package file, you can do:
● dpkg ––info <file.deb> conffiles
See: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles
14 / 36
Checksums and signatures
● The file DEBIAN/md5sums holded a relationship of all the files included in
data.tar.xz file and their corresponding MD5 checksum once extracted. This
data is not meant for security reasons, because they would be easily
modifiable, but as a way to check if the files have been modified.
● You can use, for example debsums -a <package>, to check if you have
modified a file in your system, that is supposed to be managed by dpkg.
● The security is managed via cryptographic signatures at an APT level, and
not at an individual package level.
● You can sign and verify individual packages via debsigs and debsig-verify, or
dpkg-sig, although I don't think it is too widely spread. I have never tried it.
See: https://www.debian.org/doc/debian-policy/ap-pkg-controlfields.html
See: https://wiki.debian.org/SecureApt
See: http://purplefloyd.wordpress.com/2009/02/05/signing-deb-packages/
15 / 36
Scripts that handle package changes
16 / 36
preinst, postinst, prerm, and postrm scripts
● Preinst: This script executes before that package will be unpacked from its
Debian archive (".deb") file. Many 'preinst' scripts stop services for packages
which are being upgraded until their installation or upgrade is completed.
● Postinst: This script typically completes any required configuration of the
package foo once foo has been unpacked from its Debian archive (".deb")
file. Often, 'postinst' scripts ask the user for input, and/or warn the user that if
they accept default values, they should remember to go back and
reconfigure that package afterwards. Many 'postinst' scripts execute any
commands necessary to start or restart a service once a new package has
been installed or upgraded.
● Prerm: This script typically stops any daemons which are associated with a
package. It is executed before the removal of files associated with the
package.
● Postrm: This script typically modifies links or other files associated with foo,
and/or removes files created by the package.
See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
See: http://www.marga.com.ar/~marga/debian/diagrams/
See: http://people.debian.org/~srivasta/MaintainerScripts.html
17 / 36
Installing a package
18 / 36
Removing a package
19 / 36
Purging a package
20 / 36
Removing and purging a package
21 / 36
Installing an already configured package
22 / 36
Upgrading a package
23 / 36
DPKG Triggers
● Triggers are used to ensure that during the standard package-management
process certain operations always run, but not more than necessary.
● Trigger-using packages can be classified in two behavioral categories:
● Consumers: packages which declare triggers and thus can be
"triggered"
● Producers: packages which activate triggers (explicitly or implicitly)
● When a consumer is triggered, its postinst script is run with the arguments:
● postinst triggered "<trigger1> ... <triggerN>"
See: http://www.seanius.net/blog/2009/09/dpkg-triggers-howto/
See: http://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger
24 / 36
States in which Debian Packages can be
● Not-installed: The package is not installed on your system.
● Config-files: Only the configuration files of the package exist on the system.
● Half-installed: The installation of the package has been started, but not
completed for some reason.
● Unpacked: The package is unpacked, but not configured.
● Half-configured: The package is unpacked and configuration has been
started, but not yet completed for some reason.
● Triggers-awaited: The package awaits trigger processing by another
package.
● Triggers-pending: The package has been triggered.
● Installed: The package is unpacked and configured OK.
25 / 36
Debian Configuration: Debconf
26 / 36
Debian Configuration: Debconf
● Debconf is a backend database, with a frontend that talks to it and presents
an interface to the user. There can be many different types of frontends, from
plain text to a web frontend.
● The frontend also talks to a special config script in the control section of a
debian package, and it can talk to postinst scripts and other scripts as
well, all using a special protocol. These scripts tell the frontend what values
they need from the database, and the frontend asks the user questions to
get those values if they aren't set.
● All the configuration information is stored in a special database that defines
a hierarchy of information. Each package receives its own space in the
hierarchy and is free to use a flat space, or divide its space further into sub-
hierarchies.
● If multiple packages share a common purpose they may use a shared
toplevel hierarchy, preferably with the same name as a shared (virtual)
package name.
● Each variable in the configuration space has some information associated
with it, and it has a value.
See: http://www.fifi.org/doc/debconf-doc/tutorial.html
See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
27 / 36
Debian Configuration: Debconf
28 / 36
Debian Configuration: Debconf
29 / 36
Debconf script: DEBIAN/config
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
. /usr/share/dbconfig-common/dpkg/config.mysql
if ! dbc_go phpmyadmin $@ ; then
echo 'Automatic configuration using dbconfig-common
failed!'
fi
fi
db_version 2.0
db_input high phpmyadmin/reconfigure-webserver || true
if [ ! -f /etc/phpmyadmin/htpasswd.setup ]; then
db_input low phpmyadmin/setup-username || true
db_input low phpmyadmin/setup-password || true
fi
db_go || true
See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
30 / 36
Debconf templates: DEBIAN/templates
Template: hostname
Type: string
Default: debian
Description: unqualified hostname for this computer
This is the name by which this computer will be known on the network.
It
has to be a unique name in your domain.
Template: domain
Type: string
Description: domain for this computer
This is the domain your computer is a member of. Typically it is
something like "mycompany.com" or "myuniversity.edu".
See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
31 / 36
Configuration templates: DEBIAN/templates
● Debconf is a backend database, with a frontend that talks to it and presents
an interface to the user. There can be many different types of frontends, from
plain text to a web frontend.
● The frontend also talks to a special config script in the control section of a
debian package, and it can talk to postinst scripts and other scripts as
well, all using a special protocol. These scripts tell the frontend what values
they need from the database, and the frontend asks the user questions to
get those values if they aren't set.
● All the configuration information is stored in a special database that defines
a hierarchy of information. Each package receives its own space in the
hierarchy and is free to use a flat space, or divide its space further into sub-
hierarchies.
● If multiple packages share a common purpose they may use a shared
toplevel hierarchy, preferably with the same name as a shared (virtual)
package name.
● Each variable in the configuration space has some information associated
with it, and it has a value.
● You can see its contents using the command: debconf-show
See: http://www.fifi.org/doc/debconf-doc/tutorial.html
See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
32 / 36
Debian Configuration: Debconf
● Debconf is a backend database, with a frontend that talks to it and presents
an interface to the user. There can be many different types of frontends, from
plain text to a web frontend.
● The frontend also talks to a special config script in the control section of a
debian package, and it can talk to postinst scripts and other scripts as well,
all using a special protocol. These scripts tell the frontend what values they
need from the database, and the frontend asks the user questions to get
those values if they aren't set.
See: http://www.fifi.org/doc/debconf-doc/tutorial.html
See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
Question time!
34 / 36
Some Links
● Debian Policy Manual:
● https://www.debian.org/doc/debian-policy/
● Basics of the Debian Package Management System:
● https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
● Debian Administrator's Handbook:
● http://debian-handbook.info/browse/stable/sect.manipulating-packages-with-dpkg.html
● Getting Information About Packages with APT:
● http://newbiedoc.sourceforge.net/tutorials/apt-get-intro/info.html
● Maintainer Scripts:
● http://people.debian.org/~srivasta/MaintainerScripts.html
● Debconf Specification:
● https://www.debian.org/doc/packaging-manuals/debconf_specification.html
● The Debconf Programmer's Tutorial
● http://www.fifi.org/doc/debconf-doc/tutorial.html
●
Miriam Ruiz <miriam@debian.org>
Understanding Debian Packages
A very brief introduction to what's inside Debian binary packages
36 / 36
Copyright © 2014, Miriam Ruiz
This work is licensed under the Creative
Commons Attribution-Share Alike 3.0
(CC-by-sa 3.0) license. You can use, copy,
modify, merge, remix, distribute, display,
perform, sublicense and/or sale it freely under
the conditions defined in that license.
See http://creativecommons.org/licenses/by-sa/3.0/

More Related Content

Viewers also liked

Lpi 101 study_guide
Lpi 101 study_guideLpi 101 study_guide
Lpi 101 study_guide
ousman1
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
Acácio Oliveira
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
Acácio Oliveira
 
Linux process management
Linux process managementLinux process management
Linux process management
Raghu nath
 

Viewers also liked (13)

The Gory Details of Debian packages
The Gory Details of Debian packagesThe Gory Details of Debian packages
The Gory Details of Debian packages
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
aptly: Debian repository management tool
aptly: Debian repository management toolaptly: Debian repository management tool
aptly: Debian repository management tool
 
Lpi 101 study_guide
Lpi 101 study_guideLpi 101 study_guide
Lpi 101 study_guide
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 
Installing Software, Part 2: Package Managers
Installing Software, Part 2: Package ManagersInstalling Software, Part 2: Package Managers
Installing Software, Part 2: Package Managers
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
Linux training
Linux trainingLinux training
Linux training
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
 
RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)
 
Linux for Librarians
Linux for LibrariansLinux for Librarians
Linux for Librarians
 
RPM (LINUX)
RPM (LINUX)RPM (LINUX)
RPM (LINUX)
 
Linux process management
Linux process managementLinux process management
Linux process management
 

Similar to Understanding Debian Packages (2014)

Software management in linux
Software management in linuxSoftware management in linux
Software management in linux
nejadmand
 
Debian packaging howto
Debian packaging howtoDebian packaging howto
Debian packaging howto
Ding Zhou
 
Debian packaging talk, Pysheff sept 2012
Debian packaging talk, Pysheff sept 2012Debian packaging talk, Pysheff sept 2012
Debian packaging talk, Pysheff sept 2012
takluyver
 

Similar to Understanding Debian Packages (2014) (20)

How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.
 
Debian Packaging tutorial
Debian Packaging tutorialDebian Packaging tutorial
Debian Packaging tutorial
 
Software management in linux
Software management in linuxSoftware management in linux
Software management in linux
 
$ make install
$ make install$ make install
$ make install
 
Packaging for the Maemo Platform
Packaging for the Maemo PlatformPackaging for the Maemo Platform
Packaging for the Maemo Platform
 
Debian Packaging
Debian PackagingDebian Packaging
Debian Packaging
 
Advanced Usage of the Debian Packaging System
Advanced Usage of the Debian Packaging SystemAdvanced Usage of the Debian Packaging System
Advanced Usage of the Debian Packaging System
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
RHEL Log-files, RPM, Backup & Recovery
RHEL Log-files, RPM, Backup & RecoveryRHEL Log-files, RPM, Backup & Recovery
RHEL Log-files, RPM, Backup & Recovery
 
Debian packaging
Debian packagingDebian packaging
Debian packaging
 
Debian packaging howto
Debian packaging howtoDebian packaging howto
Debian packaging howto
 
Linux Package Management.pptx
Linux Package Management.pptxLinux Package Management.pptx
Linux Package Management.pptx
 
Debian Package Management Simplified
Debian Package Management SimplifiedDebian Package Management Simplified
Debian Package Management Simplified
 
Linux16 RPM
Linux16 RPMLinux16 RPM
Linux16 RPM
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Debian packaging talk, Pysheff sept 2012
Debian packaging talk, Pysheff sept 2012Debian packaging talk, Pysheff sept 2012
Debian packaging talk, Pysheff sept 2012
 
101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management
 
6 - Package Management in Red Hat
6 - Package Management in Red Hat6 - Package Management in Red Hat
6 - Package Management in Red Hat
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 

More from Miriam Ruiz

Planets in our Solar System (2015)
Planets in our Solar System (2015)Planets in our Solar System (2015)
Planets in our Solar System (2015)
Miriam Ruiz
 
El Paradigma de la Cultura Libre (2014)
El Paradigma de la Cultura Libre (2014)El Paradigma de la Cultura Libre (2014)
El Paradigma de la Cultura Libre (2014)
Miriam Ruiz
 
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
Miriam Ruiz
 
UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)
Miriam Ruiz
 
Curso de C++ (2014)
Curso de C++ (2014)Curso de C++ (2014)
Curso de C++ (2014)
Miriam Ruiz
 
El Software Libre: Una visión global (2012)
El Software Libre: Una visión global (2012)El Software Libre: Una visión global (2012)
El Software Libre: Una visión global (2012)
Miriam Ruiz
 
El Sistema Operativo Debian GNU/Linux (2012)
El Sistema Operativo Debian GNU/Linux (2012)El Sistema Operativo Debian GNU/Linux (2012)
El Sistema Operativo Debian GNU/Linux (2012)
Miriam Ruiz
 

More from Miriam Ruiz (20)

MBTI (Myers-Briggs Type Indicator) (doc. v3)
MBTI (Myers-Briggs Type Indicator) (doc. v3)MBTI (Myers-Briggs Type Indicator) (doc. v3)
MBTI (Myers-Briggs Type Indicator) (doc. v3)
 
Patrones de Escalas Musicales (Draft)
Patrones de Escalas Musicales (Draft)Patrones de Escalas Musicales (Draft)
Patrones de Escalas Musicales (Draft)
 
Diagramas de Escalas Musicales (draft)
Diagramas de Escalas Musicales (draft)Diagramas de Escalas Musicales (draft)
Diagramas de Escalas Musicales (draft)
 
Diagramas tonales de acordes musicales (draft)
Diagramas tonales de acordes musicales (draft)Diagramas tonales de acordes musicales (draft)
Diagramas tonales de acordes musicales (draft)
 
Mapas Tonales Musicales [Draft]
Mapas Tonales Musicales [Draft]Mapas Tonales Musicales [Draft]
Mapas Tonales Musicales [Draft]
 
Ukelele Chords Cheat Sheet v2
Ukelele Chords Cheat Sheet v2Ukelele Chords Cheat Sheet v2
Ukelele Chords Cheat Sheet v2
 
Ukelele Chords Cheat Sheet
Ukelele Chords Cheat SheetUkelele Chords Cheat Sheet
Ukelele Chords Cheat Sheet
 
Mujeres en el Software Libre (Campus Party Colombia, 2020)
Mujeres en el Software Libre (Campus Party Colombia, 2020)Mujeres en el Software Libre (Campus Party Colombia, 2020)
Mujeres en el Software Libre (Campus Party Colombia, 2020)
 
MBTI (Myers-Briggs Type Indicator)
MBTI (Myers-Briggs Type Indicator)MBTI (Myers-Briggs Type Indicator)
MBTI (Myers-Briggs Type Indicator)
 
DiSC (Dominance, Influence, Steadiness, Conscientiousness)
DiSC (Dominance, Influence, Steadiness, Conscientiousness)DiSC (Dominance, Influence, Steadiness, Conscientiousness)
DiSC (Dominance, Influence, Steadiness, Conscientiousness)
 
MBTI (Myers-Briggs Type Indicator) [old]
MBTI (Myers-Briggs Type Indicator) [old]MBTI (Myers-Briggs Type Indicator) [old]
MBTI (Myers-Briggs Type Indicator) [old]
 
Mujeres en el Software Libre: El proyecto Debian Women (2015)
Mujeres en el Software Libre: El proyecto Debian Women (2015)Mujeres en el Software Libre: El proyecto Debian Women (2015)
Mujeres en el Software Libre: El proyecto Debian Women (2015)
 
Planets in our Solar System (2015)
Planets in our Solar System (2015)Planets in our Solar System (2015)
Planets in our Solar System (2015)
 
El Paradigma de la Cultura Libre (2014)
El Paradigma de la Cultura Libre (2014)El Paradigma de la Cultura Libre (2014)
El Paradigma de la Cultura Libre (2014)
 
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
Mnemonic Acronym and Mnemonic Images for Object Oriented Principles (2014)
 
UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)
 
Curso de C++ (2014)
Curso de C++ (2014)Curso de C++ (2014)
Curso de C++ (2014)
 
Feminismo en la Red (2013)
Feminismo en la Red (2013)Feminismo en la Red (2013)
Feminismo en la Red (2013)
 
El Software Libre: Una visión global (2012)
El Software Libre: Una visión global (2012)El Software Libre: Una visión global (2012)
El Software Libre: Una visión global (2012)
 
El Sistema Operativo Debian GNU/Linux (2012)
El Sistema Operativo Debian GNU/Linux (2012)El Sistema Operativo Debian GNU/Linux (2012)
El Sistema Operativo Debian GNU/Linux (2012)
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Understanding Debian Packages (2014)

  • 1. Miriam Ruiz <miriam@debian.org> Understanding Debian Packages A very brief introduction to what's inside Debian binary packages
  • 2. 2 / 36 Contents What is a Package? Questions and Answers What's inside a package Relationship between packages The scripts inside the packages Debian Configuration: Debconf
  • 3. 3 / 36 What is a Package?
  • 4. 4 / 36 What is a Package? ● Minimal Unit of Installation and Removal ● A Debian package can include: ● The files needed to provide some functionality to the system (software, artwork, configuration files, program data, etc) ● Some administrative information regarding that package: Description, Dependencies, Maintainer, etc. ● The copyright/licensing information about the contents included in that package, though this can't be read until the package is open. ● Configuration scripts to install/deinstall/upgrade/purge the software ● Checksums to check if the files contained in the file have not been modified. Keep in mind that these are not provided for security against attacks. ● A mechanism (debconf) to configure some parameters about the package.
  • 5. 5 / 36 What can you do with a Package? ● Install it: dpkg ––install <file.deb> ● Show information about it: dpkg ––info <file.deb> ● List its contents: dpkg ––contents <file.deb> ● Extract its files: dpkg ––extract <file.deb> <directory> ● Extract and show files: dpkg ––vextract <file.deb> <directory> ● Lists the installed packages: dpkg ––list <pattern> ● List the files installed from a package: dpkg ––listfiles <package> ● Shows information about a package: dpkg ––print-avail <package> ● Packages where a given filename is found: dpkg ––search <filename> ● Shows the status of a fiven package: dpkg ––status <package> ● Remove package: dpkg ––remove <package> ● Remove it and purge its configuration: sudo dpkg ––purge <package> See: https://www.debian.org/doc/manuals/debian-reference/ch02.en.html
  • 6. 6 / 36 What's inside a Package?
  • 7. 7 / 36 How is a package inside? Files Metadata (aka. DEBIAN) Package
  • 8. 8 / 36 How are these things stored? Package data.tar + compression control.tar + compr.debian-binary 2.0 BSD ar file (uncompressed) See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
  • 9. 9 / 36 How can I extract the contents? ● Extract the archived contents: ar x <file.deb> ● Result: control.tar.gz data.tar.gz debian-binary ● Standards version of the binary package : cat debian-binary ● Which files are distributed: tvfJ data.tar.xz ● Which metadata files are included: tvfz control.tar.gz ● Some files that we can find: control, prerm. postrm, preinst, postinst, shlibs, conffiles, config, templates, md5sums ● It is easier to work with the dpkg-deb command: ● Show information about a package: dpkg ––info <file.deb> ● Show a control field: dpkg ––field <file.deb> <field> ● Show a control file: dpkg ––info <file.deb> <control_file> ● Show the data contents: dpkg ––contents <file.deb> ● Extract all: dpkg ––raw-extract <file.deb> <directory> ● Build a package: dpkg ––build <directory> <directory>
  • 10. 10 / 36 The control data of a package
  • 11. 11 / 36 Control Fields: DEBIAN/control Package: [package name] Version: [version-deb] Architecture: [all or architecture_id. Try 'dpkg-architecture -L'] Maintainer: [Name <email@debian.org>] Installed-Size: [est. inst. size in bytes, div. By 1024, rounded up] Pre-Depends: [packages needed before even starting the installation] Depends: [absolute dependency] Recommends: [strong, but not absolute, dependency] Suggests: [one package may be more useful with one or more others] Enhances: [can enhance the functionality of another package] Breaks: [will not be unpacked unless other package is deconfigured] Conflicts: [will not be unpacked in the system at the same time] Provides: [virtual packages] Replaces: [overwrites files in other packages or replaces them] Section: [application area] Priority: [extra, optional, standard, important, required, essential] Homepage: [web page] Description: short description This is the long description of the package See: https://www.debian.org/doc/debian-policy/ch-controlfields.html See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics
  • 12. 12 / 36 Relationship with other packages ● Pre-Depends: Forces dpkg to complete installation of the packages named before even starting the installation of the package which declares the pre-dependency ● Depends: A package will not be configured unless all of the packages listed in its Depends field have been correctly configured (unless there is a circular dependency). ● Recommends: A strong, but not absolute, dependency. Packages that would be found together with this one in all but unusual installations. ● Suggests: Packages that are related to this one and can perhaps enhance its usefulness, but that installing this one without them is perfectly reasonable. ● Enhances: Similar to Suggests but works in the opposite direction. A package can enhance the functionality of another package. ● Breaks: The package won't be unpacked unless the broken package is deconfigured first, and it will refuse to allow the broken package to be reconfigured. ● Conflicts: The packages won't be unpacked on the system at the same time. ● Replaces: If the overwriting package declares that it Replaces the one containing the file being overwritten, then dpkg will replace the file from the old package with that from the new. Normally, Breaks should be used in conjunction with Replaces. ● Provides: A virtual package is one which appears in the Provides control field of another package. The effect is as if the package(s) which provide a particular virtual package name had been listed by name everywhere the virtual package name appears. See: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles
  • 13. 13 / 36 What are conffiles (DEBIAN/conffiles)? ● List of configuration packages thet dpkg will not overwrite when the package is upgraded ● Those files are usually placed in /etc/ ● To determine exactly which files are preserved during an upgrade, for a package you have already installed, you can run: ● dpkg ––status <package> ● To see the conffiles in a debian package file, you can do: ● dpkg ––info <file.deb> conffiles See: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles
  • 14. 14 / 36 Checksums and signatures ● The file DEBIAN/md5sums holded a relationship of all the files included in data.tar.xz file and their corresponding MD5 checksum once extracted. This data is not meant for security reasons, because they would be easily modifiable, but as a way to check if the files have been modified. ● You can use, for example debsums -a <package>, to check if you have modified a file in your system, that is supposed to be managed by dpkg. ● The security is managed via cryptographic signatures at an APT level, and not at an individual package level. ● You can sign and verify individual packages via debsigs and debsig-verify, or dpkg-sig, although I don't think it is too widely spread. I have never tried it. See: https://www.debian.org/doc/debian-policy/ap-pkg-controlfields.html See: https://wiki.debian.org/SecureApt See: http://purplefloyd.wordpress.com/2009/02/05/signing-deb-packages/
  • 15. 15 / 36 Scripts that handle package changes
  • 16. 16 / 36 preinst, postinst, prerm, and postrm scripts ● Preinst: This script executes before that package will be unpacked from its Debian archive (".deb") file. Many 'preinst' scripts stop services for packages which are being upgraded until their installation or upgrade is completed. ● Postinst: This script typically completes any required configuration of the package foo once foo has been unpacked from its Debian archive (".deb") file. Often, 'postinst' scripts ask the user for input, and/or warn the user that if they accept default values, they should remember to go back and reconfigure that package afterwards. Many 'postinst' scripts execute any commands necessary to start or restart a service once a new package has been installed or upgraded. ● Prerm: This script typically stops any daemons which are associated with a package. It is executed before the removal of files associated with the package. ● Postrm: This script typically modifies links or other files associated with foo, and/or removes files created by the package. See: https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics See: http://www.marga.com.ar/~marga/debian/diagrams/ See: http://people.debian.org/~srivasta/MaintainerScripts.html
  • 17. 17 / 36 Installing a package
  • 18. 18 / 36 Removing a package
  • 19. 19 / 36 Purging a package
  • 20. 20 / 36 Removing and purging a package
  • 21. 21 / 36 Installing an already configured package
  • 22. 22 / 36 Upgrading a package
  • 23. 23 / 36 DPKG Triggers ● Triggers are used to ensure that during the standard package-management process certain operations always run, but not more than necessary. ● Trigger-using packages can be classified in two behavioral categories: ● Consumers: packages which declare triggers and thus can be "triggered" ● Producers: packages which activate triggers (explicitly or implicitly) ● When a consumer is triggered, its postinst script is run with the arguments: ● postinst triggered "<trigger1> ... <triggerN>" See: http://www.seanius.net/blog/2009/09/dpkg-triggers-howto/ See: http://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger
  • 24. 24 / 36 States in which Debian Packages can be ● Not-installed: The package is not installed on your system. ● Config-files: Only the configuration files of the package exist on the system. ● Half-installed: The installation of the package has been started, but not completed for some reason. ● Unpacked: The package is unpacked, but not configured. ● Half-configured: The package is unpacked and configuration has been started, but not yet completed for some reason. ● Triggers-awaited: The package awaits trigger processing by another package. ● Triggers-pending: The package has been triggered. ● Installed: The package is unpacked and configured OK.
  • 25. 25 / 36 Debian Configuration: Debconf
  • 26. 26 / 36 Debian Configuration: Debconf ● Debconf is a backend database, with a frontend that talks to it and presents an interface to the user. There can be many different types of frontends, from plain text to a web frontend. ● The frontend also talks to a special config script in the control section of a debian package, and it can talk to postinst scripts and other scripts as well, all using a special protocol. These scripts tell the frontend what values they need from the database, and the frontend asks the user questions to get those values if they aren't set. ● All the configuration information is stored in a special database that defines a hierarchy of information. Each package receives its own space in the hierarchy and is free to use a flat space, or divide its space further into sub- hierarchies. ● If multiple packages share a common purpose they may use a shared toplevel hierarchy, preferably with the same name as a shared (virtual) package name. ● Each variable in the configuration space has some information associated with it, and it has a value. See: http://www.fifi.org/doc/debconf-doc/tutorial.html See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
  • 27. 27 / 36 Debian Configuration: Debconf
  • 28. 28 / 36 Debian Configuration: Debconf
  • 29. 29 / 36 Debconf script: DEBIAN/config #!/bin/sh set -e . /usr/share/debconf/confmodule if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then . /usr/share/dbconfig-common/dpkg/config.mysql if ! dbc_go phpmyadmin $@ ; then echo 'Automatic configuration using dbconfig-common failed!' fi fi db_version 2.0 db_input high phpmyadmin/reconfigure-webserver || true if [ ! -f /etc/phpmyadmin/htpasswd.setup ]; then db_input low phpmyadmin/setup-username || true db_input low phpmyadmin/setup-password || true fi db_go || true See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
  • 30. 30 / 36 Debconf templates: DEBIAN/templates Template: hostname Type: string Default: debian Description: unqualified hostname for this computer This is the name by which this computer will be known on the network. It has to be a unique name in your domain. Template: domain Type: string Description: domain for this computer This is the domain your computer is a member of. Typically it is something like "mycompany.com" or "myuniversity.edu". See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
  • 31. 31 / 36 Configuration templates: DEBIAN/templates ● Debconf is a backend database, with a frontend that talks to it and presents an interface to the user. There can be many different types of frontends, from plain text to a web frontend. ● The frontend also talks to a special config script in the control section of a debian package, and it can talk to postinst scripts and other scripts as well, all using a special protocol. These scripts tell the frontend what values they need from the database, and the frontend asks the user questions to get those values if they aren't set. ● All the configuration information is stored in a special database that defines a hierarchy of information. Each package receives its own space in the hierarchy and is free to use a flat space, or divide its space further into sub- hierarchies. ● If multiple packages share a common purpose they may use a shared toplevel hierarchy, preferably with the same name as a shared (virtual) package name. ● Each variable in the configuration space has some information associated with it, and it has a value. ● You can see its contents using the command: debconf-show See: http://www.fifi.org/doc/debconf-doc/tutorial.html See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
  • 32. 32 / 36 Debian Configuration: Debconf ● Debconf is a backend database, with a frontend that talks to it and presents an interface to the user. There can be many different types of frontends, from plain text to a web frontend. ● The frontend also talks to a special config script in the control section of a debian package, and it can talk to postinst scripts and other scripts as well, all using a special protocol. These scripts tell the frontend what values they need from the database, and the frontend asks the user questions to get those values if they aren't set. See: http://www.fifi.org/doc/debconf-doc/tutorial.html See: https://www.debian.org/doc/packaging-manuals/debconf_specification.html
  • 34. 34 / 36 Some Links ● Debian Policy Manual: ● https://www.debian.org/doc/debian-policy/ ● Basics of the Debian Package Management System: ● https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics ● Debian Administrator's Handbook: ● http://debian-handbook.info/browse/stable/sect.manipulating-packages-with-dpkg.html ● Getting Information About Packages with APT: ● http://newbiedoc.sourceforge.net/tutorials/apt-get-intro/info.html ● Maintainer Scripts: ● http://people.debian.org/~srivasta/MaintainerScripts.html ● Debconf Specification: ● https://www.debian.org/doc/packaging-manuals/debconf_specification.html ● The Debconf Programmer's Tutorial ● http://www.fifi.org/doc/debconf-doc/tutorial.html ●
  • 35. Miriam Ruiz <miriam@debian.org> Understanding Debian Packages A very brief introduction to what's inside Debian binary packages
  • 36. 36 / 36 Copyright © 2014, Miriam Ruiz This work is licensed under the Creative Commons Attribution-Share Alike 3.0 (CC-by-sa 3.0) license. You can use, copy, modify, merge, remix, distribute, display, perform, sublicense and/or sale it freely under the conditions defined in that license. See http://creativecommons.org/licenses/by-sa/3.0/