Linux rpmbuild command and linuxrpmbuild command
I. Introduction
The rpmbuild command is used to create the Binary Package and source code package of the software.
Ii. Options
Reference: http://blog.sina.com.cn/s/blog_4ba5b45e0102e5r2.html http://www.jinbuguo.com/redhat/rpmbuild.html
Iii. Instances
1. Prepare the Packaging Environment
Run the following commands to install rpmbuild and rpmdevtools:
#yum install rpmbuild
#yum install rpmdevtools
Run the following command to generate the rpmbuild working directory:
#rpmdev-setuptree
The working directory structure is as follows,
~ /Rpmbuild ~ /Rpmbuild/SOURCES # Place packaging resources, including source package files and patch files ~ /Rpmbuild/SPECS # Place the SPEC document ~ /Rpmbuild/BUILD # working directory during packaging ~ /Rpmbuild/RPMS # store the generated Binary Package ~ /Rpmbuild/RPMS/i386 # store the generated i386 structure package ~ /Rpmbuild/SRPMS # store the generated source code package
Tip: The rpmdev-setuptree command will create an RPM in the current user's home directory by default to build the root directory structure. If you need to change the default location, you can modify the configuration file :~ /. The value corresponding to _ topdir in rpmmacros.
2. Load the source code to the SOURCES directory without Decompression
cd SOURCES/wget http://nginx.org/download/nginx-1.2.1.tar.gz
3. Write a Spec File
SPEC writing is the core of packaging RPM, and it is also the most difficult step. Fortunately, we can start by referring to a simple template file, expand the document content step by step on the basis of the basic functions that can be implemented until the requirements are fully met. The following is a simple SPEC document, which includes some instructions (Note: # the following content is the description). This SPEC document is written for a tested software project hellorpm, after the hellorpm package is compiled, there is only one execution file, one manual file, and one project description file.
The content of nginx. spec is as follows:
# Example spec file for nginx ## package brief introduction Summary: high performance web server # package Name: nginx # main package Version: 1.2.1 # package Version number Release: 1. el5.ngx # authorization protocol License: 2-clause BSD-like license # software classification Group: Applications/ServerSource: http://nginx.org/download/nginx-1.2.1.tar.gzURL: http://nginx.org/Distribution: LinuxPackager: zhumaohai <admin@www.centos.bz> # Package Description % descriptionnginx [engine x] is a HTTP and reverse proxy server, as well asa mail proxy server # indicates the pre-operation field, the following command will execute % preprm-rf $ RPM_BUILD_DIR/nginx-1.2.1zcat $ RPM_SOURCE_DIR/nginx-1.2.1.tar.gz before the source code BUILD | tar-xvf-# BUILD field, will be completed by directly calling the automatic build tool in the source directory of the source code compilation operation % buildcd nginx-1.2.1 # Call the configure command in the source directory. /configure -- prefix =/usr/local/nginx # execute the automatic build command makemake in the source directory # install field % installcd nginx-1.2.1 # Call the installation in the source code to execute the script make install % preunif [- z "'ps aux | grep nginx | grep-v grep'"]; thenkillall nginx>/dev/nullexit 0fi # file Description field. If the declaration is redundant or missing, an error may occur. % files # The Declaration/usr/local/nginx will appear in the software package.
/usr/local/nginx
4. Create an RPM package
Start the build operation. First, go to the rpmbuild root directory of the current user.
#cd ~/rpmbuild/#rpmbuild -ba SPECS/nginx.spec
Tip:-ba indicates build all, that is, all RPM packages including binary and source code packages are generated. If normal, rpmbuild Exits normally, at the same time, the corresponding RPM package will be generated in the RPMS directory and SRPMS directory.
Reference: http://blog.sina.com.cn/s/blog_5d867af101019b7i.html http://hlee.iteye.com/blog/343499
https://www.centos.bz/2012/06/make-rpm-package-methods/