RPM packaging road

 Xiao Mingxu 360 Cloud Computing 

Heroine declaration

Today, the editor will share an article about RPM package packaging. The article starts from the concept of RPM, and focuses on the packaging of RPM packages. It describes two mainstream RPM package packaging methods on the market and a self-developed automated packaging tool. Hope Can be helpful to everyone.

PS: Rich first-line technologies and diversified forms of expression are all in the " 360 Cloud Computing ", please pay attention!

image

1

What is RPM

 RPM was called RedHat Package Manager in the early days, but because RPM is very popular at present, it has become the Linux industry standard. So RPM is now also called RPM is Package Manager. RPM management supports transaction mechanism, which enhances the management of program installation and uninstallation. RPM functions: packaging, installation, query, upgrade, uninstallation, verification, database management. YUM is called Yellow dog Updater, Modified, and it is a Shell front-end package manager in Fedora, RedHat and SUSE. YUM client manages based on RPM packages, and can obtain software packages through HTTP server downloads, FTP server downloads, local software pools, etc., and can automatically download and install RPM packages from a designated server, and can automatically handle dependencies.

Package management system

image


2

Use rpmbuild to generate RPM

 

Install the rpm-build package:

yum install rpm-build -y


rpmbuild directory:

When the execution of the rpmbuild command fails, a rpmbuild directory will be generated in the current directory, which contains the following 6 directories.

BUILD: After decompressing the source code, you only need to provide the BUILD directory. We don’t care about what to put in it. So the real production workshop is the BUILD directory. 

BUILDROOT: Fake root, use install to temporarily install to this directory, and use this directory as the root, so the directory file in this directory is the real directory file. When the packaging is completed, this directory will be deleted during the cleanup phase. 

RPMS: The directory where the rpm package is stored after the production is completed, and the subdirectory (i386, i686, ppc) is designated for the specific platform. 

SOURCES: The storage location of collected source files, source materials, patch files, etc. 

SPECS: store the spec file, as the program file for making the rpm package, the file ends with .spec. SRPMS: The location of the rpm package in src format. Since it is a package in src format, there is no platform concept.


Routine operation:

1. Download the source code tar package to the SOURCE directory. 2. Write SPEC files. 3. Use rpmbuild to generate RPM packages.


3

Use fpm to generate RPM

 FPM is a convenient packaging tool developed by Jordansissel based on the ruby ​​language. Simply put, it is to convert one type of package into another type of package.

Install the fpm package:

#Install ruby

          yum -y install ruby rubygems ruby-devel

# Add Taobao Ruby warehouse

          gem sources -a http://ruby.taobao.org/

# Remove native Ruby repository

          gem sources --remove http://rubygems.org/

# Install fpm

          gem install fpm


The FPM catalog plan is as follows:


image.png

General operation: 1. Unzip the directory to be packaged to the usr/local directory. 2. Write the script to be run before the software package is installed, the script to be run after the software package is installed, the script to be run after the software package is uninstalled, and the script to be run before the software package is uninstalled. 3. Execute the fpm command to generate the RPM package.

%Fpm –s <source type> -t <target type> [options]

4. Test the RPM package.

4

Use automated tools to generate RPM

 

This tool is a visual packaging tool developed based on fpm, which is divided into wshell command line upload file tool and graphical packaging test tool.

Diagram of automation tool process architecture:

image.png


Routine operation:

  1. Build the file directory according to the specification, refer to the following:

image.png

2. Upload the folder through wshell.

    1 , download folder creation tools wshell.

yum install addops-auto-wshell (installed to the usr/local/bin directory by default)

     2. Wshell makes a compressed package.

   wshell build name-version-iteration    例:wshell build pika30-3.0.2-1、wshell build safe-nginx-1.2.9-3

     3. Wshell uploads the compressed package.

   wshell put name-version-iteration.tar.gz     例:wshell put pika30-3.0.2-1.tar.gz、wshell put safe-nginx-1.2.9-3.tar.gz

3. Fill in the information through the UI and click Package.
    The following is the packaging UI interface:
image.png

Conclusion


The rpm automation tool has changed the previous packaging method to a large extent, making the packaging smaller and more white. Every programmer who has not been exposed to packaging can customize the rpm package in a short time. At present, the system supports multiple users' source code package backup, concurrent packaging and progress query, but the production of source code packages is not very friendly. As the number of users increases, the source code package production tools will be optimized in the future to improve packaging efficiency.


Guess you like

Origin blog.51cto.com/15127564/2666258
rpm