Deb-package repository with their own hands: Assembling packages in Debian from sources and binaries on an ambulance hand. Creating Debian Installation Files - Deb Files Collect Deb Package

→ Deb package assembly instructions

There are no little articles on the network about how to assemble a Deb package, but unfortunately not all of them will be understood for the developer who decided to make an assembly for the first time. So, you have a code. It is useful, good, but requires some skills and effort when installing on a server or desktop. To avoid handmade associated with copying files, manipulations with a database, setting the start-stop scripts (for demons) and configure configuration, you decided to collect everything in the Deb package.

Ideally, the correct Deb package must be signed by a GPG key. Otherwise, APT will read the package unreliable and will issue a relevant warning. But we will miss this part. Manual about how to create a GPG key and how to sign a DEB package GPG-key Consider later.

Step 1. Install utilities that will be required to build your package.:

Sudo Apt-Get Install Autoconf Automake Libtool AutoTools-Dev Dpkg-Dev Fakeroot

Step 2. Create a root directory for the future package and copy all the files of your utility to this directory, which will be required for operation and installation. For example:

MKDIR -P / MY_PACKAGE CP / SOME_SOURCE_FILES / Home / UserName / DEB / My_Package

If your utility will be in the folder:

USR / LOCAL / SHARE / MY_PROJECT

/ home / username / deb / My_package / USR / Local / Share / My_Project

Step 3. Create a Debian directory in the root of the packet.

The catalog name must consist of capital letters. This directory contains meta-information that is used during installation.

CD / Home / Username / DEB / My_Package Mkdir Debian

Next, in the catalog Debian.create mandatory text file - control. IN this file Basic information about the package. In the file, each string contains a key-value pair, separated by colon.

CD ./Debian Touch Control

File example:

Package: My-Package Version: 1.0.0 Provides: My-Package Maintainer: Vasiliy Batareikin Architecture: All Section: Web Priority: Optional Pre-Depends: GCC, Make, Perl (\u003e \u003d 5.10), MySQL-Server Depends: GCC, Make, Perl (\u003e \u003d 5.10), Perlmagick, MySQL-Server, Unzip, Rar Description : My First Debian Package

Package. - Package name. Permissible characters. Mandatory parameter.

Version. - Package version. Mandatory parameter.

Provides. - The name of the application is registered in the system.

Maintainer. - The name and mail of the package of the package. Mandatory parameter.

Architecture - The processor architecture for which the package is designed. Mandatory parameter.

Section. - Determines the group of applications. Mandatory parameter.

Priority. - Package priority. The parameter determines how important your package in the system is.

Pre-Depends. - List of packages through the comma, which are needed during the installation of your package. Packet Manager automatically pretty specified packages.

Depends. - List of packages through the comma, which are required to work this package. Packet Manager automatically pretty specified packages.

Description. - Description of the package. Mandatory parameter.

If you want to perform certain actions when installing or deleting a package, you can use special scripts. Create them and put the rights to execution:

CD ./Debian Touch Preinst Postinst Prerm Postrm Chmod 775 Preinst Postinst Prerm Postrm

preinst - Performed before installing the package.

postinst - Permanently after installing the package.

prerm. - Performed immediately before removing the package.

postrm. - It is performed immediately after deleting the package.


Step 4.. Assembling package.

We rise to one level with the root folder of the package and perform the assembly.


Posted by: Michael Reed
Publication date: January 4, 2014
Translation: N.Romodanov
Translation Date: June 2014

We will tell you how to create two most common types. linux packages For distribution softwareAnd you can distribute your own packages yourself.

We are going to conduct you through the process of creating software packages for the two most popular DEB and RPM package systems. You can use these methods to create packages of your own software or even accompany packages for the software that you consider remains unnoticed.

We will begin with a DEB ((.deb) file creation manual for distributions derived from Debian - for this we use the quality of our database. After that, we describe the methods necessary for creating RPM packages for use in distributions derived from Red Hat. And for this we will use Fedora. Often you can create a package on one distribution, and then install it on a related distribution (for example, Ubuntu\u003e Debian), but if it is important, then you may have to try it yourself.

As for the program, we are going as an example of a package collected from the source code, use the Light Web Browser Dillo. When the assembly is executed from the source texts, in case the assembly does not go out, you can, as usual, look for solutions on the Internet. For example, in the case of DILLO 3.0.3, we had to add commands to the command to add "libs \u003d -lx11" due to the absence of the source code in the original code archive.

The assembly occurs on the command line

Resources

Installation (or virtual machine) Ubuntu and Fedora

Step by step description

Step 01: Using a virtual machine

The use of virtualization tools, such as VirtualBox or VMware, is often the best approach to creating packages for other systems. On the one hand, this approach allows you to maintain a relatively clean basic installation comparable to the settings that others will probably work. It also means that you use various distributions, you can get a collection of target systems. In addition, most virtualization tools allow emulate various architectures, and, therefore, a 64-bit OS can be launched on a 32-bit platform, although performance will suffer.

Step 02: Start from scratch

If something is wrong in Ubuntu or Fedora, you can completely safely simply delete the source directory and start all over again. Please note that Debian's tool means change the original archive, so you have to start with a new copy.

Part 1: Debian

Step 03: Install the assembly environment

We will start with the installation of most toolsWe need to create programs from source code. Type:

$ sudo APT-Get Install Build-Essential Autoconf Automake AutoTools-Dev

Now we must set the tools that are used to work with DEB packages. Do it with the following command ...

$ Sudo Apt-Get Install DH-Make Debhelper Devscripts Fakeroot Xutils Lintian Pbuilder

Step 04: Create a GPG key

If you still did not create a GPG public key in the past, it must be created right now so that you can sign packages. First, enter the text GPG -Gen-Key. Select the default values \u200b\u200band enter your real name and contact details when prompted. Carefully write down all the data, because later we will need to be accurately compliance in the configuration file. After that, type the LS ~ / .gnUpg command in order to ensure that the new key exists (this is the file name_name. GPG). From it, create an open key:

GPG -A --output ~ / .gnupg / .gpg --export "[Your name]"

Import it with:

GPG --Import ~ / .gnupg / .gpg

Step 05: Download package

In this example, we are going to download and assemble the latest version of the Dillo web browser. Go to the Dillo site (www.dillo.org) and download the most recent archive.tar.bz. Using the MKDIR ~ / srCand command, create a directory for the source code and move the archive to it.

Step 06: Unpack the archive

Unpack the archive with tAR teams -XJVF [archive name] .tar.bz2. Please note that compliance with the catalog naming agreements (namePack version) is important for our purposes, and fortunately, the Dillo package matches them. It is also important that the source archive is located for one level above the source directory.

Step 07: Configure under Debian

Move the DH_MAKE script directory to the newly unpacked directory, which will take care of most of the work - will add a configuration file and create a directory structure, and which is part of the developer's intrumenartary, which we have added earlier.

DH_MAKE -E -C LICENCE -F ../

In our example, the command line tugades look like this:

DH_MAKE -C GPL3 -E [Email Protected] -F ../dillo-3.0.3.tar.bz2.

When the query appears, select one binary file. Script assistant The script must create a directory with the name of Debian in the source directory.

Step 08: Open the control file

Open B. text editor The control file in the Debian subdirectory. Fill in the "Homepage" section (use Google to fill the Debian program sections list) and the description fields of this file.

Step 09: Examine the dependences

You can explore which dependencies are necessary to start the program supplied as a package. Go to the source code directory and type the DPKG-DPCHECK -D command in the terminal ./configure. If you do this, then errors will be issued indicating which there is no package required for the assembly of the program (supplied separately). You can open this package by typing Sudo APT-Get Build-DEP [Package Name], and this should help if this package is supported in the repository of the Distribution. If it is not supported, you will have to repeatedly run the dpkg-depcheck -d command ./configur and add packets manually by typing the RSUDO APT-Get Install command [Package name].

Step 10: Add dependences to the control file

When all actions from the previous step are completed, you must have a list of all necessary packages. Add this dependency list to the Depends section: Control File. The element in the list must be separated by a comma and a space.

Try to execute this step so fully as you can, and do not skip it. Source: - This is usually main page Project. In the Files section: * Replace copyright information in the names of the authors of the project. You can see an example in the Files: Debian / * section, in which the relevant information should be entered. You may have to a little detective to find the information you need. Search in directory with source code files such as Authors and Copying.

Step 12: Edit change log file

Open the change log file and make sure that the name and address email Coincide with those that you entered when creating a GPG key. Usually, the script assistant can add a username to the file, and not your real name. As with the copyright file, do not skip this partition, because due to this, the process of creating a package may be stopped or an incorrect package can be created.

Step 13: Create a package

If everything is configured correctly, we can finally collect a DEB package. Go to the source directory and in order to collect a package that will be placed in the ~ / SRC / directory, type the DPKG-BuildPackage -B command. For example, create a package using the DPKG -i [Package] command. In order to check for the Debian policy compliance, using the Lintian [Package] command, launch the LintIan program. Please note that this tool is known to be strict, and your business is to decide whether some minor non-compliance warnings are allowed for you. Finally, set the pact using the Sudo DPGK -i [Package] command.

Part 2: Creating RPM packages in Fedora

Step 14: Open the control file

Go to Root User Mode, typing SU. Start from the Development Tools Installation Tools (Development Tools) in Yum, and then with YUM, install the GCC-C ++ Fedora- packter. Type the usermod -a -g mock command to add your user to the MOCK group. This allows us to execute the assembly procedure without the need to go to the role of the ROOT user.

Step 15: Create an assembly environment

Press Ctrl + D to exit ROOT role. Enter RPMDEV-SetupTree in order to create a directory tree (under ~ / rpmbuild) that we need.

Step 16: Download the archive and move it to the right place.

Download the Dillo package from the Dillo website and move the archive to the appropriate directory - type the MV command [archive name] ~ / RPMBuild / Sources.

Step 17: Create file.spec.

Distributions created based on Red Hat, such as Fedora, use.Spec files to specify the assembly process. Switch to the directory in which there are files using the CD command ~ / rpmbuild / specs / andcreateablank.spec and create an empty file.spec using the RPMDEV-Newspec Dillo command.

Step 18: Edit the file.spec.

Type the gedit dillo.spec command. Fill in the Version fields (Version), Summary (Summary) Licency (License) (in this case - GPLV3 +). The URL indicates homepage project; Source0 indicates the address of the source code. Specify comments in the Buildrequires fields (Requirements for Assembly) and Requires. Add full description In the area% description.

Step 19: Follow the source code assembly

If the package is generally supported in the system, run the Yum-BuildDep command [Package Name] command. Otherwise, you will have to repeat the assembly command in order to receive error messages, or search the documentation in the archive with the source code. In the SPEC directory, type the RPMBuild -Ba command [Package name] .Spec. If this assembly fails, and messages about additional non-unpacked files will be issued, highlight and copy this list of files to the% files file section .Spec and repeat the assembly command. Now the package will be in the RPMS directory. Type the RPM -IVH [Package] command in order to install it. Dial the RPM -QA command | Grep [Package] in order to make sure it is installed.

I will try to set out the process of creating the Deb packages as you can set out the Ruby-ZooKeper example. I warn you immediately that the Ruby Gems patching method described by me is wrong, it is better to use gem2deb for this, but since From the source using gem2deb to collect Ruby-ZooKeper latest version I did not succeed, then here is the easiest assembly method.

If you collect Ruby packets, as recommended, via gem2deb, then better add a string

Export DH_Ruby_ignore_Tests \u003d All / Export DH_Ruby_ignore_Tests \u003d All

in Debian / Rules.

Because We will collect Ruby code, then we will need Ruby and a set of tools for assembling Deb packages.

Sudo Apt-Get Install Ruby Dpkg-Dev

If you have old version Ruby, then there is no gem command in it, you will have to install the Rubygems package or update Ruby.

Now install Gem. fPM.who will collect the deb package for us.

Sudo GEM Install FPM FPM -S GEM -T DEB ZOOKEEPER

In the current directory, we have a rubygem-zookeeper_1.4.11_amd64.deb package, it would seem that the case is already in a hat, but because We need a Source package, so that you can collect from it DEB, for example in OBS, then we will continue.

Create the assembly directory

CP rubygem-zooKeeper_1.4.11_amd64.deb ~ / CD MKDIR -P Ruby-Zookeeper / Fakeroot CD Ruby-ZooKeeper / Fakeroot

Recalling the content of just the collected package

DPKG-DEB -R ~ / RUBYGEM-ZOOKEEPER_1.4.11_AMD64.deb Ruby-zooKeeper_1.4.11-1

Now we will create files required to build a package. They must be in the Debian directory. Part of the files we can copy from the unpacked package.

Mkdir Debian CP Rubygem-Zookeeper_1.4.11-1 / Debian / Control Debian / Control

Edit it until the next state. Do not forget to change Maintainer

Source: Ruby-Zookeeper Maintainer: Section: Ruby Build-Depends: Debhelper (\u003e \u003d 7.0.50 ~) Priority: Extra Homepage: https://github.com/slyphon/zookeeper Package: Ruby-Zookeeper Architecture: AMD64 DEPENDS: $ (Shlibs: Depends), $ (MISC: DEPENDS), Ruby Description: A Low-Level Multi-Ruby Wrapper Around The Zookeeper API Bindings. For a friendlier interface, see http://github.com/slyphon/zk. Currently Supported: MRI: (1.8.7, 1.9.2, 1.9.3), JRuby: ~\u003e 1.6.7, Rubinius: 2.0.Testing, Ree 1.8.7. . This Library Uses Version 3.4.5 of Zookeeper Bindings.

We still need Debian / Rules. Create it. Override_Dh_shlibDeps need not to check the linkeper libraries link, because She does not pass.

#! / USR / BIN / Make -F # - * - Makefile - * -%: DH [Email Protected] override_dh_shlibdeps: True.

Tabulations in Debian / Rules are required, it is impossible to replace them on spaces. Let's make it executable.

CHMOD + X Debian / Rules

USR / * VAR / *

Now let's create Debian / ChangeLog and install it:

Ruby-Zookeeper (1.4.11-1) unreleased; URGENCY \u003d MEDIUM * INITIAL RELEASE - ROOT WED, 25 Nov 2015 20:01:55 +0300

We also need Debian / Compat

Echo 7\u003e Debian / Compat

Copy the files that will be installed in the local directory and delete the folder with the unpacked package, it is no longer useful.

MV Ruby-Zookeeper_1.4.11-1 / (USR, VAR). RM -R Ruby-Zookeeper_1.4.11-1

We collect a new package, as well as the Source package.

Dpkg-BuildPackage -RfakeRoot -uc -f

In the directory, we will have all the necessary files.

LL .. Total 5528 DrWXR-XR-XR 3 ROOT ROOT 4096 DEC 20 13:32 ./ DrWX ------ 12 Root Root 4096 Dec 20 13:31 ../ DrWXR-XR-X 5 Root Root 4096 Dec 20 13:28 Fakeroot / -RW-R - R-- 1 root root 1261 Dec 20 13:32 Ruby-zookeeper_1.4.11-1_amd64.changes -rw-r - R-- 1 root root 2375044 DEC 20 13: 32 Ruby-zooKeeper_1.4.11-1_amd64.deb -rw-R - R-- 1 Root Root 565 Dec 20 13:32 Ruby-zooKeeper_1.4.11-1.DSC -RW-R - R-- 1 Root Root 3263381 DEC 20 13:32 Ruby-zooKeeper_1.4.11-1.tar.gz

You can check the contents of the received DEB package

deb file is an archive in format aRcontaining the installers of the program, program information, as well as scripts (command files), executed before and after installing and deleting the program (the presence of scripts is not mandatory - they may not be included in the package).

The DEB file format is described in MAN-Help (Man Pages) DEB (5) - This help is displayed if the terminal dial the MAN DEB command. Also on the Internet there are quite a few pages containing this information - it is enough to dial in the DEB search bar (5) to find them. This manual is not given here, as in the official manual for Debian developers, in the package format certificate (which at the time of writing this guide was located at http://www.debian.org/doc/manuals/debian-faq/ch pkg_basics.en.html) It is written that the package format may vary, and therefore it is recommended to use the DPKG-DEB utility to work with them. Help for working with the DPKG-DEB utility can be obtained by typing the MAN DPKG-DEB command in the terminal.

The operation of the GUI-DEB program is to create a directory containing the necessary data, and launch the DPKG-DEB program indicating this directory and other necessary parameters.

The correct directory needed to create the DPKG-DEB installation package must, above all, contain the "Debian" directory. All data that is not copied to the system must be in this directory, and the programs used directly to work with packages - information about the package performed before and after installation of the scrap pit, etc. No files contained in the Debian directory when installing the package will not fall into the computer file system to which the package is installed.

Outside the "Debian" directory contains those files that will be copied to the computer file system to which the package will be installed. Files should be located in those directories in which they will be placed when installing the package. That is, within the directory created for DPKG-DEB, a copy of the parts of the file system needs should be created - as if this directory was rooted ("/"). That is, let's say if the name of the directory on the basis of which the packet will be created - "~ / TMP_DEBS / MyProgram", and you need to install when installing file System The "MyProgram.png" file was recorded in the "/ usr / share / pixmaps" file - you need to create the "usr" directory, in it - the "Share" directory in it, in the "Share" directory, "Pixmaps" directory ", And already in the" Pixmaps "directory to place the file" myprogram.png ". As a result, the full path to the file will be "~ / tmp_debs / myprogram / usr / share / pixmaps / myprogram.png". When creating a package, part of the "~ / TMP_DEBS / myProgram" directory will be cut, and when installing the file "myprogram.png" just gets the desired address "/ usr / share / pixmaps". Thus, the necessary directories must be created for each file.

After creating the directory, it remains only to run DPKG-DEB, passing the necessary parameters. The most necessary DPKG-DEB parameters are described in the "Command Line Settings for the DPKG-DEB utility". In the absence of errors in the Control file, the installation package will be created.

There are several ways to install programs. Almost everyone has a common part - to unpack the sources:

Tar xvfj mega_app.tar.bz2.

Tar xvfz mega_app.tar.gz.

Run command ./configure., then make. These commands are used to build from source code executable files, libraries and TP.
Separately, it is worth noting the first command - ./configure.
If you perform ./configure --help.then you will receive a list of parameters that can be transmitted ./configure.
For example, such a command is often possible:

./configure --prefix \u003d / OPT / MEGA_APP

Or indicate the path to the library, which for some reason did not find itself:

./configure --kerberos-lib \u003d / OPT / KERBEROS / LIB

Classical.
So we make a sequence:

./configure make

And the team which will actually establish all components of the program in the system:

Make Install

Warning !!! Using this method it is easy to get very serious problems in the future. First, most likely, you will not be able to delete the program (make uninstall).

We use the CheckInstall program.
The right way. After completing the total part, you start:

The program itself will ask you about everything, and you can just press ENTER everywhere.
man Checkinstall Also very good way :))

Build a package with source sources for Debian.
This is a separate I. sophisticated way - You need to deal with many aspects of creating deb-packages (or any other). Here this path will not be fully described, only an example of how to assemble a package of already trained materials.
So an example. We go to packages.ubuntu.com, we find the desired package (DIFF for example) and download two files - source (http: //archive.ubuntu.com/ubuntu/pool/main/d/diffutils/diffutils_2.8.1.o ... ) And the patch to it, which will correct the sources and create a Debian folder with the magic file Rules inside (http: //archive.ubuntu.com/ubuntu/pool/main/d/diffutils/diffutils_2.8.1-1 ...).
Copy them to the ~ / Test folder and to start unpacking the sources:

TAR XVFZ Diffutils_2.8.1.orig.tar.gz.

And then leave the patch:

CD Diffutils-2.8.1 / Gzip -CD ../Diffutils_2.8.1-11ubuntu4.diff.gz | Patch -p1

Now you have to do debian / Rules. Executable:

CHMOD + X Debian / Rules

And collect the package:

FakeRoot Debian / Rules Binary

Fakeroot is needed to build a package by the usual user (usually many operations required would not allow you to make a package).

Ls ../ Diff_2.8.1-11ubuntu4_i386.deb Diffutils-2.8.1 diffutils_2.8.1-11ubuntu4.diff.gz diffutils_2.8.1.orig.tar.gz

As you can see, the package is ready.

Or Debian:

wget Name Package.dsc, Package_name.Diff.GZ name, Package name.orig.tar.gz DPKG-Source -x_Pack_name.dsc CD.

Conclusion
There are still methods - make a package from beginning to end. We need to take a manual to create packages from its distribution and study this process from and to it. Make packages a lot, good and necessary. If you have made a good assembly - throw the distribution to the developers, support the relevant. Remember that even one package supported by you may come in handy hundreds of people around the world.

We will take a little break and look at the video about the site optimization: