Build rpmbuild of local yum source and yumrpmbuild

Source: Internet
Author: User

Build rpmbuild of local yum source and yumrpmbuild

Before creating an internal yum source, you must standardize the installation directory of the software and package the existing applications.

 

There are currently two rpm packaging tools available: rpmbuild and fpm.

-Rpmbuild

The key to rpmbuild is to write the spec file.

Environment Construction

Yum-y install rpm-build rpmdevtools

Useradd rpm; su rpm

Note: rpm packaging requires a specific directory. In a recent version, rpmbuild can create a packaging directory in the directory of a non-root Account:

Rpmdev-setuptree

[Rpm @ vm-1-lz rpmbuild] $ ll

Total 20

Drwxrwxr-x. 2 rpm 4096 Dec 22 BUILD

Drwxrwxr-x. 2 rpm 4096 Dec 22 RPMS

Drwxrwxr-x. 2 rpm 4096 Dec 22 SOURCES

Drwxrwxr-x. 2 rpm 4096 Dec 22 SPECS

Drwxrwxr-x. 2 rpm 4096 Dec 22 SRPMS

[Rpm @ vm-1-lz rpmbuild] $

Note: Here is/home/rpm/rpmbuild. The default directory can be modified and the macro definition can be modified:

/Usr/lib/rpm/macros:

_ Topdir% {Getenv: HOME}/rpmbuild

Then, create the spec file in the rpmbuild/SPECS directory:

Cd ~ /Rpmbuild/SPECS

Rpmdev-newspec-o example. spec

SPEC File

The packaging process is

1.% prep decompress the compressed package defined in the source part to the % build directory.

Note: The Source must be a compressed file in tar format, so that setup can be called (the source and setup can have multiple records and correspond accordingly)

2% build can call % configure macro variable or directly call configure command to directly configure

3% install the installation file to % buildroot (rpmbuild/BUILDROOT). In this part, make sure that the directory already exists. Otherwise, an error will be reported, such as copying the configuration file to/etc, you need to create the % buildroot/etc directory

Note: % install uses absolute paths, so it is best to reference % buildroot

4% file part defines which files will be packaged into the rpm package

Note: % file uses relative paths. We can use macro variables such as % _ prefix to represent/usr. Its absolute path is % buildroot/usr.

Reference http://fedoraproject.org/wiki/Packaging:RPMMacros

 

-Fpm Packaging

This is an open source project https://github.com/jordansissel/fpm

Environment setup:

Yum-y ruby-devel rubygems rpm-build

Gem install fpm

Note: There is a pitfall. If you install fpm normally according to gem, we cannot call fpm successfully, because the cabin version has a problem:

[Root @ vm-1-lz RPMS] # fpm

/Usr/lib/ruby/gems/1.8/gems/cabin-0.8.0/lib/cabin/mixins/logger. rb: 12: in 'included': undefined method 'options' for # <Cabin: Subscriber: 0x7fad75e31b90> (NoMethodError)

From/usr/lib/ruby/gems/1.8/gems/cabin-0.8.0/lib/cabin/channel. rb: 105: in 'call'

....

Therefore, uninstall the current cabin version:

Gem uninstall cabin

....

Gem install cabin-v 0.7.2

You can use the cabin of the previous version to correctly start fpm.

 

Build an rpm package

Pack the compiled nginx:

Nginx Directory:/usr/local/nginx

Fpm command:

Fpm-e-s dir-t rpm-n nginx-v 1.8.0-C/usr/local/nginx -- prefix =/opt/nginx

Note:-e shows the specific spec file. If no problem exists, you can create an rpm package in the current directory after saving and exiting.

However, fpm cannot be packaged according to the standard path.

 

 

-SPEC example

Name:           tengineVersion:        1.5.2Release:        1%{?dist} Summary:        tengine-1.5.2Group:          Application/System License:        GPL URL:            http://tengine.taobao.org/Source0:        tengine-1.5.2.tar.gzSource1:        LuaJIT-2.0.4.tar.gzSource2:        pcre-8.34.tar.gzSource3:      openssl-1.0.2e.tar.gzSource4:      zlib-1.2.8.tar.gzSource5:      ngx_devel_kit-0.2.18.tar.gzSource6:       jemalloc-3.4.0.tar.bz2Source7:      nginx-bb-1.8.0.tar.gzRequires: zlib,pcre,openssl,LuaJIT %descriptiontengine-1.5.2%prep%setup -b 0%setup -b 1%setup -b 2%setup -b 3%setup -b 4%setup -b 5%setup -b 6%setup -b 7%build CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic}" ; export CFLAGS ; CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic}" ; export CXXFLAGS ; FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules}" ; export FFLAGS ; ./configure \  --with-http_ssl_module \  --prefix=/opt/nginx \  --error-log-path=/opt/nginx/logs/ \  --http-log-path=/opt/nginx/logs/ \  --pid-path=/opt/nginx/run/ \  --lock-path=/opt/nginx/lock/ \  --user=www \  --group=www \  --with-http_stub_status_module \  --with-http_gzip_static_module  \  --with-http_lua_module  \  --with-luajit-inc=/usr/local/include/luajit-2.0 \  --with-luajit-lib=/usr/local/lib \  --with-pcre=%{_builddir}/pcre-8.34 \  --with-openssl=%{_builddir}/openssl-1.0.2e \  --with-zlib=%{_builddir}/zlib-1.2.8 \  --with-http_concat_module  \  --with-http_sysguard_module \  --with-http_realip_module \  --without-syslog \  --with-jemalloc  \  --add-module=%{_builddir}/ngx_devel_kit-0.2.18 make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOTmv %{buildroot}/opt/nginx/conf %{buildroot}/opt/nginx/conf.defaultinstall -d %{buildroot}/opt/nginx/confcp -r %{_builddir}/nginx-bb-1.8.0/conf/*  %{buildroot}/opt/nginx/conf%clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc /opt/nginx/*%changelog

 

 

 

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.