📄 appendix-e.html
字号:
E.2.4.3. The excludeos Tag
</H4>
<P>The excludeos tag is used to direct RPM to ensure that the package does not attempt to
build on the excluded operating system(s):
</P>
<!-- CODE SNIP //-->
<PRE>
ExcludeOS: linux irix
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.2.4.4. The exclusiveos Tag
</H4>
<P>The exclusiveos tag is used to denote which operating system(s) should be exclusively
permitted to build the package:
</P>
<!-- CODE SNIP //-->
<PRE>
ExclusiveOS: linux
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.2.5. Directory-Related Tags
</H4>
<P>Directory-related tags are used to define certain directory-related aspects of RPM's
operation. For more information about these tags, see section 13.2.5.
</P>
<H4>
E.2.5.1. The prefix Tag
</H4>
<P>The prefix tag is used to define part of the path RPM will use when installing the
package's files:
</P>
<!-- CODE SNIP //-->
<PRE>
Prefix: /opt
</PRE>
<!-- END CODE SNIP //-->
<P>The prefix can be redefined by the user when the package is installed, thereby changing
where the package is installed.
</P>
<H4>
E.2.5.2. The buildroot Tag
</H4>
<P>The buildroot tag is used to define an alternate build root, where the software will be
installed during the build process:
</P>
<!-- CODE SNIP //-->
<PRE>
BuildRoot: /tmp/cdplayer
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-393"><P>Page 393</P></A>
<H4>
E.2.6. Source and Patch Tags
</H4>
<P>The source and patch tags are used to define the names of the files that contain the
package's source code, and patches. For more information about these tags see section 13.2.6 in
Chapter 13.
</P>
<H4>
E.2.6.1. The source Tag
</H4>
<P>The source tag is used to define the filename of the sources to be packaged:
</P>
<!-- CODE SNIP //-->
<PRE>
Source0: ftp://ftp.gnomovision.com/pub/cdplayer-1.0.tgz
Source1: foo.tgz
</PRE>
<!-- END CODE SNIP //-->
<P>When there is more than one source tag in a spec file, each one must be numbered so it
is unique, starting with the number 0. When there is only one tag, it does not need to be
numbered. By convention, the source filename is usually preceded by a URL pointing to the
location of the original sources, but RPM does not require this.
</P>
<H4>
E.2.6.2. The nosource Tag
</H4>
<P>The nosource tag is used to make RPM aware that one or more source files should be
excluded from the source package file:
</P>
<!-- CODE SNIP //-->
<PRE>
NoSource: 0, 3
</PRE>
<!-- END CODE SNIP //-->
<P>The tag is followed by one or more numbers. The numbers correspond to the numbers
following the source tags that are to be excluded from packaging.
</P>
<H4>
E.2.6.3. The patch Tag
</H4>
<P>The patch tag is used to define the name of a patch file to be applied to the package's sources:
</P>
<!-- CODE SNIP //-->
<PRE>
Patch: cdp-0.33-fsstnd.patch
</PRE>
<!-- END CODE SNIP //-->
<P>When there is more than one patch tag in a spec file, each one must be numbered so it is
unique, starting with the number 0. When there is only one tag, it does not need to be numbered.
</P>
<H4>
E.2.6.4. The nopatch Tag
</H4>
<P>The nopatch tag is used to make RPM aware that one or more patch files should be
excluded from the source package file:
</P>
<!-- CODE SNIP //-->
<PRE>
NoPatch: 2 3
</PRE>
<!-- END CODE SNIP //-->
<P>The tag is followed by one or more numbers. The numbers correspond to the numbers
following the patch tags that are to be excluded from packaging.
</P>
<A NAME="PAGENUM-394"><P>Page 394</P></A>
<H3>
E.3. Scripts
</H3>
<P>Scripts are used by RPM to perform processing at various times.
</P>
<H4>
E.3.1. Build Time Scripts
</H4>
<P>Every build time script has the following environment variables defined:
</P>
<UL>
<LI> RPM_SOURCE_DIR
<LI> RPM_BUILD_DIR
<LI> RPM_DOC_DIR
<LI> RPM_OPT_FLAGS
<LI> RPM_ARCH
<LI> RPM_OS
<LI> RPM_ROOT_DIR
<LI> RPM_BUILD_ROOT
<LI> RPM_PACKAGE_NAME
<LI> RPM_PACKAGE_VERSION
<LI> RPM_PACKAGE_RELEASE
</UL>
<P>For more information on these environment variables and build time scripts, see section
13.3.1 in Chapter 13.
</P>
<H4>
E.3.1.1. The %prep Script
</H4>
<P>The %prep script is the first script RPM executes during a build:
</P>
<!-- CODE SNIP //-->
<PRE>
%prep
</PRE>
<!-- END CODE SNIP //-->
<P>As the name implies, it is normally used to prepare the sources for building. The commands
in the script can be any valid sh commands.
</P>
<H4>
E.3.1.2. The %build Script
</H4>
<P>The %build script is the second script RPM executes during a build:
</P>
<!-- CODE SNIP //-->
<PRE>
%build
</PRE>
<!-- END CODE SNIP //-->
<P>As the name implies, it is normally used to build the software. The commands in the script
can be any valid sh commands.
</P>
<A NAME="PAGENUM-395"><P>Page 395</P></A>
<H4>
E.3.1.3. The %install Script
</H4>
<P>The %install script is the third script RPM executes during a build:
</P>
<!-- CODE SNIP //-->
<PRE>
%install
</PRE>
<!-- END CODE SNIP //-->
<P>As the name implies, it is normally used to install the software. The commands in the
script can be any valid sh commands.
</P>
<H4>
E.3.1.4. The %clean Script
</H4>
<P>The %clean script, as the name implies, is used to clean up the software's build directory tree:
</P>
<!-- CODE SNIP //-->
<PRE>
%clean
</PRE>
<!-- END CODE SNIP //-->
<P>RPM will normally do this for you, but in certain cases (most notably in those packages
that use a build root) you'll need to include a
%clean script. The commands in the script can be
any valid sh commands.
</P>
<H4>
E.3.2. Install and Erase Time Scripts
</H4>
<P>Install time and erase time scripts are executed whenever the package is installed or erased,
respectively. Each script can consist of any valid
sh commands.
</P>
<P>You can make each of the following scripts specific to a particular subpackage by adding
the subpackage name and, optionally, the -n option:
</P>
<!-- CODE SNIP //-->
<PRE>
%post bar
%preun -n bar
</PRE>
<!-- END CODE SNIP //-->
<P>The subpackage name and usage of the -n option must match those defined with the
%package directive.
</P>
<P>Each script has the following environment variable defined:
</P>
<UL>
<LI> RPM_INSTALL_PREFIX
</UL>
<P>For more information on this environment variable and the associated scripts, see section
13.3.2 in Chapter 13.
</P>
<H4>
E.3.2.1. The %pre Script
</H4>
<P>The %pre script executes just before the package is to be installed:
</P>
<!-- CODE SNIP //-->
<PRE>
%pre
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.3.2.2. The %post Script
</H4>
<P>The %post script executes just after the package is to be installed:
</P>
<!-- CODE SNIP //-->
<PRE>
%post
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-396"><P>Page 396</P></A>
<H4>
E.3.2.3. The %preun Script
</H4>
<P>The %preun script executes just before the package is to be erased:
</P>
<!-- CODE SNIP //-->
<PRE>
%preun
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.3.2.4. The %postun Script
</H4>
<P>The %postun script executes just after the package is to be erased:
</P>
<!-- CODE SNIP //-->
<PRE>
%postun
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.3.3. Verification Scripts
</H4>
<P>Verification scripts are executed when an installed package is to be verified.
</P>
<H4>
E.3.3.1. The %verifyscript Script
</H4>
<P>The %verifyscript script executes whenever the package is verified using RPM's
-V option. The script can consist of any valid sh commands.
</P>
<P>For more information, see section 13.3.3 in Chapter 13.
</P>
<H3>
E.4. Macros
</H3>
<P>Macros are used to simplify certain types of repetitive operations.
</P>
<H4>
E.4.1. The %setup Macro
</H4>
<P>The %setup macro is used to unpack the original sources in preparation for the build. It is
used in the %prep script:
</P>
<!-- CODE SNIP //-->
<PRE>
%prep
%setup
</PRE>
<!-- END CODE SNIP //-->
<P>For more information about the %setup macro and the related options described in this
section, see section 13.4.1 in Chapter 13.
</P>
<H4>
E.4.1.1. The -n <name> Option
</H4>
<P>The -n option is used to set the name of the software's build directory:
</P>
<!-- CODE SNIP //-->
<PRE>
%setup -n cd-player
</PRE>
<!-- END CODE SNIP //-->
<P>This is necessary only when the source archive unpacks into a directory named other than
<name>-<version>.
</P>
<A NAME="PAGENUM-397"><P>Page 397</P></A>
<H4>
E.4.1.2. The -c Option
</H4>
<P>The -c option is used to direct %setup to create the top-level build directory before
unpacking the sources:
</P>
<!-- CODE SNIP //-->
<PRE>
%setup -c
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.4.1.3. The -D Option
</H4>
<P>The -D option is used to direct %setup to not delete the build directory prior to unpacking
the sources:
</P>
<!-- CODE SNIP //-->
<PRE>
%setup -D -T -b 3
</PRE>
<!-- END CODE SNIP //-->
<P>This option is used when more than one source archive is to be unpacked into the build
directory, normally with the -b or -a option.
</P>
<H4>
E.4.1.4. The -T Option
</H4>
<P>The -T option is used to direct %setup to not perform the default unpacking of the source
archive specified by the first source tag. It is used with the
-a or -b options:
</P>
<!-- CODE SNIP //-->
<PRE>
%setup -D -T -a 1
</PRE>
<!-- END CODE SNIP //-->
<H4>
E.4.1.5. The -b <n> Option
</H4>
<P>The -b option is used to direct %setup to unpack the source archive specified on the
nth source tag line before changing directories into the build directory:
</P>
<!-- CODE SNIP //-->
<PRE>
%setup -D -T -b 2
</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -