Step-by-step production of RPM packages

Source: Internet
Author: User
Tags mkdir rpmbuild

This article is based on Marco Education Video http://mageedu.blog.51cto.com/4265610/919986 Summary, if you want to study carefully see the video.

I. RPM PRODUCTION steps

We have in the enterprise software is basically compiled, we have to compile each time, how to do it. Then make the RPM installation package according to our needs. First of all, the basic cloth:

1.Planning What do you want plan to do RPM package. Software. The library.

2.Gathering the software to package collects raw materials, which is the collection of source packages

3.Patch the software as need if you need to patch, collect the patch files. This cloth is not a must

4.Outling any dependenies determining dependency packages

------------------the above actions can be manually compiled by our software once to determine the-------------------

5.Building RPMs start making RPM package

5.1 Set up the directory stucture, we make our RPM packages in these directories, we need the following directories

BUILD source code after extracting the storage directory

RPMS after the completion of the RPM package storage directory, which has a platform-related sub-directory

SOURCES collection of source materials, patch storage location

SPECS Spec File storage directory

Srmps Store Srmps generated directory

5.2 Place the Sources in the right directory put the source material in the correct position

5.3 Create a spec file that ' tell ' rpmbuild command what does the creation of spec files, this is the program file, Rpmbuild command according to the spec file to make the appropriate RPM package

5.4 Build the source and binary RPMS make src or binary rpm packages

6.Test RPMS Test-made PRM package

7.Add Signature for RPM signature for RPM package

Two. RPM Package Making Example

I would like to use a coherent word for you to tell the story, we first really why we do rpm package, usually we are for some software, such as Httpd,nginx, and then to collect the source code of these packages, if necessary, also collect the patch files, manually compile and install the software ( Of course, if it is not necessary to compile the need to drill, to determine the dependencies of the package, and recorded, the following began to prepare the tengine of the PRM package it:

1. Create an ordinary user, with ordinary users to make rpm, with root may cause the consequences of the destruction of code problems

Useradd Ibuler Su-ibuler

2. Determine in which directory we make rpm, usually this directory we topdir, this need to be specified in the macro configuration file, this configuration file is called Macrofiles, they are usually/usr/lib/rpm/macros:/usr/lib/rpm/macros . *:~/.rpmmacros, this can be Rpmbuild--SHOWRC in Rhel 5.8 | grep macrofiles View, 6.3 of the I use this can not find, but the use is the same. You can get through Rpmbuild--SHOWRC | grep topdir View your system's default work shop

Rpmbuild--SHOWRC |   grep topdir-14: _builddir%{_topdir}/build-14: _buildrootdir%{_topdir}/buildroot-14: _rpmdir%{_topdir}/rpms    -14: _sourcedir%{_topdir}/sources-14: _specdir%{_topdir}/specs-14: _srcrpmdir%{_topdir}/srpms-14: _topdir %{getenv:home}/rpmbuild

We're still customizing the working directory (or workshop).

VI ~/.rpmmacros%_topdir/home/ibuler/rpmbuild # #目录可以自定义 mkdir ~/rpmbuild

3. Create the required directory under Topdir

CD ~/rpmbuild MKDIR-PV {BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

4. Place the source of the collection under the sources

cp/tmp/tengine-1.4.2.tar.gz SOURCES # #事先放好的

5. Create an important spec file under specs

CD SPECS VI tengine.spec # #内容见后讲解, rhel6.3 will automatically generate templates

6. Make RPM package with rpmbuild command, Rpmbuild command will generate RPM package according to spec file

Rpmbuild-ba both generate src.rpm and generate binary rpm-bs only generate SRC RPM-BB only raw binary RPM-BP execute to PRE-BC execute to build segment-bi Execute install segment-BL detect file not wrapped Containing

We can try step by step, first rpmbuild-bp, then-BC-bi if no problem, RPMBUILD-BA generate SRC Package and binary package bar

7. Installation Test There is no problem, whether the normal installation and operation, whether the normal upgrade, uninstall there is no problem

Root User Test Installation:

Cd/tmp cp/home/ibuler/rpmbuild/rpms/x86_64/tengine-1.4.2-1.el6.x86_64.rpm/tmp RPM-IVH tengine-1.4.2-1.el6.x86_64. RPM # #测试安装 rpm-e tengine # #测试卸载, if the version number is higher than the original, the upgrade test

8. If no problem for the RPM package signed it, to prevent someone malicious change # #这个先不写了, a little late, to fill in later

This entire process is complete. Here is the most important spec format, first of all, the simplest, easiest to implement

vi tengine.spec    ### 0.define section                 #自定义宏段, this is not a must   ### %define nginx_user nginx         #这是我们自定义了一个宏 with a nginx_user value of Nginx,%{nginx_user} reference     # # #  1.The introduction section       #介绍区域段    

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.