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

📄 0195-0197.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:




<HTML>

<HEAD>

<TITLE>Maximum RPM (RPM):Inside the Spec File:EarthWeb Inc.-</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311054 //-->

<!-- TITLE=Maximum RPM (RPM)//-->

<!-- AUTHOR=Edward Bailey//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=13 //-->

<!-- PAGES=0163-0204 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0192-0194.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0198-0200.html">Next</A>

</CENTER></P>



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





<UL>

<LI>          Control which aspects of a file are to be checked during package verification

<LI>          Eliminate some of the tedium in creating the

%files list

</UL>



<P>In the %files list, one or more directives may be placed on a line, separated by spaces,

before one or more filenames. Therefore, if %foo and

%bar are two %files list directives, they may be applied to a file

baz in the following manner:

</P>

<!-- CODE SNIP //-->

<PRE>

%foo %bar baz

</PRE>

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



<P>Now it's time to take a look at the directives that inhabit the

%files list.

</P>



<H4><A NAME="ch13_ 11">

13.6.1. File-Related Directives

</A></H4>



<P>RPM processes files differently according to their types. However, RPM does not have a

method of automatically determining file types. Therefore, it is up to the package builder to

appropriately mark files in the %files list. This is done using one of the following directives.

</P>



<P>Keep in mind that not every file will need to be marked. As you read the following

sections, you'll see that directives are used only in special circumstances. In most packages, the

majority of files in the %files list will not need to be marked.

</P>



<B>

13.6.1.1. The %doc Directive

</B>



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

being documentation. RPM keeps track of documentation files in its database so that a user can easily find information about an

installed package. In addition, RPM can create a package-specific documentation directory

during installation and copy documentation into it. Whether or not this additional step is

taken depends on how a file is specified. Here is an example:

</P>

<!-- CODE SNIP //-->

<PRE>

%doc README

%doc /usr/local/foonly/README

</PRE>

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



<P>The file README exists in the software's top-level directory during the build and is included

in the package file. When the package is installed, RPM creates a directory in the

documentation directory named the same as the package (that is,

&lt;software&gt;-&lt;version&gt;-&lt;release&gt;) and

copies the README file there. The newly created directory and the

README file are marked in the RPM database as being documentation. The default documentation directory is

/usr/doc and can be changed by setting the

defaultdocdir rpmrc file entry. For more information on

rpmrc files, see Appendix B.

</P>



<P>The file /usr/local/foonly/README was installed into that directory during the build and

is included in the package file. When the package is installed, the

README file is copied into /usr/local/foonly and marked in the RPM database as being documentation.

</P>



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







<B>

13.6.1.2. The %config Directive

</B>



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

performs additional processing for config files when

packages are erased, and during installations and upgrades. This is due to the nature of config files: They are often changed by the

system administrator, and those changes should not be lost.

</P>



<P>There is a restriction to the %config directive: No more than one filename may follow the

%config. This means that the following example is the only allowable way to specify config files:

</P>

<!-- CODE SNIP //-->

<PRE>

%config /etc/foonly

</PRE>

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



<P>Note that the full path to the file, as it is installed at build time, is required.

</P>



<B>

13.6.1.3. The %attr Directive

</B>



<P>The %attr directive permits finer control over three key file attributes:

</P>



<UL>

<LI>          The file's

permissions, or mode

<LI>          The file's user

ID

<LI>          The file's group ID

</UL>



<P>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 //-->



<P>The mode is specified in the traditional numeric format, while the user and group are

specified as a string, such as root. Here's a sample

%attr directive:

</P>

<!-- CODE SNIP //-->

<PRE>

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

</PRE>

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



<P>This would set foo.bar's permissions to 755. The file would be owned by user root, group

root. If a particular attribute does not need to be specified (usually because the file is installed

with that attribute set properly), that attribute may be replaced with a dash:

</P>

<!-- CODE SNIP //-->

<PRE>

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

</PRE>

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



<P>The main reason to use the %attr directive is to permit users without root access to build

packages. The techniques for doing this (and a more in-depth discussion of the

%attr directive) can be found in Chapter 16.

</P>



<B>

13.6.1.4. The %verify Directive

</B>



<P>RPM's ability to verify the integrity of the software it has installed is impressive. But

sometimes it's a bit too impressive. After all, RPM can verify as many as nine

different aspects of every file. The %verify directive can control which of these file attributes are to be

checked

</P>



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







<P>when an RPM verification is done. Here are the attributes, along with the names used by

the %verify directive:

</P>



<UL>

<LI>          Owner

(owner)

<LI>        Group

(group)

<LI>          Mode

(mode)

<LI>          MD5 Checksum

(md5)

<LI>          Size

(size)

<LI>          Major Number

(maj)

<LI>          Minor Number

(min)

<LI>          Symbolic Link String

(symlink)

<LI>          Modification Time

(mtime)

</UL>



<P>How is %verify used? Say, for instance, that a package installs device files. Since the owner

of a device will change, it doesn't make sense to have RPM verify the device file's

owner/group and give out a false alarm. Instead, the following

%verify directive could be used:

</P>

<!-- CODE SNIP //-->

<PRE>

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

</PRE>

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



<P>We've left out owner and group since we'd rather RPM not verify those. (RPM will

automatically exclude file attributes from verification if it doesn't make sense for the type of file. In

our example, getting the MD5 checksum of a device file is an example of such a situation.)

However, if all you want to do is prevent RPM from verifying one or two attributes, you can

use %verify's alternate syntax:

</P>

<!-- CODE SNIP //-->

<PRE>

%verify(not owner group) /dev/ttyS0

</PRE>

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



<P>This use of %verify produces results identical to those in the previous example.

</P>



<H4><A NAME="ch13_ 12">

13.6.2. Directory-Related Directives

</A></H4>



<P>While the two directives in this section perform different functions, each is related to

directories in some way. Let's see what they do.

</P>



<B>

13.6.2.1. The %docdir Directive

</B>



<P>The %docdir directive is used to add a directory to the list of directories that will contain

documentation. RPM includes the directories

/usr/doc, /usr/info, and /usr/man in the %docdir list by default.

</P>



<P>For example, if the following line is part of the

%files list:

</P>

<!-- CODE SNIP //-->

<PRE>

%docdir /usr/blather

</PRE>

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



<P><CENTER>

<a href="0192-0194.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0198-0200.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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