⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appendix-e.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- END CODE SNIP //-->



<H4>

E.4.1.6. The -a &lt;n&gt; Option

</H4>



<P>The -a option is used to direct %setup to unpack the source archive specified on the

nth source tag line after changing directories into the build directory:

</P>

<!-- CODE SNIP //-->

<PRE>

%setup -D -T -a 5

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.4.2. The %patch Macro

</H4>



<P>The %patch macro, as its name implies, is used to apply patches to the unpacked sources.

With no additional options specified, it will apply the patch file specified by the

patch (or patch0) tag:

</P>

<!-- CODE SNIP //-->

<PRE>

%patch

</PRE>

<!-- END CODE SNIP //-->



<P>When there is more than one patch tag line in a spec file, they can be specified by

appending the number of the patch tag to the

%patch macro name itself:

</P>

<!-- CODE SNIP //-->

<PRE>

%patch2

</PRE>

<!-- END CODE SNIP //-->



<A NAME="PAGENUM-398"><P>Page 398</P></A>



<P>For more information about the patch tag and the related options described in this section,

see section 13.4.2 in Chapter 13.

</P>



<H4>

E.4.2.1. The -P &lt;n&gt; Option

</H4>



<P>The -P option is another method of applying a specific patch. The number from the

patch tag follows the -P option. The following

%patch macros both apply the patch specified on the

patch2 tag line:

</P>

<!-- CODE SNIP //-->

<PRE>

%patch -P 2

%patch2

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.4.2.2. The -p&lt;#&gt; Option

</H4>



<P>The -p option is sent directly to the patch command. It is followed by a number that

specifies the number of leading slashes (and the directories in between) to strip from any filenames

present in the patch file:

</P>

<!-- CODE SNIP //-->

<PRE>

%patch -p2

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.4.2.3. The -b &lt;name&gt; Option

</H4>



<P>When the patch command is used to apply a patch, unmodified copies of the files patched

are renamed to end with the extension .orig. The

-b option is used to change the extension used by

patch:

</P>

<!-- CODE SNIP //-->

<PRE>

%patch -b .fsstnd

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.4.2.4. The %patch -E Option

</H4>



<P>The -E option is sent directly to the patch command. It is used to direct

patch to remove any empty files after the patches have been applied.

</P>

<!-- CODE SNIP //-->

<PRE>

%patch -E

</PRE>

<!-- END CODE SNIP //-->



<H3>

E.5. The %files List

</H3>



<P>The %files list indicates which files on the build system are to be packaged. The list consists

of one file per line:

</P>

<!-- CODE SNIP //-->

<PRE>

%files

/etc/foo.conf

/sbin/foo

/usr/bin/foocmd

</PRE>

<!-- END CODE SNIP //-->



<A NAME="PAGENUM-399"><P>Page 399</P></A>



<P>If a directory is specified, by default all files and subdirectories will be packaged.

</P>



<P>You can make the %files list specific to a particular subpackage by adding the subpackage

name and, optionally, the -n option:

</P>

<!-- CODE SNIP //-->

<PRE>

%files bar



%files -n bar

</PRE>

<!-- END CODE SNIP //-->



<P>The subpackage name and the usage of the -n option must match those defined with the

%package directive.

</P>



<P>The %files list can also use the contents of a file as the list of files to be packaged. This is

done by using the -f option, which is then followed by a filename:

</P>

<!-- CODE SNIP //-->

<PRE>

%files -f files.list

</PRE>

<!-- END CODE SNIP //-->



<P>For more information, see section 13.5 in Chapter 13.

</P>



<H3>

E.6. Directives for the %files List

</H3>



<P>The directives outlined in the following sections are used to modify various attributes of one

or more entries in the %files list.

</P>



<H4>

E.6.1. File-Related Directives

</H4>



<P>The directives outlined in the following sections modify

%files list entries that are files. For more information about these directives, see section 13.6.1.

</P>



<H4>

E.6.1.1. The %doc Directive

</H4>



<P>The %doc directive flags the filename(s) that follow it as being documentation:

</P>

<!-- CODE SNIP //-->

<PRE>

%doc README

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.6.1.2. The %config Directive

</H4>



<P>The %config directive is used to flag the specified file as being a configuration file:

</P>

<!-- CODE SNIP //-->

<PRE>

%config /etc/fstab

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.6.1.3. The %attr Directive

</H4>



<P>The %attr directive is used to permit RPM to directly control a file's permissions and

ownership. It is normally used when non-root users build packages. The

%attr directive has the following format:

</P>

<!-- CODE SNIP //-->

<PRE>

%attr(&lt;mode&gt;, &lt;user&gt;, &lt;group&gt;) file

</PRE>

<!-- END CODE SNIP //-->



<A NAME="PAGENUM-400"><P>Page 400</P></A>



<P>The user and group identifiers must be non-numeric. Attributes that do not need to be set

by %attr may be replaced with a dash:

</P>

<!-- CODE SNIP //-->

<PRE>

%attr(755, root, -) foo.bar

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.6.1.4. The %verify Directive

</H4>



<P>The %verify directive is used to control which of nine different file attributes are to be

verified by RPM. The attributes are

</P>



<UL>

<LI>          owner&#151;The file's

owner.

<LI>          group&#151;The file's

group.

<LI>          mode&#151;The file's mode.

<LI>          md5&#151;The file's MD5 checksum.

<LI>          size&#151;The file's size.

<LI>          maj&#151;The file's major number.

<LI>          min&#151;The file's minor number.

<LI>     

symlink&#151;The file's symbolic link string.

<LI>     

mtime&#151;The file's modification time.

</UL>



<P>One or more of these attributes may be listed in each

%verify directive:

</P>

<!-- CODE SNIP //-->

<PRE>

%verify(mode md5 size maj min symlink mtime) /dev/ttyS0

</PRE>

<!-- END CODE SNIP //-->



<P>If the keyword not precedes the list of attributes, every attribute except those listed will be

verified.

</P>



<H4>

E.6.2. Directory-Related Directives

</H4>



<P>The directives outlined in the following sections modify

%files list entries that are directories. For more information about these directives, see section 13.6.2 in Chapter 13.

</P>



<H4>

E.6.2.1. The %docdir Directive

</H4>



<P>The %docdir directive is used to add the specified directory to RPM's internal list of

directories containing documentation. When a directory is added to this list, every file packaged in

this directory (and any subdirectories) will automatically be marked as documentation.

</P>



<H4>

E.6.2.2. The %dir Directive

</H4>



<P>The %dir directive is used to direct RPM to package only the directory itself, regardless of

what files may reside in the directory at the time the package is created:

</P>



<!-- CODE SNIP //-->

<PRE>

%dir /usr/blather

</PRE>

<!-- END CODE SNIP //-->



<A NAME="PAGENUM-401"><P>Page 401</P></A>



<H3>

E.7. The %package Directive

</H3>



<P>The %package directive is used to control the creation of subpackages. The subpackage name

is derived from the first name tag in the spec file, followed by the name specified after the %package directive. Therefore, if the first

name tag is

</P>



<!-- CODE SNIP //-->

<PRE>

Name: foo

</PRE>

<!-- END CODE SNIP //-->



<P>and a subpackage is defined with the following

%package directive:

</P>

<!-- CODE SNIP //-->

<PRE>

%package bar

</PRE>

<!-- END CODE SNIP //-->



<P>the subpackage name will be foo-bar.

</P>



<P>For more information on this package and its options, see section 13.7 in Chapter 13.

</P>



<H4>

E.7.1. The %package -n Option

</H4>



<P>The -n option is used to change how RPM derives the subpackage name. When the -n

option is used, the name following the %package directive becomes the complete subpackage

name. Therefore, if a subpackage is defined with the following

%package directive:

</P>

<!-- CODE SNIP //-->

<PRE>

%package -n bar

</PRE>

<!-- END CODE SNIP //-->



<P>the subpackage name will be bar.

</P>



<H3>

E.8. Conditionals

</H3>



<P>The %ifxxx conditionals are used to begin a section of the spec file that is specific to a

particular architecture or operating system. They are followed by one or more architecture or

operating system specifiers, each separated by commas or whitespace.

</P>



<P>Conditionals may be nested within other conditionals, provided that the inner conditional

is completely enclosed by the outer conditional. For more information about conditionals,

see section 13.8 in Chapter 13.

</P>



<H4>

E.8.1. The %ifarch Conditional

</H4>



<P>If the build system's architecture is specified, the part of the spec file following the

%ifarch but before an %else or %endif will be used during the build:

</P>

<!-- CODE SNIP //-->

<PRE>

%ifarch i386 sparc

</PRE>

<!-- END CODE SNIP //-->





<A NAME="PAGENUM-402"><P>Page 402</P></A>



<H4>

E.8.2. The %ifnarch Conditional

</H4>



<P>If the build system's architecture is specified, the part of the spec file following the

%ifarch but before an %else or %endif will not be used during the build:

</P>

<!-- CODE SNIP //-->

<PRE>

%ifnarch i386 sparc

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.8.3. The %ifos Conditional

</H4>



<P>If the build system is running one of the specified operating systems, the part of the spec

file following the %ifos but before an %else or

%endif will be used during the build:

</P>

<!-- CODE SNIP //-->

<PRE>

%ifos linux

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.8.4. The %ifnos Conditional

</H4>



<P>If the build system is running one of the specified operating systems, the part of the spec

file following the %ifnos but before an %else or

%endif will not be used during the build:

</P>

<!-- CODE SNIP //-->

<PRE>

%ifnos linux

</PRE>

<!-- END CODE SNIP //-->



<H4>

E.8.5. The %else Conditional

</H4>



<P>The %else conditional is placed between an %if conditional of some persuasion and an

%endif. It is used to create two blocks of spec file statements, only one of which will be used in

any given case:

</P>

<!-- CODE //-->

<PRE>

%ifarch alpha

make RPM_OPT_FLAGS=&quot;$RPM_OPT_FLAGS -I .&quot;

%else

make RPM_OPT_FLAGS=&quot;$RPM_OPT_FLAGS&quot;

%endif

</PRE>

<!-- END CODE //-->



<H4>

E.8.6. The %endif Conditional

</H4>



<P>An %endif is used to end a conditional block of spec file statements. The

%endif is always needed after a conditional; otherwise, the build will fail:

</P>



<!-- CODE SNIP //-->

<PRE>

%ifarch i386

make INTELFLAG=-DINTEL

%endif</PRE>

<!-- END CODE SNIP //-->





<P><CENTER>

<a href="appendix-d.html">Previous</a> | <a href="ewtoc.html">Table of Contents</a> | <a href="appendix-f.html">Next</a></CENTER></P>







</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -