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
- Generate the file list or source code used by rpm
- Generates rpm specifications based on the file list or source code, that is, spec files.
- 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