From nothing to an instance that creates a Deb package

Source: Internet
Author: User
Tags automake
From scratch, an instance that creates a Deb package -- the Linux Release Technology-Debian information. For more information, see the following. I want to create a Deb package from scratch, which means that even the source code of the software is written by myself, similar to deb from scratch, such a production process consists of three parts:

1. coding and testing of source code

2. Use autotools to generate related files that comply with Gnu programming standards, such as configure and makefile.

3. Create the Deb package file In Debian mode.

Now I have written a small software hb-0.01, which means hyperbolic, is a small software written by myself for hyperbolic and antihyperbolic functions. There are only three files in total, in the/home/wen1/hb-0.01/directory, the entire process of making the hb software deb package is:

Step 1: Compile the source code

This step is compiled by the user. My small software has only three files, one is the header file, the other is the C file implemented by the function, and the other is the main program C file. The system displays:

Wen1 @ lenny :~ /Hb-0.01 $ ls-l

Total 12

-Rw-r -- 1 wen1 wen1 140 bolic. h

-Rw-r -- 1 wen1 wen1 369 boliclib. c

-Rw-r -- 1 wen1 wen1 300 hb. c

Step 2: Use Autotools to generate all configuration files that comply with Gnu programming standards.

This process involves many steps, including:

1. Use the autoscan command to generate a configure template file. System Operation:

Wen1 @ lenny :~ Hb-0.01 $ autoscan

Wen1 @ lenny :~ /Hb-0.01 $ ls-l

Total 16

-Rw-r -- 1 wen1 wen1 0 2008-01-26 15:25 autoscan. log

-Rw-r -- 1 wen1 wen1 140 bolic. h

-Rw-r -- 1 wen1 wen1 369 boliclib. c

-Rw-r -- 1 wen1 wen1 484 configure. scan

-Rw-r -- 1 wen1 wen1 300 hb. c

A configure. scan file is generated.

2. Rename the configure. scan file to configure. in and modify the file accordingly. Mine is:

AC_PREREQ (2.61)

AC_INIT (hb, 0.01, wenheping@tom.com)

AM_INIT_AUTOMAKE (HBr, 0.01)

# Checks for programs.

AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CHECK_FUNCS ([sqrt])

AC_OUTPUT (Makefile)

Generally, only three parameters, AC_INIT, AC_OUTPUT, and AM_INIT_AUTOMAKE, need to be modified according to your own situation. Other automatically generated items do not move.

3. Execute the commands aclocal and autoconf to generate the configure file:

Wen1 @ lenny :~ Hb-0.01 $ aclocal

Wen1 @ lenny :~ Hb-0.01 $ autoconf

Wen1 @ lenny :~ /Hb-0.01 $ ls-l

Total 184

-Rw-r -- 1 wen1 wen1 31848 aclocal. m4

Drwxr-xr-x 2 wen1 wen1 4096 autom4te. cache

-Rw-r -- 1 wen1 wen1 0 2008-01-26 15:25 autoscan. log

-Rw-r -- 1 wen1 wen1 140 bolic. h

-Rw-r -- 1 wen1 wen1 369 boliclib. c

-Rwxr-xr-x 1 wen1 wen1 130126 2008-01-26 15:36 configure

-Rw-r -- 1 wen1 wen1 434 configure. in

-Rw-r -- 1 wen1 wen1 300 hb. c

The configure file is generated.

4. Create a Makefile. am file, and then the automake tool automatically generates the Makefile. in File Based on the Makefile. am file.

Makefile. am files generally define the name of the executable program generated by your software and the library to be connected. The content of this file is:

AUTOMAKE_OPTIONS = foreign #

Bin_PROGRAMS = hb # Name of the last generated Executable File

Hb_SOURCES = hb. c bolic. h boliclib. c # all source code files

LIBS =-lm # connect to the math Library

Then use automake to generate the Makefile. in file. to comply with the specifications, first:

Wen1 @ lenny :~ Hb-0.01 $ touch news readme authors ChangeLog

Then the system displays:

Wen1 @ lenny :~ Hb-0.01 $ automake -- add-missing

Wen1 @ lenny :~ Hb-0.01 $ ls

Aclocal. m4 bolic. h configure. in INSTALL missing

AUTHORS boliclib. c COPYING install-sh NEWS

Autom4te. cache ChangeLog depcomp Makefile. am README

Autoscan. log configure hb. c Makefile. in

5. Execute configure to generate Makefile

This step is very simple. After the Makefile is generated, you can use other make commands, such as make clean, make install, and make dist, to see what effect they will give you.

Step 3: generate the Deb package.

There are two methods to generate the deb package: one is very simple. Simply run checkinstall in the software source code directory and then answer a few simple questions. However, this method is generally not recommended; second, follow the New Maintainer Guide of Debian to create the deb package step by step. For detailed procedures, see:

Http://www.debian.org/doc/maint-guide/

My production process is roughly as follows:

1. Download and install required software:

# Apt-get install build-essential dpkg-dev dh-make debhelper fakeroot gnupg lintian Linda pbuilder

2 generate the tar.gz file and move it to the parent directory of the source code:

Wen1 @ lenny :~ Hb-0.01 $ make dist

Wen1 @ lenny :~ /Hb-0.01 $ mv hb *. gz ../

3. Run the dh_make command.

Wen1 @ lenny :~ /Hb-0.01 $ dh_make-e wenheping@tom.com-f ../hb-0.01.tar.gz

There is orig before callback ..

4. Modify Makefile, control, and other files.

Debian requires that the executable file cannot be installed in the/usr/local directory. Therefore, check the corresponding installation location of the Makefile file, my small software was originally installed under/usr/bin, so you do not need to modify the Makefile file.

For control copyright and other files, if you just create a deb package file for your own use, you can do it without modifying it. However, if you are preparing to upload the file for Debian to the Debian apt source, it must be carefully entered in accordance with the specifications.

5. Generate the deb package file, which is like this:

Wen1 @ lenny :~ Hb-0.01 $./configure

Wen1 @ lenny :~ Hb-0.01 $ make

Wen1 @ lenny :~ Hb-0.01 $ dpkg-buildpackage? Rfakeroot

In this way, my hb software's deb package file and other related files are generated-but generated in the parent directory of the source directory.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.