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

📄 0198-0200.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="0195-0197.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0201-0203.html">Next</A>

</CENTER></P>



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



<P>any files in the %files list that RPM packages from

/usr/blather will be included in the package as usual, but will also be automatically flagged as documentation. This directive is

handy when a package creates its own documentation directory and contains a

large number of files. Let's give it a try by adding the following line to our spec file:

</P>

<!-- CODE SNIP //-->

<PRE>

%docdir /usr/blather

</PRE>

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



<P>Our %files list contains no references to the several files the package installs in the

/usr/blather directory. After building the package, looking at the package's file list shows this:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qlp ../RPMS/i386/blather-1.0-1.i386.rpm

...

#

</PRE>

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



<P>Wait a minute: There's nothing there, not even

/usr/blather! What happened?

</P>



<P>The problem is that %docdir only directs RPM to mark the specified directory as holding

documentation. It doesn't direct RPM to package any files in the directory.

To do that, we need to clue RPM in to the fact that there are files in the directory that must be packaged.

</P>



<P>One way to do this is to simply add the files to the

%files list:

</P>

<!-- CODE SNIP //-->

<PRE>

%docdir /usr/blather

/usr/blather/INSTALL

</PRE>

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



<P>Looking at the package, we see that INSTALL was packaged:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qlp ../RPMS/i386/blather-1.0-1.i386.rpm

...

/usr/blather/INSTALL

#

</PRE>

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



<P>Directing RPM to only show the documentation files, we see that

INSTALL has indeed been marked as documentation, even though the

%doc directive had not been used:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qdp ../RPMS/i386/blather-1.0-1.i386.rpm

...

/usr/blather/INSTALL

#

</PRE>

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



<P>Of course, if you go to the trouble of adding each file to the

%files list, it wouldn't be that much more work to add

%doc to each one. So the way to get the most benefit from

%docdir is to add another line to the %files list:

</P>

<!-- CODE SNIP //-->

<PRE>

%docdir /usr/blather

/usr/blather

</PRE>

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



<P>Since the first line directs RPM to flag any file in

/usr/blather as being documentation, and the second line tells RPM to automatically package any files found in

/usr/blather, every single file in there will be packaged and marked as documentation:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qdp ../RPMS/i386/blather-1.0-1.i386.rpm

/usr/blather

/usr/blather/COPYING



</PRE>

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



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



<!-- CODE SNIP //-->

<PRE>



/usr/blather/INSTALL

/usr/blather/README

...

#

</PRE>

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



<P>The %docdir directive can save quite a bit of effort in creating the

%files list. The only caveat is that you must be sure the directory will only contain files you want marked as

documentation. Keep in mind, also, that all subdirectories of the

%docdired directory will be marked as documentation directories, too.

</P>



<B>

13.6.2.2. The %dir Directive

</B>



<P>As mentioned in section 13.5, if a directory is specified in the

%files list, the contents of that directory, and the contents of every directory under it, will automatically be included in

the package. While this feature can be handy (assuming that you are sure that every file under

the directory should be packaged), there are times when this could be a problem.

</P>



<P>The way to get around this is to use the %dir directive. By adding this directive to the line

containing the directory, RPM will package only the directory itself,

regardless of what files are in the directory at the time the package is created. Here's an example of

%dir in action.

</P>



<P>The blather-1.0 package creates the directory

/usr/blather as part of its build. It also puts several files in that directory. In the spec file, the

/usr/blather directory is included in the %files list:

</P>

<!-- CODE SNIP //-->

<PRE>

%files

...

/usr/blather

...

</PRE>

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



<P>There are no other entries in the %files list that have

/usr/blather as part of their path. After building the package, we use RPM to look at the files in the package:

</P>

<!-- CODE //-->

<PRE>

# rpm -qlp ../RPMS/i386/blather-1.0-1.i386.rpm

...

/usr/blather

/usr/blather/COPYING

/usr/blather/INSTALL

/usr/blather/README

...

#

</PRE>

<!-- END CODE //-->



<P>The files present in /usr/blather at the time the package was built were included in the

package automatically, without entering their names in the

%files list.

</P>



<P>However, after changing the /usr/blather line in the

%files list to this:

</P>

<!-- CODE SNIP //-->

<PRE>

%dir /usr/blather

</PRE>

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



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



<P>and rebuilding the package, a listing of the package's files now includes only the

/usr/blather directory:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -qlp ../RPMS/i386/blather-1.0-1.i386.rpm

...

/usr/blather

...

#

</PRE>

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



<B>

13.6.2.3. -f &lt;file&gt;: Read the %files List from

&lt;file&gt;

</B>



<P>The -f option is used to direct RPM to read the

%files list from the named file. Like the %files list in a spec file, the file named using the

-f option should contain one filename per line and also include any

of the directives named in this section.

</P>



<P>Why is it necessary to read filenames from a file rather than have the filenames in the spec

file? Here's a possible reason: The filenames' paths may contain a directory name that can be

determined only at build time, such as an architecture specification. The list of files, minus the

variable part of the path, can be created, and sed can be used at build time to update the

path appropriately.

</P>



<P>It's not necessary that every filename to be packaged reside in the file. If there are any

filenames present in the spec file, they will be packaged as well:

</P>

<!-- CODE SNIP //-->

<PRE>

%files latex -f tetex-latex-skel

/usr/bin/latex

/usr/bin/pslatex

...

</PRE>

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



<P>Here, the filenames present in the file

tetex-latex-skel would be packaged, followed by

every filename following the %files line.

</P>



<H3>

13.7. The Lone Directive: %package

</H3>



<P>While every directive we've seen so far is used in the

%files list, the %package directive is different. It is used to permit the creation of more than one package per spec file and can appear

at any point in the spec file. These additional packages are known as subpackages.

Subpackages are named according to the contents of the line containing the

%package directive. The format of the package directive is this:

</P>

<!-- CODE SNIP //-->

<PRE>

%package: &lt;string&gt;

</PRE>

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



<P>&lt;string&gt; should be a name that describes the subpackage. This string is appended to the

base package name to produce the subpackage's name. For example, if a spec file contains a

name tag value of foonly and a %package doc line, the subpackage name will be

foonly-doc.

</P>



<P><CENTER>

<a href="0195-0197.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0201-0203.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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