SlideShare a Scribd company logo
1 of 27
Download to read offline
Debian packaging
…because you’re worth it
Why “Debian” packaging?
Debian packaging:
● dpkg for package creation/installation
● apt for package downloading and dependency handling
● aptitude as a higher-level version of apt
● arguably the best package management system in Linux
All Debian-derivative distros use this!
Ubuntu, Lubuntu, Kubuntu, Edubuntu, Xubuntu, Knoppix, Raspbian, Mint, LXLE, Elementary OS, Kali Linux, SteamOS,
Tails, Gparted Live, Elive, Proxmox, Grml….
Come on and type-a-long!
- Debian/Ubuntu box?
- local env in VM/Vagrant?
in any case:
apt-get install git fakeroot lintian tree
What does a Debian package look like?
Let’s download one.
[name]_[version-distroversion]_[architecture].deb
What does a Debian package contain?
Let’s check the contents
…
…
It’s a compressed group of files.
And they are pre-cooked! (installation path, owner, permissions)
But that’s NOT everything in the package...
I wanna look closer!
Let’s unpack it
I wanna look closer!
Let’s unpack it
Control files:
● Package metadata
● Maintainer’s scripts
I wanna look closer!
Let’s unpack it
Data files:
● Actual content
● We already know what this is (remember “dpkg -c” ? Two slides earlier?)
I wanna look closer!
Let’s unpack it
Format version:
● Contains which version of the Debian package format this package is using
(it only contains “2.0”)
● You’ll probably never see something else. No need to worry about this.
control.tar.gz
control.tar.gz The main metadata file. All info about the package is here.
Package: fail2ban
Version: 0.9.1-1
Architecture: all
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Yaroslav Halchenko <debian@onerussian.com>
Installed-Size: 1075
Depends: python3, python3:any (>= 3.3.2-2~), init-system-helpers (>= 1.18~), lsb-base (>= 2.0-
7)
Recommends: iptables, whois, python3-pyinotify
Suggests: mailx, system-log-daemon, python3-systemd
Section: net
Priority: optional
Homepage: http://www.fail2ban.org
Description: ban hosts that cause multiple authentication errors
Fail2ban monitors log files (e.g. /var/log/auth.log,
/var/log/apache/access.log) and temporarily or persistently bans
failure-prone addresses by updating existing firewall rules. Fail2ban allows
easy specification of different actions to be taken such as to ban an
IP using iptables or hostsdeny rules, or simply to send a
notification email.
control.tar.gz md5 checksums. Automatically created.
56ce6f9298838bcc3a9f0ba3e67c2917 lib/systemd/system/fail2ban.service
3a318374fa0cb6e07a292b7cdc97f50d usr/bin/fail2ban-client
72d77e966ca17f474de6daef24f83760 usr/bin/fail2ban-regex
0c2a078af6af4bc3fc4ad30e427bee3e usr/bin/fail2ban-server
86c43074af44dccc268750fa7b6f8b05 usr/bin/fail2ban-testcases
2b87fac05ca20d8c82b2dc8039b7e84d usr/lib/python3/dist-packages/fail2ban-0.9.1.egg-info
063c94472e76bee8522af76c7bb83043 usr/lib/python3/dist-packages/fail2ban/__init__.py
1462fa8f21229ca8ce838cad186607d8 usr/lib/python3/dist-packages/fail2ban/client/__init__.py
43c78526e2c53e278c222bfa0203ebca usr/lib/python3/dist-packages/fail2ban/client/actionreader.py
5d3747e822e520751afda04b331670d9 usr/lib/python3/dist-packages/fail2ban/client/beautifier.py
ced2218bc0120e247db682e838c1ad57 usr/lib/python3/dist-
packages/fail2ban/client/configparserinc.py
0ad1ac6cc7d6ccbc7f8fb509d01d6e1e usr/lib/python3/dist-packages/fail2ban/client/configreader.py
b25882f7c058745aaba76c7336cd7dad usr/lib/python3/dist-packages/fail2ban/client/configurator.py
f0fd3691740ec8bc93a74d65e324c35c usr/lib/python3/dist-packages/fail2ban/client/csocket.py
control.tar.gz Maintainer scripts. Executed when installing or removing the package.
● preinst:
- executed before installation starts
- maybe clear prev installation leftovers?
● postinst:
- executed as last step of installation
- e.g. change ownership/perms, start service
● prerm:
- first step in package removal
- e.g. stop service
● postrm:
- last step in package removal
- e.g. remove logs
control.tar.gz List of configuration files.
Usually anything that resides in /etc
Special rules for these files:
If changed, DO NOT OVERWRITE during package upgrade.
(nobody wants to lose custom configuration after upgrade)
...
/etc/fail2ban/action.d/sendmail-common.conf
/etc/fail2ban/action.d/xarf-login-attack.conf
/etc/fail2ban/action.d/iptables.conf
/etc/fail2ban/action.d/sendmail-whois-lines.conf
/etc/fail2ban/action.d/sendmail-whois-ipjailmatches.conf
/etc/fail2ban/action.d/sendmail-whois-ipmatches.conf
/etc/fail2ban/action.d/ipfw.conf
/etc/fail2ban/action.d/apf.conf
/etc/fail2ban/action.d/badips.conf
/etc/fail2ban/action.d/mail-buffered.conf
/etc/fail2ban/action.d/iptables-ipset-proto6-allports.conf
/etc/fail2ban/action.d/iptables-multiport-log.conf
/etc/fail2ban/action.d/sendmail-buffered.conf
/etc/fail2ban/action.d/osx-afctl.conf
/etc/fail2ban/action.d/dummy.conf
...
data.tar.gz
data.tar.gz Files to be installed.
Full path is included.
Just ignore the . at the beginning of each file.
Also, permissions!
$ ls -lat etc/fail2ban/*.conf
-rw-r--r-- 1 dtsomp dtsomp 2104 okt 28 2014 etc/fail2ban/fail2ban.conf
-rw-r--r-- 1 dtsomp dtsomp 16866 okt 28 2014 etc/fail2ban/jail.conf
What about the owner?
“fakeroot” assigns root as owner during the creation of the package.
Or, we don’t care at all and just fix it via postinst ;)
Enough theory.
Let’s build something.
1. git it!
Clone the packaging tutorial repo
DEBIAN/ control files
DOC/ documentation (man page, licence, etc)
ROOT/ the directory structure with the actual files
target/ will contain the final package
Why not put DOC/* under ROOT, like Debian asks you to?
- Too lazy to find and update files every time. Script copies them over for me.
2. Prepare installation files
Create dir and place the file
Don’t forget the permissions!
0755 for executables, 0644 for others
Is it a configuration file?
Needs to be added in conffiles
3. Metadata and maintainer scripts
Do you need to update the package information?
YES! At least change the name of the package!
Make sure the maintainer’s scripts are up-to-date.
It’s mandatory to have postinst and prerm scripts, even if they don’t do anything
Optional steps:
You know what is cool? Changelogs!
Any changes in copyright or the manual page?
4. Build time?
Wait, wait, wait.
What does this script do?
All the boring bits:
- preflight checks
- creates dir structure
- copies doc, metadata and content (ROOT) to the correct places in the structure
- fixes permissions
- compresses files (yes, some need to be compressed)
- creates the actual package
The actual build command (once everything is in place):
fakeroot makes root owner of all files in the package, no sudo needed:
5. Build it already!
Congratulations!
It’s a package!
Or is it?
6. Basic conformity check
…
Zero? Woohoo! No Errors!
Warnings are OK. But you need to fix Errors.
Now install it!
Did everything went according to plan? :)
Conclusions
We built a Debian package!
Is it a *proper* package?
No.
(unsigned, bad changelog format, etc)
Is it a *good enough* package?
Hell yeah!
Reference checklist (copied from http://www.tldp.org)
Prerequisite files:
1. one or more binary executable or shell script files
2. a man page for each executable file
3. a 'control' file
4. a 'copyright' file
5. a 'changelog' and 'changelog.Debian' file
Setup temporary 'debian' directories:
1. create 'debian/usr/bin' directory (or wherever you plan to place your executable files)
2. create 'debian/usr/share/man/man1' (or whatever section your man page belongs into)
3. create 'debian/DEBIAN' directory
4. create 'debian/usr/share/doc/<package_name>'
5. make sure all sub directories of 'debian' have file permission 0755
Copy files into temporary 'debian' tree:
1. copy executable file into 'debian/usr/bin' directory (or wherever you plan to place your executable files)
2. copy man page file into 'debian/usr/share/man/man1' directory
3. copy 'control' file into 'debian/DEBIAN' directory
4. copy 'copyright', 'changelog', and 'changelog.Debian' files into 'debian/usr/share/doc/<package_name>'
5. gzip man page, 'copyright', 'changelog', and 'changelog.Debian' files with option '--best' inside the temporary 'debian' tree
Build and check binary Debian package:
1. invoke 'dpkg-deb --build' using 'fakeroot' on the 'debian' directory
2. rename resulting 'debian.deb' file to its final package name including version and architecture information
3. check resulting .deb package file for Debian policy compliance using 'lintian'
Reference cheatsheet
●
●
●
●
●
●
EOM

More Related Content

What's hot

Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...Edureka!
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxQIANG XU
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyAndré Rømcke
 
One click deployment
One click deploymentOne click deployment
One click deploymentAlex Su
 
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.İbrahim UÇAR
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPressdotCloud
 
Debian source list generator
Debian source list generatorDebian source list generator
Debian source list generatorJessalynCo
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Ahmed El-Arabawy
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deployfcrippa
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012Carlos Sanchez
 
Linux Getting Started
Linux Getting StartedLinux Getting Started
Linux Getting StartedAngus Li
 
Single node hadoop cluster installation
Single node hadoop cluster installation Single node hadoop cluster installation
Single node hadoop cluster installation Mahantesh Angadi
 
Distro Recipes 2013 : Debian and quality assurance
Distro Recipes 2013 : Debian and quality assuranceDistro Recipes 2013 : Debian and quality assurance
Distro Recipes 2013 : Debian and quality assuranceAnne Nicolas
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command linedotCloud
 

What's hot (20)

Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
UNIX Basics and Cluster Computing
UNIX Basics and Cluster ComputingUNIX Basics and Cluster Computing
UNIX Basics and Cluster Computing
 
One click deployment
One click deploymentOne click deployment
One click deployment
 
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.
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
Debian source list generator
Debian source list generatorDebian source list generator
Debian source list generator
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
Belvedere
BelvedereBelvedere
Belvedere
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deploy
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Linux Getting Started
Linux Getting StartedLinux Getting Started
Linux Getting Started
 
Single node hadoop cluster installation
Single node hadoop cluster installation Single node hadoop cluster installation
Single node hadoop cluster installation
 
Distro Recipes 2013 : Debian and quality assurance
Distro Recipes 2013 : Debian and quality assuranceDistro Recipes 2013 : Debian and quality assurance
Distro Recipes 2013 : Debian and quality assurance
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
 

Similar to Debian packaging

Debian Packaging tutorial
Debian Packaging tutorialDebian Packaging tutorial
Debian Packaging tutorialnussbauml
 
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)Thierry Gayet
 
The Gory Details of Debian packages
The Gory Details of Debian packagesThe Gory Details of Debian packages
The Gory Details of Debian packagesJeremiah Foster
 
Packaging for the Maemo Platform
Packaging for the Maemo PlatformPackaging for the Maemo Platform
Packaging for the Maemo PlatformJeremiah Foster
 
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 managementAcácio Oliveira
 
Raspberry zero usb in linux
Raspberry zero usb in linuxRaspberry zero usb in linux
Raspberry zero usb in linuxGSHCO
 
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 managementAcácio Oliveira
 
101 2.4b use debian package management v2
101 2.4b use debian package management v2101 2.4b use debian package management v2
101 2.4b use debian package management v2Acácio Oliveira
 
2.4.1 use debian package management v2
2.4.1 use debian package management v22.4.1 use debian package management v2
2.4.1 use debian package management v2Acácio Oliveira
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wikishahab071
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux TroubleshootingKeith Wright
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologistAjay Murali
 
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 managementAcácio Oliveira
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
04 02-2018--Slackware Wire Shark Installation
04 02-2018--Slackware Wire Shark Installation04 02-2018--Slackware Wire Shark Installation
04 02-2018--Slackware Wire Shark InstallationAlexander Bitar
 
Software management in linux
Software management in linuxSoftware management in linux
Software management in linuxnejadmand
 

Similar to Debian packaging (20)

Debian Packaging tutorial
Debian Packaging tutorialDebian Packaging tutorial
Debian Packaging tutorial
 
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)
 
The Gory Details of Debian packages
The Gory Details of Debian packagesThe Gory Details of Debian packages
The Gory Details of Debian packages
 
Packaging for the Maemo Platform
Packaging for the Maemo PlatformPackaging for the Maemo Platform
Packaging for the Maemo Platform
 
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
 
Raspberry zero usb in linux
Raspberry zero usb in linuxRaspberry zero usb in linux
Raspberry zero usb in linux
 
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
 
101 2.4b use debian package management v2
101 2.4b use debian package management v2101 2.4b use debian package management v2
101 2.4b use debian package management v2
 
2.4.1 use debian package management v2
2.4.1 use debian package management v22.4.1 use debian package management v2
2.4.1 use debian package management v2
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
RPM Packaging 101 (Old)
RPM Packaging 101 (Old)RPM Packaging 101 (Old)
RPM Packaging 101 (Old)
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologist
 
Sahu
SahuSahu
Sahu
 
File system discovery
File system discovery File system discovery
File system discovery
 
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
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
04 02-2018--Slackware Wire Shark Installation
04 02-2018--Slackware Wire Shark Installation04 02-2018--Slackware Wire Shark Installation
04 02-2018--Slackware Wire Shark Installation
 
Software management in linux
Software management in linuxSoftware management in linux
Software management in linux
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Debian packaging

  • 2. Why “Debian” packaging? Debian packaging: ● dpkg for package creation/installation ● apt for package downloading and dependency handling ● aptitude as a higher-level version of apt ● arguably the best package management system in Linux All Debian-derivative distros use this! Ubuntu, Lubuntu, Kubuntu, Edubuntu, Xubuntu, Knoppix, Raspbian, Mint, LXLE, Elementary OS, Kali Linux, SteamOS, Tails, Gparted Live, Elive, Proxmox, Grml….
  • 3. Come on and type-a-long! - Debian/Ubuntu box? - local env in VM/Vagrant? in any case: apt-get install git fakeroot lintian tree
  • 4. What does a Debian package look like? Let’s download one. [name]_[version-distroversion]_[architecture].deb
  • 5. What does a Debian package contain? Let’s check the contents … … It’s a compressed group of files. And they are pre-cooked! (installation path, owner, permissions) But that’s NOT everything in the package...
  • 6. I wanna look closer! Let’s unpack it
  • 7. I wanna look closer! Let’s unpack it Control files: ● Package metadata ● Maintainer’s scripts
  • 8. I wanna look closer! Let’s unpack it Data files: ● Actual content ● We already know what this is (remember “dpkg -c” ? Two slides earlier?)
  • 9. I wanna look closer! Let’s unpack it Format version: ● Contains which version of the Debian package format this package is using (it only contains “2.0”) ● You’ll probably never see something else. No need to worry about this.
  • 11. control.tar.gz The main metadata file. All info about the package is here. Package: fail2ban Version: 0.9.1-1 Architecture: all Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Yaroslav Halchenko <debian@onerussian.com> Installed-Size: 1075 Depends: python3, python3:any (>= 3.3.2-2~), init-system-helpers (>= 1.18~), lsb-base (>= 2.0- 7) Recommends: iptables, whois, python3-pyinotify Suggests: mailx, system-log-daemon, python3-systemd Section: net Priority: optional Homepage: http://www.fail2ban.org Description: ban hosts that cause multiple authentication errors Fail2ban monitors log files (e.g. /var/log/auth.log, /var/log/apache/access.log) and temporarily or persistently bans failure-prone addresses by updating existing firewall rules. Fail2ban allows easy specification of different actions to be taken such as to ban an IP using iptables or hostsdeny rules, or simply to send a notification email.
  • 12. control.tar.gz md5 checksums. Automatically created. 56ce6f9298838bcc3a9f0ba3e67c2917 lib/systemd/system/fail2ban.service 3a318374fa0cb6e07a292b7cdc97f50d usr/bin/fail2ban-client 72d77e966ca17f474de6daef24f83760 usr/bin/fail2ban-regex 0c2a078af6af4bc3fc4ad30e427bee3e usr/bin/fail2ban-server 86c43074af44dccc268750fa7b6f8b05 usr/bin/fail2ban-testcases 2b87fac05ca20d8c82b2dc8039b7e84d usr/lib/python3/dist-packages/fail2ban-0.9.1.egg-info 063c94472e76bee8522af76c7bb83043 usr/lib/python3/dist-packages/fail2ban/__init__.py 1462fa8f21229ca8ce838cad186607d8 usr/lib/python3/dist-packages/fail2ban/client/__init__.py 43c78526e2c53e278c222bfa0203ebca usr/lib/python3/dist-packages/fail2ban/client/actionreader.py 5d3747e822e520751afda04b331670d9 usr/lib/python3/dist-packages/fail2ban/client/beautifier.py ced2218bc0120e247db682e838c1ad57 usr/lib/python3/dist- packages/fail2ban/client/configparserinc.py 0ad1ac6cc7d6ccbc7f8fb509d01d6e1e usr/lib/python3/dist-packages/fail2ban/client/configreader.py b25882f7c058745aaba76c7336cd7dad usr/lib/python3/dist-packages/fail2ban/client/configurator.py f0fd3691740ec8bc93a74d65e324c35c usr/lib/python3/dist-packages/fail2ban/client/csocket.py
  • 13. control.tar.gz Maintainer scripts. Executed when installing or removing the package. ● preinst: - executed before installation starts - maybe clear prev installation leftovers? ● postinst: - executed as last step of installation - e.g. change ownership/perms, start service ● prerm: - first step in package removal - e.g. stop service ● postrm: - last step in package removal - e.g. remove logs
  • 14. control.tar.gz List of configuration files. Usually anything that resides in /etc Special rules for these files: If changed, DO NOT OVERWRITE during package upgrade. (nobody wants to lose custom configuration after upgrade) ... /etc/fail2ban/action.d/sendmail-common.conf /etc/fail2ban/action.d/xarf-login-attack.conf /etc/fail2ban/action.d/iptables.conf /etc/fail2ban/action.d/sendmail-whois-lines.conf /etc/fail2ban/action.d/sendmail-whois-ipjailmatches.conf /etc/fail2ban/action.d/sendmail-whois-ipmatches.conf /etc/fail2ban/action.d/ipfw.conf /etc/fail2ban/action.d/apf.conf /etc/fail2ban/action.d/badips.conf /etc/fail2ban/action.d/mail-buffered.conf /etc/fail2ban/action.d/iptables-ipset-proto6-allports.conf /etc/fail2ban/action.d/iptables-multiport-log.conf /etc/fail2ban/action.d/sendmail-buffered.conf /etc/fail2ban/action.d/osx-afctl.conf /etc/fail2ban/action.d/dummy.conf ...
  • 16. data.tar.gz Files to be installed. Full path is included. Just ignore the . at the beginning of each file. Also, permissions! $ ls -lat etc/fail2ban/*.conf -rw-r--r-- 1 dtsomp dtsomp 2104 okt 28 2014 etc/fail2ban/fail2ban.conf -rw-r--r-- 1 dtsomp dtsomp 16866 okt 28 2014 etc/fail2ban/jail.conf What about the owner? “fakeroot” assigns root as owner during the creation of the package. Or, we don’t care at all and just fix it via postinst ;)
  • 18. 1. git it! Clone the packaging tutorial repo DEBIAN/ control files DOC/ documentation (man page, licence, etc) ROOT/ the directory structure with the actual files target/ will contain the final package Why not put DOC/* under ROOT, like Debian asks you to? - Too lazy to find and update files every time. Script copies them over for me.
  • 19. 2. Prepare installation files Create dir and place the file Don’t forget the permissions! 0755 for executables, 0644 for others Is it a configuration file? Needs to be added in conffiles
  • 20. 3. Metadata and maintainer scripts Do you need to update the package information? YES! At least change the name of the package! Make sure the maintainer’s scripts are up-to-date. It’s mandatory to have postinst and prerm scripts, even if they don’t do anything Optional steps: You know what is cool? Changelogs! Any changes in copyright or the manual page?
  • 21. 4. Build time? Wait, wait, wait. What does this script do? All the boring bits: - preflight checks - creates dir structure - copies doc, metadata and content (ROOT) to the correct places in the structure - fixes permissions - compresses files (yes, some need to be compressed) - creates the actual package The actual build command (once everything is in place): fakeroot makes root owner of all files in the package, no sudo needed:
  • 22. 5. Build it already! Congratulations! It’s a package! Or is it?
  • 23. 6. Basic conformity check … Zero? Woohoo! No Errors! Warnings are OK. But you need to fix Errors. Now install it! Did everything went according to plan? :)
  • 24. Conclusions We built a Debian package! Is it a *proper* package? No. (unsigned, bad changelog format, etc) Is it a *good enough* package? Hell yeah!
  • 25. Reference checklist (copied from http://www.tldp.org) Prerequisite files: 1. one or more binary executable or shell script files 2. a man page for each executable file 3. a 'control' file 4. a 'copyright' file 5. a 'changelog' and 'changelog.Debian' file Setup temporary 'debian' directories: 1. create 'debian/usr/bin' directory (or wherever you plan to place your executable files) 2. create 'debian/usr/share/man/man1' (or whatever section your man page belongs into) 3. create 'debian/DEBIAN' directory 4. create 'debian/usr/share/doc/<package_name>' 5. make sure all sub directories of 'debian' have file permission 0755 Copy files into temporary 'debian' tree: 1. copy executable file into 'debian/usr/bin' directory (or wherever you plan to place your executable files) 2. copy man page file into 'debian/usr/share/man/man1' directory 3. copy 'control' file into 'debian/DEBIAN' directory 4. copy 'copyright', 'changelog', and 'changelog.Debian' files into 'debian/usr/share/doc/<package_name>' 5. gzip man page, 'copyright', 'changelog', and 'changelog.Debian' files with option '--best' inside the temporary 'debian' tree Build and check binary Debian package: 1. invoke 'dpkg-deb --build' using 'fakeroot' on the 'debian' directory 2. rename resulting 'debian.deb' file to its final package name including version and architecture information 3. check resulting .deb package file for Debian policy compliance using 'lintian'
  • 27. EOM