How CentOS RPM packages are created

Source: Internet
Author: User

Sometimes, to deploy our own package more conveniently, we will make our own RPM package. What are the steps for creating an RPM package? Learning these steps is the purpose of this Article. Creating an RPM package in CentOS depends on the rpm-build package. Therefore, you must install the package in advance.

RPM generation Elements

  1. Generate the file list or source code used by rpm
  2. Generates rpm specifications based on the file list or source code, that is, spec files.
  3. Rpmbuild, a tool that processes source code/files based on the spec File

In RedHat, the default rpm package Creation Path is under/usr/src/redhat:

/Usr/src/redhat
-- BUILD # the path that is stored After decompressing the package before Compilation
-- BUILDROOT # path stored after compilation
-- RPMS # path of the rpm package after Packaging
-- SOURCES # path of the source package
-- SPECS # path for storing spec documents
-- SPRMS # path of the source code rpm package

Centos does not have this directory. This is what we can do. In fact, creating an rpm in that directory does not matter. You only need to set the configuration file. In general, we pack the source code into the tar.gz format and store it in the SOURCES path. In the SPECS path, write the spec document. After the command is packaged, the packaged rpm package will be placed under RPMS by default, the source code package will be placed under SRPMS.

Let's take a look at the usage of the rpmbuild command:

1. The following options are available for creating a spec file:

-Bp # Only execute the % pre segment of the spec (unpack the source code package and patch it to prepare only)
-Bc # execute the % pre and % build segments of spec (prepare and compile)
-Bi # execute % pre, % build and % install in spec (prepare, compile and install)
-Bl # Check the % file segment in the spec (check whether the file is complete)
-Ba # Build source code and Binary Package (commonly used)
-Bb # create Binary packages only (commonly used)
-Bs # create only source code packages

2. Build from the tarball package, similar to spec

-Tp # Corresponds to-bp
-Tc # Corresponds to-bc
-Ti # -bi
-Ta # Corresponds to-ba
-Tb # Corresponds to-bb
-Ts # Corresponds to-bs

3. Create from source code package

-- Rebuild # create a Binary Package and use-bb
-- Recompile # Same-bi

* Other rpmbuild Parameters

-- Buildroot = DIRECTORY # confirm to create a package in the root DIRECTORY
-- Clean # Clear the file directory under BUILD After packaging
-- Nobuild # stage where % build is not performed
-- Nodeps # do not check the associated files when the package is created
-- Nodirtokens
-- Rmsource # clear SOURCES after Packaging
-- Rmspec # Clear SPEC after Packaging
-- Short-cricuit
-- Target = CPU-VENDOR-OS # determine the final use platform of the package

Create your own rpm package

Directory structure and configuration after rpm installation in Linux

Brief Introduction and demo of rpm and yum

Redhat Linux --- rpm command details

  • 1
  • 2
  • Next Page

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.