📄 0255-0259.html
字号:
<HTML>
<HEAD>
<TITLE>Maximum RPM (RPM):Creating Subpackages: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=18 //-->
<!-- PAGES=0247-0262 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0251-0254.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0260-0262.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-255"><P>Page 255</P></A>
<!-- CODE //-->
<PRE>
Summary: The foo app, and the baz library needed to build it
Group: bogus/junque
%description
This is the long description of the foo app, and the baz library needed to
build it...
%package server
Summary: The foo server
Group: bogus/junque
%package client
Summary: The foo client
Group: bogus/junque
%package -n bazlib
Version: 5.6
Summary: The baz library
Group: bogus/junque
%files
/usr/local/foo-file
%files server
/usr/local/server-file
%files client
/usr/local/client-file
%files -n bazlib
/usr/local/bazlib-file
</PRE>
<!-- END CODE //-->
<P>As you can see, we've added %files lists for
</P>
<UL>
<LI> The main
foo package
<LI> The
foo-server subpackage
<LI> The
foo-client subpackage
<LI> The
bazlib subpackage
</UL>
<P>Each package contains a single file. (Hey, we said it was a simple example!) If there was no
need for a main package, we could simply remove the unnamed
%files list. Keep in mind that even if you do not create a main package, the tags defined in the main package's preamble
will appear somewhere—specifically, in the source package file.
</P>
<P>Let's look at the last subpackage-specific part of the spec file: the install and erase time scripts.
</P>
<H4><A NAME="ch18_ 17">
18.4.3. Install and Erase Time Scripts
</A></H4>
<P>The install and erase time scripts, %pre,
%preun, %post, and %postun, can all be named using exactly the same method as was used for the other subpackage-specific sections of the spec
file. The script used during package verification,
%verifyscript, can be made package specific as
</P>
<A NAME="PAGENUM-256"><P>Page 256</P></A>
<P>well. Using the subpackage structure from our sample spec file, we would end up with
script definitions like this:
</P>
<UL>
<LI> %pre server
<LI> %postun client
<LI> %preun -n bazlib
<LI> %verifyscript client
</UL>
<P>Other than the change in naming, there's only one thing to be aware of when creating
scripts for subpackages. It's important that you consider the possibility of scripts from
various subpackages interacting with each other. Of course, this is simply good script-writing
practice, even if the packages involved are not related.
</P>
<H4><A NAME="ch18_ 18">
18.4.3.1. Back at the Spec File
</A></H4>
<P>Here we've added some scripts to our spec file. So that our example doesn't get too
complex, we've just added preinstall scripts for each package:
</P>
<!-- CODE //-->
<PRE>
Name: foo
Version: 2.7
Release: 1
Source: foo-2.7.tgz
CopyRight: probably not
Summary: The foo app, and the baz library needed to build it
Group: bogus/junque
%description
This is the long description of the foo app, and the baz library needed to
build it...
%package server
Summary: The foo server
Group: bogus/junque
%description server
This is the long description for the foo server...
%package client
Summary: The foo client
Group: bogus/junque
%description client
This is the long description for the foo client...
%package -n bazlib
Version: 5.6
Summary: The baz library
Group: bogus/junque
%description -n bazlib
This is the long description for the bazlib...
%pre
echo "This is the foo package preinstall script"
%pre server
echo "This is the foo-server subpackage preinstall script"
</PRE>
<!-- END CODE //-->
<A NAME="PAGENUM-257"><P>Page 257</P></A>
<!-- CODE //-->
<PRE>
%pre client
echo "This is the foo-client subpackage preinstall script"
%pre -n bazlib
echo "This is the bazlib subpackage preinstall script"
%files
/usr/local/foo-file
%files server
/usr/local/server-file
%files client
/usr/local/client-file
%files -n bazlib
/usr/local/bazlib-file
</PRE>
<!-- END CODE //-->
<P>As preinstall scripts go, these don't do very much. But they will allow us to see how
subpackage-specific scripts can be defined.
</P>
<P>Those of you who have built packages probably realize that our spec file is missing
something. Let's add that part now.
</P>
<H3><A NAME="ch18_ 19">
18.5. Build-Time Scripts: Unchanged for <BR>
Subpackages
</A></H3>
<P>Although creating subpackages changes the general structure of the spec file, there's one
section that doesn't change: the build-time scripts. This means there is only one set of
%prep, %build, and %install scripts in any spec file.
</P>
<P>Of course, even if RPM doesn't require any changes to these scripts, you still might need
to make some subpackage-related changes to them. Normally these changes are related to
doing whatever is required to get all the software unpacked, built, and installed. For example, if
packaging client/server software, the software for both the client and the server must be
unpacked, and then both the client and server binaries must be built and installed.
</P>
<H4><A NAME="ch18_ 20">
18.5.1. Our Spec File: One Last Look
</A></H4>
<P>Let's add some build time scripts and take a final look at the spec file:
</P>
<!-- CODE //-->
<PRE>
Name: foo
Version: 2.7
Release: 1
Source: foo-2.7.tgz
CopyRight: probably not
Summary: The foo app, and the baz library needed to build it
Group: bogus/junque
%description
</PRE>
<!-- END CODE //-->
<A NAME="PAGENUM-258"><P>Page 258</P></A>
<!-- CODE //-->
<PRE>
This is the long description of the foo app, and the baz library needed to
build it...
%package server
Summary: The foo server
Group: bogus/junque
%description server
This is the long description for the foo server...
%package client
Summary: The foo client
Group: bogus/junque
%description client
This is the long description for the foo client...
%package -n bazlib
Version: 5.6
Summary: The baz library
Group: bogus/junque
%description -n bazlib
This is the long description for the bazlib...
%prep
%setup
%build
make
%install
make install
%pre
echo "This is the foo package preinstall script"
%pre server
echo "This is the foo-server subpackage preinstall script"
#%pre client
echo "This is the foo-client subpackage preinstall script"
%pre -n bazlib
echo "This is the bazlib subpackage preinstall script"
%files
/usr/local/foo-file
%files server
/usr/local/server-file
%files client
/usr/local/client-file
%files -n bazlib
/usr/local/bazlib-file
</PRE>
<!-- END CODE //-->
<P>As you can see, the build time scripts are about as simple as they can be. This is the
advantage to making up an example. A more real-world spec file would undoubtedly have more
interesting scripts.
</P>
<A NAME="PAGENUM-259"><P>Page 259</P></A>
<H3><A NAME="ch18_ 21">
18.6. Building Subpackages
</A></H3>
<P>Now it's time to give our sample spec file a try. The build process is not that much
different from that of a single-package spec file:
</P>
<!-- CODE //-->
<PRE>
# rpm -ba foo-2.7.spec
Package: foo
Package: foo-server
Package: foo-client
Package: bazlib
...
Executing: %prep
...
Executing: %build
...
Executing: %install
...
Executing: special doc
+ cd /usr/src/redhat/BUILD
+ cd foo-2.7
+ DOCDIR=//usr/doc/foo-2.7-1
+ DOCDIR=//usr/doc/foo-server-2.7-1
+ DOCDIR=//usr/doc/foo-client-2.7-1
+ DOCDIR=//usr/doc/bazlib-5.6-1
+ exit 0
Binary Packaging: foo-2.7-1
Finding dependencies...
usr/local/foo-file
1 block
Generating signature: 0
Wrote: /usr/src/redhat/RPMS/i386/foo-2.7-1.i386.rpm
Binary Packaging: foo-server-2.7-1
Finding dependencies...
usr/local/server-file
1 block
Generating signature: 0
Wrote: /usr/src/redhat/RPMS/i386/foo-server-2.7-1.i386.
rpm Binary Packaging: foo-client-2.7-1
Finding dependencies...
usr/local/client-file
1 block
Generating signature: 0
Wrote: /usr/src/redhat/RPMS/i386/foo-client-2.7-1.i386.rpm
Binary Packaging: bazlib-5.6-1
Finding dependencies...
usr/local/bazlib-file
1 block
Generating signature: 0
Wrote: /usr/src/redhat/RPMS/i386/bazlib-5.6-1.i386.rpm
...
Source Packaging: foo-2.7-1
foo-2.7.spec
foo-2.7.tgz
4 blocks
Generating signature: 0
Wrote: /usr/src/redhat/SRPMS/foo-2.7-1.src.rpm
#
</PRE>
<!-- END CODE //-->
<P><CENTER>
<a href="0251-0254.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0260-0262.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -