Deb is the Debian package or as an ‘installer’ for Debian-based distributions. There are two types of Debian packages, both with the same functionality to implement certain command, resource or resources.
I will address the creation of a Debian binary package, which is the most used between the two types of packages. Consists of multiple executables, configuration files, manual pages, proprietary information, and other documentation. Packages are commonly found with the extension ‘. Deb’.
- It should create a folder to contain the files related to the package.
- The Debian package is mainly composed of a folder named DEBIAN, which will control scripts and file.
- The control file which contains all the needs and requirements for the implementation and installation of the package. Just like the name, version, description, among others.
- The scripts are not necessary but are often used in the DEBIAN folder you can create scripts to before starting the installation (preinst) and removal (prerm), and after installation (postinst) and removal (postrm) . These files are commonly written in shell script.
On a Debian package is also possible to put certain files in certain folders. Just putting the folder with your name exactly as it will be in the folder and its path.
To illustrate, we will create a package for running a PHP.
Assuming that the name of our package is examplePHPDEB, the framework for creating it would be:
We create the package folder DEB examplePHPDEB , within the same, be the folder DEBIAN where scripts are run, to be executed during package installation, and file control having the package configurations.
Also our PHP file to be executed. Exactly in the folder where it should stay. is placed on the structure of the package the exact path where will be the same after installation, in our example the example.php file is in / var / www / example.php
The control file is the most important file of creating the DEB package, without it, you can not create the package. In this file will be stored packet data created, such as name, version, description, dependencies, Maintainer, among others.
A Control file can be composed as follows, within the DEBIAN folder.
Maintainer: <http://www.viniciusmuniz.com> Vinícius Muniz
Depends: php5 (> = 5.2.1), apache2 (> = 2.2.3), php5-gd, php5-sqlite
Description: Package example, to execute a php file
To run scripts before or after installing the package, you can use the files in the folder DEBIAN:
- Preinst – Executed before beginning installation;
- postinst – Executed after the end of the installation;
- prerm – Executed before removal;
- postrm – Executed after removal
The scripts follow the same pattern. Using bash, sh, or ksh. Or if you know “make mallets”, you can use php, c, c + +, it would be a matter of making the call to the file with other language within the package scripts.
In our example there is no need to use one of these scripts. But we will use to create a menu icon to open the browser with the php file being executed.
#! / Bin / sh
# Copyright (c) 2010 The Authors <https://viniciusmuniz.com> Vinicius Muniz. All rights reserved.
# Add icons to all users.
User is in $ (ls / home), the
if [ ! -d /home/$usuario/.local/share/applications ]; then
cp /usr/share/applications/examplePHPDEB.desktop /home/$user/.local/share/applications
To use this script, we will create another file with the name examplePHPDEB.desktop where we will store the data shortcut. The file will be stored within / usr / share / applications / within the package, and after installation in the same way inside the server. [ 3×1002]
The contents of the shortcut will be: For the implementation of our file we will create another file in shell to open the browser with PHP script running. . The file is specified in the Exec desktop file will be the start.sh file, its content will be: After creating the entire structure, and edit all the scripts we want, we really have. Deb. We will use the command dpkg-deb . With the syntax: Okay, with that, we will DEB package generated and to execute the same, we can use the command
The contents of the shortcut will be:
For the implementation of our file we will create another file in shell to open the browser with PHP script running. . The file is specified in the Exec desktop file will be the start.sh file, its content will be:
After creating the entire structure, and edit all the scripts we want, we really have. Deb.
We will use the command dpkg-deb . With the syntax:
Okay, with that, we will DEB package generated
and to execute the same, we can use the command