How to create RPM or DEB package from Linux source code

  

In Linux system operation, for some reasons, you want to create the installed package directly from the source code. The following small series will introduce you how to use the source code under Linux system. Create an RPM or DEB package so that you can uninstall the program more easily in the future. Let's take a look.

If you have already run the linux program from its source code “make install”. It would be really cumbersome to remove it completely, unless the developer of the program provided the target setting for uninstall in the Makefile. Otherwise you must compare the complete list of files in your system before and after installation, and then manually remove all files added during the installation process.

At this time, Checkinstall can be used. Checkinstall will track the path to all files created or modified by the install command line (for example: “make install”,“make install_modules” etc.) and create a standard binary package that allows you to manage with your distribution's standard package. The system installs or uninstalls it (for example, Red Hat's yum or Debian's apt-get command). It is also known to work well on Slackware, SuSe, Mandrake and Gentoo, please refer to its official documentation.

In this article, we focus only on Red Hat and Debian-based distributions and show how to create an RPM and DEB package from Source using Checkinstall

Installing Checkinstall on Linux

Installing Checkinstall on Debian and its derivatives:

# aptitude install checkinstall

To install Checkinstall on Red Hat's distribution, you need to download a packaged one. The Checkinstall rpm package (for example: found at http://rpm.pbone.net/), but it has been removed from the Repoforge library. This package is for Cent OS6, but it works in Cent OS7 as well.

# wget

ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/ikoinoba/CentOS_CentOS-6/x86_64/checkinstall -1.6.2-3.el6.1.x86_64.rpm# yum install checkinstall-1.6.2-3.el6.1.x86_64.rpm

Once checkinstall is installed, you can create it in the following format: A specific package

# checkinstall "install-command"

If there are no parameters, the default installation command “make install” will be used

Create an RPM with Checkinstall Or DEB package

In this example, we will create a htop package, which is a linux interactive text mode process viewer (like top).

First, let's download the source code from the project's official website. As a good habit, we store the source package under /usr/local/src and unzip it.

# cd /usr/local/src# wget http://hisham.hm/htop/releases/1.0.3/htop-1.0.3.tar.gz# tar xzf htop-1.0.3. Tar.gz# cd htop-1.0.3

Let's see what the htop installation command is, so that we can call it with the Checkinstall command, as shown below, htop is installed with the “make install” command .

# . /configure# make install

So, to create a htop installation package, we can call checkinstall without any parameters, which will create a package using the “make install” command. In this process, the checkinstall command will ask you a few questions.

In short, the following command creates a htop package:

# . /configure# checkinstall

“Should I create a default set of package docs? (I will create a default setting package file?) & Rdquo ;, answer & ldquo; Y & rdquo ;:

You can enter a short description of a package, then press Enter twice:

enter a numeric value or to modify any of the following eNTER continued:

checkinstall will then automatically create a .rpm or .deb package, according to what your linux system is:

in CentOS7:

in Debian 7:

the above can be used to create checkinstall RPM or DEB source packet from the method described under the Linux system, the The method is only available for Red Hat and Debian-based distributions, and other versions can be used as a reference.

Copyright © Windows knowledge All Rights Reserved