The use of RPM packaging tool Rpmbuild and the writing of spec files are introduced with the example of packaging fuse

Source: Internet
Author: User
Tags rpmbuild

I. Installation of the Rpmbuild command

Yum Install Rpm-build

Second, usage

RPMBUILD-BB Xxxx.spec or Rpmbuild-ba XXX.tar.gz

Iii. Overview of the catalogue

Rpmbuild will generate a Rpmbuild folder in the user directory after running:
[[email protected] rpmbuild]# ls ~/rpmbuild/
BUILD buildroot RPMS SOURCES SPECS SRPMS
There are four of directories:
Build: The files you want to pack will be compiled here;
BuildRoot: In the virtual installation (make install) directory;
RPMS: To store the generated binary RPM package, which is the kind of RPM package we normally use;
SOURCES: The source package you want to compile will be copied here;
SPECS: The spec file you execute will be copied here;
SRPMS: Storage is the RPM source package, the source package only one file, is your XXXX.tar.gz

Iv. Preparation of spec files

Vim an empty file, you can see that Rpmbuild has helped us to generate a format:

VI aaa.spec Name:Version:Release:         1%{?  Dist}summary:group:license:url:source0:buildrequires:requires:%Description%Prep%setup- q%build%Configure make%{?  _smp_mflags}%installmakeinstall destdir=%{buildroot}%  Files%doc%changelog
View Code

The corresponding keywords are described below:

Name: Package Names%{name}version: Actual version number of the software release: Release serial number%{Release} for example: Moosefs-3.0.Bayi-1.Tar. Gzname:moosefs; version number:3.0.BayiRelease:1Summary: Package Content Summary Group: Software groupings, recommended use of standard grouping license: Software licensing method URL: Software's home page SOURCE0: Source package Address, multiple sources can be used"%{source1}"、"%{source1}"requires: The package name that the RPM package relies on can be used>= or <=represents greater than or less than a specific version of Prereq, Requires (pre), Requires (POST), Requires (Preun), Requires (Postun), Buildrequires, etc. are specified for dependencies on different packaging stages.%Description: Detailed description of the software%prep: Indicates to start compiling software, usually including%setup and%Patch two commands%setup-Q: Unzip the source file program%Patch: Put the patch in the source code%Build means start building%configure equivalent to"./configure", you can also specify the parameters Make%{?_smp_mflags} is" Make"%Install: Means to start the installation (in fact, install to the virtual directory, generally we specify is BuildRoot) Make InstallDestdir=%{buildroot} is"Make Install"%Files : Used to specify which files to package in the RPM package%defattr (644, Root,root,755) to set the default permissions for a file%Doc: This is very important, only the files written in this file will be packaged into the RPM if the directory is not correct, you will be reminded of file not found by Glob:/root/rpmbuild/buildroot/xxxxx was actually packing.%doc can not write first, after the implementation of the/root/rpmbuild/buildroot/directory to see what is installed, and then write;
%changelog: Change log, some time back to remind you to add "*"

Here is the spec file I wrote to fuse-2.9.7:

%define _relname. Develsummary:file Systeminchuserspace (FUSE) Utilitiesname:fuseversion:2.9.7Release:1%{?_reasename} License:commercialGroup:System Environment/BaseSource0:%{name}-%{version}.Tar. GZ BuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-root-% (%{__id_u}-N) Requires:kernel>=2.6. -%Description Libfuse%Prep%setup-Q% CleanRM-RF $RPM _build_root%Build%Configure Make%Install Make InstallDestdir=$RPM _build_root%Files%defattr (644, Root,root,755) %Doc%{_includedir}/*%{_includedir}/fuse/*%{_libdir}/*%{_libdir}/pkgconfig/*%{_bindir}/*%{_mandir}/man1/*%{_mandir}/man8/*/sbin /*%{_sysconfdir}/init.d/*%{_sysconfdir}/udev/*%{_sysconfdir}/udev/rules.d/*%changelog*mon Feb 2006 Peter  Lemenkov <lemenkov newmail ru>-2.9.1-1*proper udev rule*mon Feb 2006 Peter Lemenkov <lemenkov newmail ru> -2.9.1-1*added missing requires
View Code Five, after the packaging of questions and solutions

1. So is the document after packing what we want?

A: You can use "RPM--prefix" to install, the result: Error:package fuse is not relocatable, with the RPM command to view the package information, the original was banned.

[Email protected] x86_64]# RPM-IVH fuse-2.9.7-1. x86_64.rpm--prefix=/usr/local/fuse3error:package fuse is not relocatable[[email protected] x86_64]# rpm-qpi fuse-2.9.7-1. x86_64.rpm name:fuseversion:2.9.7Release:1Architecture:x86_64install Date: (not installed) Group:system environment/basesize:833112license:commercialsignature: (none) Source rpm:fuse-2.9.7-1. Src.rpmbuild date:wedTen  -: .: +  .Build host:localhostRelocations: (not relocatable)summary:file Systeminchuserspace (FUSE) Utilitiesdescription:libfuse

2. How do I know what files are in it without installing RPM?

#先看我们之前说的SRPM中打的源码包是什么样子的:
[Email protected] srpms]#pwd/root/rpmbuild/Srpms[[email protected] srpms]# rpm-QLP fuse-2.9.7-1. src.rpm Fuse-2.9.7.Tar. gzlibfuse.spec# look at the binary RPM package that we finally want is God-like: [[email protected] x86_64]#pwd/root/rpmbuild/rpms/X86_64[[email protected] x86_64]# rpm-QLP fuse-2.9.7-1. x86_64.rpm/etc/init.d/Fuse/etc/udev/RULES.D/etc/udev/rules.d/ About-Fuse.rules/sbin/Mount. Fuse/usr/bin/Fusermount/usr/bin/Ulockmgr_server/usr/include/fuse

3. How to extract the files in the RPM package without installing the RPM package:
Http://blog.chinaunix.net/uid-33787-id-3331183.html

4. How do we make sure that the system comes up with orders that we just loaded?

[Email protected] packages]# Rpm-qi fuse-Libsname:fuse-libsversion:2.9.2Release:6. El7architecture:x86_64install date:wedTen Ten: -: the  .Group:system Environment/librariessize:293074License:lgplv2+Signature:rsa/sha256, Wed Nov -  A: -: -  -, Key ID 24c6a8a7f4a80eb5source rpm:fuse-2.9.2-6. El7.src.rpmBuild Date:fri Nov -  -: the: About  -

The use of RPM packaging tool Rpmbuild and the writing of spec files are introduced with the example of packaging fuse

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.