Building the rpmbuild of local Yum source

Source: Internet
Author: User
Tags rpmbuild

The group is ready to build an internal yum source, which requires the specification of the software's installation directory and the packaging of existing applications.

Currently contacting two RPM packaging tools, Rpmbuild and FPM.

-Rpmbuild

Rpmbuild key is the spec file writing.

Environment construction

Yum-y Install Rpm-build Rpmdevtools

Useradd rpm; Su rpm

Note: RPM packaging requires a specific directory, in the recent version Rpmbuild can create a package directory under the non-root account home directory:

Rpmdev-setuptree

[email protected] rpmbuild]$ LL

Total 20

Drwxrwxr-x. 2 rpm 4096 Dec 14:46 BUILD

Drwxrwxr-x. 2 rpm 4096 Dec 14:46 RPMS

Drwxrwxr-x. 2 rpm 4096 Dec 15:06 SOURCES

Drwxrwxr-x. 2 rpm 4096 Dec 16:07 SPECS

Drwxrwxr-x. 2 rpm 4096 Dec 14:46 SRPMS

[Email protected] rpmbuild]$

Note: Here is/home/rpm/rpmbuild, this default directory can be modified, you can modify the macro definition:

/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 extract the compressed package defined in the source section into the%build directory

Note: Source needs to compress files in tar format so that Setup can be called (source and Setup may have multiple records and correspond sequentially)

2%build can call the%configure macro variable or directly configure it by calling the Configure command

3%install installation files to%buildroot (Rpmbuild/buildroot), in this section, you need to ensure that the directory already exists or will be error, such as copying the configuration file to/etc/, need to establish%BUILDROOT/ETC directory

Note: The%install section is in absolute path, so it is best to refer to%buildroot

4%file section definition those files will be packaged in the RPM package.

Note:%file part is used relative path, 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 Construction:

Yum-y Ruby Ruby-devel RubyGems rpm-build

Gem Install FPM

Note: There is a hole here. If normal follow the gem to install we are not able to invoke FPM successfully, because the cabin version has a problem:

[email protected] rpms]# FPM

/usr/lib/ruby/gems/1.8/gems/cabin-0.8.0/lib/cabin/mixins/logger.rb:12:in ' included ': Undefined method ' Optio NS ' 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

Use the previous version of cabin to properly start FPM

Building RPM Packages

To package the previously 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 can let us see the specific spec file, if no problem, save the exit can be in the current directory to create a RPM package

But FPM cannot be packaged in a friendly way.

-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. -.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-b0%setup-b1%setup-b2%setup-b3%setup-b4%setup-b5%setup-b6%setup-b7%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. -  Make%{?_smp_mflags}%Install RM-RF $RPM _build_root Make InstallDestdir=$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

Building the rpmbuild of local Yum source

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.