Use the SRC. RPM package to modify the source code and recreate the RPM package.

Source: Internet
Author: User
Tags unpack rpmbuild

1. Download The. SRC. RPM package.
Example: https://repos.fedorapeople.org/repos/openstack/EOL/openstack-grizzly/epel-6/openstack-quantum-2013.1.4-4.el6.src.rpm

2. Use "rpm-IVH" to decompress the source code package.
Example: rpm-IVH openstack-quantum-2013.1.4-4.el6.src.rpm (-- root = xxx specifies the path)
The extracted results are stored in/root/rpmbuild.

3. (optional) Check the decompressed file.
Example: CD/root/rpmbuild/specs/
Ls openstack-quantum.spec

4. (optional) modify the source code.

5. Use rpmbuild for packaging. (Note: If the rpmbuild command is not available, install: Yum install rpm-build from the centos CD image if the dependency package is not installed, install: Yum install python2-devel, yum install dos2unix)
Example: rpmbuild-Ba openstack-quantum.spec (-- Define "_ topdir xxx/root/rpmbuild" specified buildroot)
  

Bytes ------------------------------------------------------------------------------------------------------

Appendix: Explanation of rpmbuild commands <forwarded from http://blog.163.com/?email protected]/blog/static/27765239200992110163786/>

Usage: rpmbuild [option...]
* Run the following command: rpmbuild · [Option]
Build options with [<specfile >|< tarball >|< source package>]:
* The options for creating a package are: [Create from file <specfile> | create from <tarball> package | create from <source package> package]
* Create from file <specfile>

-BP build through % prep (unpack sources and apply patches) from <specfile>
*-BP is established from the % prep segment of the <specfile> file (unbind the source code package and patch it)
-BC build through % build (% prep, then compile) from <specfile>
*-BC: % build from the <specfile> File
-Bi build through % install (% prep, % build, then install) from <specfile>

-BL verify % files section from <specfile>
* Check the % files section of the <specfile> file.
-Ba build source and Binary packages from <specfile>
* Create source code and Binary Package
-BB build Binary Package only from <specfile>
* Create only Binary packages
-BS build source package only from <specfile>
* Only Source Code packages are created.

* Create from the <tarball> package

-TP build through % prep (unpack sources and apply patches) from <tarball>

-TC build through % build (% prep, then compile) from <tarball>

-Ti build through % install (% prep, % build, then install) from <tarball>

-Ta build source and Binary packages from <tarball>
* Create source code and Binary Package
-TB build Binary Package only from <tarball>
* Create only Binary packages
-Ts build source package only from <tarball>
* Only Source Code packages are created.

* Create a package from the <source package> package

-- Rebuild
Build Binary Package from <source package>
* Create a Binary Package
-- Recompile
Build through % install (% prep, % build, then install) from <source package>


* Other rpmbuild usage items

-- Buildroot = directory override build Root
* Are you sure you want to create a package in the root directory?
-- Clean remove build tree when done
* After packaging, clear the file directory under build.
-- Nobuild do not execute any stages of the build
* No build phase
-- Nodeps do not verify build Dependencies
* Do not check the associated files when the package is created
-- Nodirtokens
Generate package header (s) compatible with (legacy) rpm [23] Packaging

-- Rmsource remove sources when done
* Clear sources after Packaging
-- Rmspec remove specfile when done
* Clear specfile After packaging
-- Short-circuit skip straight to specified stage (only for C, I)
* Skip
-- Target = CPU-VENDOR-OS
Override Target Platform
* Determine the final platform for using the package

Common options for all RPM modes:
* All options available for RPM

-D, -- Define = 'macro expr' define macro with value expr
* Pre-defined
-E, -- EVAL = 'expr' print macro expansion of expr
* Display a large number of expr Extension Information
-- Macros = <file:...> Read <file:...> instead of default file (s)
* Read the <file:...> file instead of the default file.
-- Nodigest don't verify package Digest (s)
* The description of the package is not checked.
-- Nosignature don't verify package signature (s)
* The signature information of the package is not checked.
-- Rcfile = <file:...> Read <file:...> instead of default file (s)
* Read the <file:...> file instead of the default file.
-R, -- root = root use root as top level directory (default :"/")
* Set root to the highest level.
-- Querytags display known query tags
* Display known issues
-- Showrc display final rpmrc and macro Configuration
* Display the final configuration information
-- Quiet provide less detailed output
* Provide a small amount of information
-V, -- verbose provide more detailed output
* Provides a large amount of detailed information.
-- Version print the version of RPM being used
* Displays the RPM package version.

Options implemented via popt alias/exec:
* Additional Options

-- Dbpath = directory Use Database in Directory

-- With = <option> enable configure <option> for build
* Options that can be configured during creation
-- Without = <option> disable configure <option> for build
* Configuration options not allowed during creation

Help options:
* Help options

-?, -- Help show this help message
* Display help information
-- Usage display brief usage message
* Display the usage information

Package

To release an RPM source code package or binary package, you must use the rpmbuild tool (the latest RPM packaging tool ). If we have compiled and installed the spec file based on the local source code package successfully (this file must use. SPEC), then we can create a packaging environment, that is, the creation of the directory tree. Generally, five directories are created under the/usr/src/RedHat/directory. Its doors are build, source, spec, srpm, and RPM. The build directory is used to store the source files in the packaging process, the source is used to store the source files and patches used for packaging, and the spec is used to store the spec files, srpm and rpm respectively store the source files and binary files in RPM format. Of course, we can choose different parameter packaging files as needed. I will summarize the following three articles.

1) generate only RPM packages in binary format

Rpmbuild-bb xxx. spec

Use this command to generate a software package. After the package is executed, the screen displays the following information: (each line starts with a line number)

 

1 executing: % prep 2 + umask 022 3 + CD/usr/src/Dist/Build 4 + exit 0 5 executing: % build 6 + umask 022 7 + CD/usr/src/Dist/build

The generated file will exist in the created RPM directory.

2) generate only the RPM package in SRC format

Rpmbuild-bs xxx. spec

The generated file will exist in the srpm directory just created.

3) you only need to generate the complete source file

Rpmbuild-bp xxx. spec

The source file exists in the directory build.

Readers may not understand this command. The purpose of this command is to unbind the tar package and merge all the patch files to generate a complete source file with the latest functions.

4) Complete Packaging

Rpmbuild-Ba XXX. spec

Generate packages generated in the preceding three processes. Stored in the corresponding directory.

 

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.