Linux Rpmbuild Commands

Source: Internet
Author: User
Tags rpmbuild

First, Introduction

The Rpmbuild command is used to create binary packages and source code packages for the software.

Second, the option

Reference: http://blog.sina.com.cn/s/blog_4ba5b45e0102e5r2.html     http://  Www.jinbuguo.com/redhat/rpmbuild.html

Third, examples

1 Preparing the packaging environment

Execute the following command to install Rpmbuild and Rpmdevtools

#Yuminstall rpmbuild
#yum Install

Execute the following command to generate the working directory of the Rpmbuild

#rpmdev-setuptree

The working directory structure is as follows

~/rpmbuild~/rpmbuild/SOURCES              #放置打包资源, including source packaging files and patch files ~/rpmbuild/SPECS                #放置SPEC文档 ~/rpmbuild/BUILD                #打包过程中的工作目录~/rpmbuild/RPMS                 #存放生成的二进制包~/rpmbuild/rpms/i386            #存放生成的i386结构包~/rpmbuild/srpms                #存放生成的源码包
Tip: The Rpmdev-setuptree command defaults to the current user home directory to create a RPM build root structure, if you need to change the secondary default location, you can modify the configuration file: ~/.rpmmacros variable _topdir corresponding value.

2, download source package to sources directory, do not need decompression

CD sources/wget http://nginx.org/download/nginx-1.2.1.tar.gz

3. Write Spec file

Spec writing is the core of packaging rpm, is also the most difficult step, fortunately, we can refer to a simple template file, in the basic functions can be achieved on the basis of the next step to expand the content of the document, until fully meet the requirements. Here is a simple spec document, which includes some explanatory information (note: #后面的内容为说明信息), the spec document is written for a test software project hellorpm, the HELLORPM package compiles with only one execution file, one manual file, and one project said file.

The contents of the Nginx.spec document are as follows:

# # Example Specfile  fornginx# #软件包简要介绍Summary: The name of the high performance Web server# software package name:nginx# The major version number of the package version:1.2.1#软件包的次版本号Release:1. el5.ngx# License Agreement 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<[email protected]>#软件包的内容介绍%Descriptionnginx [engine x] is a HTTP and reverse proxy server, as well ASA Mail proxy server# represents a pre-action field, the following command will be in the source code build Pre-execution%PrepRM-RF $RPM _build_dir/nginx-1.2.1Zcat$RPM _source_dir/nginx-1.2.1.Tar. gz |Tar-XVF-#BUILD字段, the source code compilation operation will be done by directly invoking the automatic build tool in the source directory%BUILDCD Nginx-1.2.1#调用源码目录中的configure命令./configure--prefix=/usr/local/nginx# Execute the Automatic build command in the source directory make Make#安装字段%InstallCD Nginx-1.2.1#调用源码中安装执行脚本 Make Install%Preunif[-Z"' ps aux | grep nginx | grep-v grep '"]; ThenKillallNginx >/dev/NULLExit0fi#文件说明字段, statements that are redundant or missing can be error-prone%files# declaration/usr/local/nginx will appear in the package
/usr/local/nginx

4. Build RPM Package

Start the build operation by first entering the Rpmbuild root directory of the current user

#cd ~/rpmbuild/-ba specs/nginx.spec

Tip:-ba represents build all, which generates all RPM packages including binary packages and source packages, and if normal, rpmbuild exits normally, and the corresponding RPM packages are 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/

Linux Rpmbuild Commands

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.