The Spec File
说明文件
The spec file is at the heart of RPM's packaging building process. Similarin concept to a makefile,
it contains information required by RPM to build the package, as well asinstructions telling RPM
how to build it. The spec file also dictates exactly whatfiles are a part of the package, and where
they should be installed.
As you might imagine, with this many responsibilities, the spec fileformat can be a bit complex.
However, it's broken into several sections, making it easier to handle.All told, there are eight sections:
说明文件是RPM包编译进程的中心.类似makefile文件,它包含了RPM编包所需信息及告诉RPM怎么去构建.说明文件也指示哪些文件是包的一部分以及他们应该被安装至何处.
如你所想,由于要承担这么多的责任,说明文件的格式有点复杂.
1. The Preamble
前言节
The preamble contains information that will be displayed when usersrequest information about the
package. This would include a description of the package's function, theversion number of the software,and so on. Also contained in the preamble arelines identifying sources, patches, and even an
icon to be used if the package is manipulated by graphical interface.
前言节包括了用户查询包时显示的信息.包括包的功能描述,软件的版本号等.此外,前言节还包括识别源码和补丁的行以及用于图像界面的图标.
2. The Prep Section
准备节
The prep section is where the actual work of building a package starts. Asthe name implies, this
section is where the necessary preparations are made prior to the actualbuilding of the software. In
general, if anything needs to be done to the sources prior to building thesoftware, it needs to happen
in the prep section. Usually, this boils down to unpacking the sources.
The contents of this section are an ordinary shell script. However, RPMdoes provide two macros to
make life easier. One macro can unpack a compressed tar file and cdinto the source directory. The
other macro easily applies patches to the unpacked sources.
准备节是编包起始的地方.包括了真正开始编包之前的必要准备工作.通常如果在编译之前需要针对源码的操作就放在准备节.一般情况下,就是解压源码包.
该节的内容是普通的shell脚本.不过,RPM提供了两个宏让工作更便利.一个宏能解包一个tar文件,一个能针对解开的包打补丁.
3. The Build Section
编译节
Like the prep section, the build section consists of a shell script. Asyou might guess, this section is
used to perform whatever commands are required to actually compile thesources. This section
could consist of a single make command, or be more complex if thebuild process requires it. Since
most software is built today using make, there are no macrosavailable in this section.
像准备节一样,编译节由一个shell脚本组成.如你所想,该节执行编译源码时的一系列命令.该节可以由一个make命令组成,也可能变得复杂依据编译过程的要求.由于目前大多数软件都使用make编译,该节没有可用的宏.
4. The Install Section
安装节
Also containing a shell script, the install section is used to perform thecommands required to actually
install the software. If the software's author added an install target inthe makefile, this section
might only consist of a make install command. Otherwise, you'llneed to add the usual assortment
of cp, mv, or install commands to get the job done.
也是一个shell脚本,用来执行安装软件所需的一系列命令.如果软件作者在makefile里写了安装路径,该节可以仅有make install命令.否则,你将需要增加类似cp, mv, 或者install的命令来完成安装.
5. Install and Uninstall Scripts
安装与反安装脚本节
While the previous sections contained either information required by RPMto build the package, or
the actual commands to do the deed, this section is different. It consistsof scripts that will be run, on
the user's system, when the package is actuallyinstalled or removed. RPM can execute a script:
• Prior to the package being installed.
• After the package has been installed.
• Prior to the package being erased.
• After the package has been erased.
One example of when this capability would be required is when a packagecontains shared libraries.
In this case, ldconfig would need to be run after the package isinstalled or erased. As another example,
if a package contains a shell, the file /etc/shells would need to be updated appropriately
when the package was installed or erased.
该节不同于前面的节包含编包所需要的信息或者需要执行的命令.本节包含了当包被安装或者移除时需要运行的脚本.RPM可以在一下四种情况下执行一个脚本:
1. 在包正要被安装前
2. 在包已经被安装后
3. 在包正要被移除前
4. 在包已经被移除后
例子1,当一个包包含共享链接库时,需要在包安装或者移除后运行ldconfig命令.例子2,如果一个包含一个shell,在包安装或者移除后需要更新/etc/shells文件.
6. The Verify Script
验证脚本节
This is another script that is executed on the user's system. It isexecuted when RPM verifies the
package's proper installation. While RPM does most of the work verifyingpackages, this script can
be used to verify aspects of the package that are beyond RPM'scapabilities.
这是用户系统上需要执行的另一个脚本.它用来验证包是否正确安装.RPM能完成验证包的大部分操作,这个脚本可以用来验证RPM验证不到的地方.
7. The Clean Section
清理节
Another script that can be present is a script that can clean things upafter the build. This script is
rarely used, since RPM normally does a good job of clean-up in most buildenvironments.
一个用来清理编译后的残余文件的脚本.由于RPM通常能够很好地清理编译后的环境,这个脚本很少使用
8. The File List
文件列表节
The last section consists of a list of files that will comprise thepackage. Additionally, a number of
macros can be used to control file attributes when installed, as well asto denote which files are documentation,and which contain configurationinformation. The file list is very important — if it is
missing, no package will be built.
该节包含了该包的文件列表.此外,有一系列的宏可以用来控制文件安装后的属性,指明哪些文件是文档以及哪些文件包含配置信息.文件列表节非常重要,如果漏写,将直接导致编包失败.
REF:
http:// rpm5.org/docs/max-rpm.pdf