📄 0283-0285.html
字号:
<HTML>
<HEAD>
<TITLE>Maximum RPM (RPM):Real-World Package Building: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=20 //-->
<!-- PAGES=0275-0304 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0279-0282.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0286-0289.html">Next</A>
</CENTER></P>
<!-- END CODE //--><A NAME="PAGENUM-283"><P>Page 283</P></A><!-- CODE //-->
<PRE>
# if cpp is not on your path, try one of these:
-# CPP=/lib/cpp # traditional
+CPP=/lib/cpp # traditional
# CPP=/usr/lib/cpp # also traditional
# CPP=/usr/ccs/lib/cpp # Solaris 2.x
#
</PRE>
<!-- END CODE //-->
<P>The patch file contains complete copies of our
config.h and options.h files, followed by the changes we've made to
munge. Looks good! Time to hand this grunt work over to RPM.
</P>
<H4><A NAME="ch20_ 11">
20.3.2. Making a First-Cut Spec File
</A></H4>
<P>Since amanda comes in two parts, it's obvious that we'll need to use subpackages: one for
the client software and one for the server. Given that, and the fact that the first part of any spec
file consists of tags that are easily filled in, let's sit down and fill in the blanks, tag-wise:
</P>
<!-- CODE //-->
<PRE>
Summary: Amanda Network Backup System
Name: amanda
Version: 2.3.08
Release: 1
Group: System/Backup
Copyright: BSD-like, but see COPYRIGHT file for details
Packager: Edward C. Bailey <bailey@rpm.org>
URL:
http://www.cs.umd.edu/projects/amanda/
Source: ftp://ftp.cs.umd.edu/pub/amanda/amanda-2.3.0.tar.gz
Patch: amanda-2.3.0-linux.patch
%description
Amanda is a client/server backup system. It uses standard tape
devices and networking, so all you need is any working tape drive
and a network. You can use it for local backups as well.
</PRE>
<!-- END CODE //-->
<P>That part was pretty easy. We set the package's release number to
1. We'll undoubtedly be changing that as we continue work on the spec file. You'll notice that we've included a
URL tag line; the uniform resource locator there points to the home page for the amanda project,
making it easier for the user to get additional information on amanda.
</P>
<P>The Source tag here includes the name of the original source
tar file and is preceded by the URL pointing to the file's primary location. Again, this makes it easy for the user to grab
a copy of the sources from the software's "birthplace."
</P>
<P>Finally, the patch file that we've just created gets a line of its own on the
Patch tag line.
</P>
<P>
Next, let's take a look at the tags for our two subpackages. Let's start with the client:
</P>
<!-- CODE //-->
<PRE>
%package client
Summary: Client-side Amanda package
Group: System/Backup
Requires: dump
%description client
The Amanda Network Backup system contains software necessary to
automatically perform backups across a network. Amanda consists of
two packages -- a client (this package), and a server:
</PRE>
<!-- END CODE //--><A NAME="PAGENUM-284"><P>Page 284</P></A><!-- CODE //-->
<PRE>
The client package enable a network-capable system to have its
filesystems backed up by a system running the Amanda server.
</PRE>
<!-- END CODE //-->
<TABLE BGCOLOR=#FFFF99><TR><TD>NOTE:</TD></TR><TR><TD>
<!-- CODE SNIP //-->
<PRE>
In order for a system to perform backups of itself, install both
the client and server packages!
</PRE>
<!-- END CODE SNIP //-->
</TD></TR></TABLE>
<P>The %package directive names the package. Because we wanted the subpackages
to be named amanda-<something>, we didn't use the
-n option. This means our client subpackage will
be called amanda-client, just as we wanted. RPM requires unique
summary, %description, and group tags for each subpackage, so we've included them. Of course, it would be a good idea even
if RPM didn't require them—we've used the tags to provide client-specific information.
</P>
<P>The requires tag is the only other tag in the client subpackage. Because amanda uses
dump on the client system, we included this tag so that RPM will ensure that the
dump package is present on client systems.
</P>
<P>Next, let's take a look at the tags for the server subpackage:
</P>
<!-- CODE //-->
<PRE>
%package server
Summary: Server-side Amanda package
Group: System/Backup
%description server
The Amanda Network Backup system contains software necessary to
automatically perform backups across a network. Amanda consists of
two package -- a client, and a server (this package):
The server package enables a network-capable system to control one
or more Amanda client systems performing backups. The server system
will direct all backups to a locally attached tape drive. Therefore,
the server system requires a tape drive.
</PRE>
<!-- END CODE //-->
<TABLE BGCOLOR=#FFFF99><TR><TD>NOTE:</TD></TR><TR><TD>
<!-- CODE SNIP //-->
<PRE>
In order for a system to perform backups of itself, install both
the client and server packages!
</PRE>
<!-- END CODE SNIP //-->
</TD></TR></TABLE>
<P>No surprises here, really. You'll note that the server subpackage has no
requires tag for the dump package. The reason for that is due to a design decision we've made. Since amanda is
comprised of a client and a server component, in order for the server system to perform backups
of itself, the client component must be installed. Since we've already made the client
subpackage require dump, we've already covered the bases.
</P>
<P>Since an amanda server cannot back itself up without the client software, why don't we
have the server subpackage require the client subpackage? Well, that could be done, but the fact
of the matter is that there are cases where an amanda server won't need to back itself up. So
the server subpackage needs no package requirements.
</P>
<H4><A NAME="ch20_ 12">
20.3.2.1. Adding the Build-Time Scripts
</A></H4>
<P>Next we need to add the build-time scripts. There's really not much to them:
</P>
<!-- CODE SNIP //-->
<PRE>
%prep
%setup
</PRE>
<!-- END CODE SNIP //--><A NAME="PAGENUM-285"><P>Page 285</P></A><!-- CODE SNIP //-->
<PRE>
%build
make
%install
make install
</PRE>
<!-- END CODE SNIP //-->
<P>The %prep script consists of one line containing the simplest flavor of
%setup macro. Since we only need %setup to unpack one set of sources, there are no options we need to add.
</P>
<P>The %build script is just as simple, with the single
make command required to build amanda.
</P>
<P>Finally, the %install script maintains our singe-line trend for build-time scripts. Here a
simple make install will put all the files where they need to be for RPM to package them.
</P>
<H4><A NAME="ch20_ 13">
20.3.2.2. Adding %files Lists
</A></H4>
<P>The last part of our initial attempt at a spec file is a
%files list for each package the spec file will build. Because we're planning on a client and a server subpackage, we'll need two
%files lists. For the time being, we'll just add the
%files lines; we'll be adding the actual filenames later:
</P>
<!-- CODE SNIP //-->
<PRE>
%files client
%file server
</PRE>
<!-- END CODE SNIP //-->
<P>There's certainly more to come, but this is enough to get us started. And the first thing
we want RPM to do is to unpack the amanda sources.
</P>
<H4><A NAME="ch20_ 14">
20.3.3. Getting the Original Sources Unpacked
</A></H4>
<P>In keeping with a step-by-step approach, RPM has an option that let's us stop the build
process after the %prep script has run. Let's give the
-bp option a try and see how things look:
</P>
<!-- CODE //-->
<PRE>
# rpm -bp amanda-2.3.0.spec
* Package: amanda
* Package: amanda-client
* Package: amanda-server
+ umask 022
+ echo Executing: %prep
Executing: %prep
+ cd /usr/src/redhat/BUILD
+ cd /usr/src/redhat/BUILD
+ rm -rf amanda-2.3.0
+ gzip -dc /usr/src/redhat/SOURCES/amanda-2.3.0.tar.gz
+ tar -xvvf -
drwxr-xr-x 3/20 0 May 19 22:10 1996 amanda-2.3.0/
-rw-r--r-- 3/20 1389 May 19 22:11 1996 amanda-2.3.0/COPYRIGHT
-rw-r--r-- 3/20 1958 May 19 22:11 1996 amanda-2.3.0/Makefile
-rw-r--r-- 3/20 11036 May 19 22:11 1996 amanda-2.3.0/README
...
-rw-r--r-- 3/20 2010 May 19 22:11 1996 amanda-2.3.0/man/amtape.8
drwxr-xr-x 3/20 0 May 19 22:11 1996 amanda-2.3.0/tools/
-rwxr-xr-x 3/20 2437 May 19 22:11 1996 amanda-2.3.0/tools/munge
+ [ 0 -ne 0 ]
+ cd amanda-2.3.0
</PRE>
<P><CENTER>
<a href="0279-0282.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0286-0289.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -