
                            RPM HOWTO (RPM at Idle)
                                       
: Donnie Barnes, djb@redhat.com
: ΰ marr@cc.nccu.edu.tw

   v2.0, 8 April 1997
     _________________________________________________________________
   
   ʹ Red Hat װʽ
     _________________________________________________________________
   
1. Introduction

2. Overview

3. General Information

     * 3.1 Acquiring RPM
     * 3.2 RPM Requirements
       
4. Using RPM

5. Now what can I really do with RPM?

6. Building RPMs

     * 6.1 The rpmrc File
     * 6.2 The Spec File
     * 6.3 The Header
     * 6.4 Prep
     * 6.5 Build
     * 6.6 Install
     * 6.7 Optional pre and post Install/Uninstall Scripts
     * 6.8 Files
     * 6.9 Building It
     * 6.10 Testing It
     * 6.11 What to do with your new RPMs
     * 6.12 What Now?
       
7. Multi-architectural RPM Building

     * 7.1 Sample spec File
     * 7.2 Optflags
     * 7.3 Macros
     * 7.4 Excluding Architectures from Packages
     * 7.5 Finishing Up
       
8. Copyright Notice
     _________________________________________________________________
   
1. Introduction

   RPM ָ Red Hat Package Manager ֮д Ȼϰ Red Hat 
   ֺţ ԭʼǲɿʽģ ʽṩ
   ʹá ͸ rpm Ĺ ʹ߿Խĳ source code 
   װһ source  binary ĵʽ һ ǿɵ
    binary ʽĵ аװ׼׷ٹĹ  source ʽ
    Ҳܷܹٱװ ͬʱ rpm һϿ⣬
   ͷеĳʽ׼ĵϣ ͸Ͽ⣬ ǿԽгʽ
   ׼֮ȷѯ
   
   Red Hat ˾Э̣ һͬչʹ RPM ǵ
   distribution С RPM ൱еԣ ǳ򵥣 ṩϵͳ䷢
   չĻ һ棬 ķչȫ ҿȡã ʹ߿Ի
   κγʽϵĴݡ ֻҪڷ GPL £ ҿ
   ɵʹü RPM ʽ
   
   й RPM ϸļ˵ Բο Ed Bailey ׫֮
   Maximum RPM һ顣 Ȿ [1]www.redhat.com ػ򵽡
   
2. Overview

   ȣ ˽ RPM ѧ ƵĿ֮һ 
   ʹܹʹá source  춴˵㣬 Ǳ RPP 
   ʽ ( һʹõĳʽ׼ϵͳ   RPM û
    ) õ source  Ǿġƽ⴦ 
    ʹ߿˳أ һ RPP ԭʼ  install  make Ķ
     source  òȫǣ ʹ߿޴ӵ֪
   ﵽЩطĹ ͨȡδ source 
    RPM  ʹȡáδ source  ͬʱٸ
   һݡpatch  ɽ֮ɳʽĹ Ǻ׷֣ 
   ٺô ˵أ ٸ״Ϊ  Red Hat Linux £ 
   ĳ°ĳʽˣ ûбҪͷʼ compile  ȹ
   졸patch ݣ ǷЩݲҪġ һ
   ںĳʽԤֵ׿
   
   һ棬 RPM ҲǿĲѯܣ ʽ׼Ͽ⣬
   ĳЩضĵ вѯĶ Ҳɵز ĳ
   ĸʽ׼ ġ RPM Ǿѹģ 
   Ժ׶ٵأ ѯÿʽ׼ݣ Ϊڳʽ׼ Ѿ
   һ binary header ¼ȫѯʱݣ 
    ʹòѯܱ൱١
   
   һǿĹܣ ǳʽ׼ȷϡ ĳ 
   ĳʽ׼Ҫݣ ȷ϶ˡ κβ
   ĵط ֪ͨ ʱ °װóʽ׼ 
   ֮ǰ趨 õر
   
   Ƿǳл BOGUS distribution ĸǣ ṩ룬
   Ҳ RPM С Ȼ RPM ȫ Red Hat Software ׫д
   ģʽǸ BOGUS (PM  PMS) дĳʽ롣
   
3. General Information

3.1 Acquiring RPM

   򵥵ķ Ȼǰװ Red Hat Linux ޣ ӣ
   ȻԴ FTP վ ץȡԭʼʽװ ʽλ
   [2]ftp.redhat.com
   
3.2 RPM Requirements

   ˳ִ RPM  ǡҪ 2.4.2 ϵ cpio ʽ RPM
   ҪƸ Linux ʹõģ  Unix ϵͳҲ൱ 
   ʵϣ Ѿ˳ SunOS Solaris AIX Irix AmigaOS ϵͳ
    compile  ֵעǣ ɲͬ Unix ҵƽ̨
   binary ʽ׼ ǲܱ˴ݵġ
   
   ֻǰװ RPM  Ҫ source  
   Ҫ gcc make ֮ı빤߳ʽ ͽһʽ׼޶¡
   
4. Using RPM

   RPM 춰װʽ׼ϣ 򵥵Ĳʽ£
   
rpm -i foobar-1.0-1.i386.rpm

   һ򵥵Ĳ 춽ĳһʽ׼İװ
   
rpm -e foobar

   ָΪӣ ǳã ͸ FTP װʽ
    ܹ· 밲װĳµĳʽ׼ʱ ´ָ
   ڵǰʵ URL ʽ 磺
   
rpm -i ftp://ftp.pht.com/pub/linux/redhat/rh-2.0-beta/RPMS/foobar-1.0-1.i386.rp
m

   رע⣬ RPM Ŀǰ͸ FTP вѯװ
   
   Щ򵥵ָ rpm ಻ͬѡʽ Щ Usage ˵
   п
   
RPM version 2.3.9
Copyright (C) 1997 - Red Hat Software
This may be freely redistributed under the terms of the GNU Public License

usage: rpm {--help}
       rpm {--version}
       rpm {--initdb}   [--dbpath <dir>]
       rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]
                        [--replacepkgs] [--replacefiles] [--root <dir>]
                        [--excludedocs] [--includedocs] [--noscripts]
                        [--rcfile <file>] [--ignorearch] [--dbpath <dir>]
                        [--prefix <dir>] [--ignoreos] [--nodeps]
                        [--ftpproxy <host>] [--ftpport <port>]
                        file1.rpm ... fileN.rpm
       rpm {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]
                        [--oldpackage] [--root <dir>] [--noscripts]
                        [--excludedocs] [--includedocs] [--rcfile <file>]
                        [--ignorearch]  [--dbpath <dir>] [--prefix <dir>]
                        [--ftpproxy <host>] [--ftpport <port>]
                        [--ignoreos] [--nodeps] file1.rpm ... fileN.rpm
       rpm {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]
                        [--scripts] [--root <dir>] [--rcfile <file>]
                        [--whatprovides] [--whatrequires] [--requires]
                        [--ftpuseport] [--ftpproxy <host>] [--ftpport <port>]
                        [--provides] [--dump] [--dbpath <dir>] [targets]
       rpm {--verify -V -y} [-afpg] [--root <dir>] [--rcfile <file>]
                        [--dbpath <dir>] [--nodeps] [--nofiles] [--noscripts]
                        [--nomd5] [targets]
       rpm {--setperms} [-afpg] [target]
       rpm {--setugids} [-afpg] [target]
       rpm {--erase -e} [--root <dir>] [--noscripts] [--rcfile <file>]
                        [--dbpath <dir>] [--nodeps] [--allmatches]
                        package1 ... packageN
       rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile  <file>]
                        [--sign] [--test] [--timecheck <s>] specfile
       rpm {--rebuild} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm
       rpm {--recompile} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm
       rpm {--resign} [--rcfile <file>] package1 package2 ... packageN
       rpm {--addsign} [--rcfile <file>] package1 package2 ... packageN
       rpm {--checksig -K} [--nopgp] [--nomd5] [--rcfile <file>]
                           package1 ... packageN
       rpm {--rebuilddb} [--rcfile <file>] [--dbpath <dir>]
       rpm {--querytags}

    RPM  man page  ҵЩѡϸ˵
   
5. Now what can I really do with RPM?

   RPM ǸǳõĹߣ ֪ģ ѡܡ ˽
   Щܵ÷ʽ ʵʽܼ ǰѾװ
   װļӣ һЩġ
     * ˵ Сɾ˼ ȷЩ 
       ϵͳȷ϶ ˽ЩݿѾ 
       
rpm -Va

     * ˵ һϲĵ Ҫ֪һʽ׼
       Ļ 
       
rpm -qf /usr/X11R6/bin/xjewel

       õ
       
xjewel-1.6-1

     * ҵһµ RPM  ȴݣ ҪصѶ
        
       
rpm -qpi koules-1.2-2.i386.rpm

       õ
       
Name        : koules                      Distribution: Red Hat Linux Colgate
Version     : 1.2                               Vendor: Red Hat Software
Release     : 2                             Build Date: Mon Sep 02 11:59:12 199
6
Install date: (none)                        Build Host: porky.redhat.com
Group       : Games                         Source RPM: koules-1.2-2.src.rpm
Size        : 614939
Summary     : SVGAlib action game with multiplayer, network, and sound support
Description :
This arcade-style game is novel in conception and excellent in execution.
No shooting, no blood, no guts, no gore.  The play is simple, but you
still must develop skill to play.  This version uses SVGAlib to
run on a graphics console.

     * ˽ĳ RPM  ϵͳﰲװЩ 
       
rpm -qpl koules-1.2-2.i386.rpm

       ǣ
       
/usr/doc/koules
/usr/doc/koules/ANNOUNCE
/usr/doc/koules/BUGS
/usr/doc/koules/COMPILE.OS2
/usr/doc/koules/COPYING
/usr/doc/koules/Card
/usr/doc/koules/ChangeLog
/usr/doc/koules/INSTALLATION
/usr/doc/koules/Icon.xpm
/usr/doc/koules/Icon2.xpm
/usr/doc/koules/Koules.FAQ
/usr/doc/koules/Koules.xpm
/usr/doc/koules/README
/usr/doc/koules/TODO
/usr/games/koules
/usr/games/koules.svga
/usr/games/koules.tcl
/usr/man/man6/koules.svga.6

   ֻһЩ  RPM Ϥʱ ӦĴ
   
   
6. Building RPMs

   Ըȡ壬Ὠ RPM ҲǷǳ򵥵ġ
   
    RPM Ļ£
     * ȷ /etc/rpmrc Ѿϵͳ裬 趨
     * ȡҪ source code
     *  source  patch  ʹ˳ build 
       ʽ
     * Ϊʽ׼׫дһ spec 
     * ȷÿȷĿ¼λá
     * ʹ RPM  build ʽ׼
       
   һвȷ RPM ˳ build  binary  source ʽ׼
   
6.1 The rpmrc File

   ĿǰΪֹ RPM ϵͳΨһ趨 ͸ /etc/rpmrc  
   £
   
require_vendor: 1
distribution: I roll my own!
require_distribution: 1
topdir: /usr/src/me
vendor: Mickiesoft
packager:  Mickeysoft Packaging Account <packages@mickiesoft.com>

optflags: i386 -O2 -m486 -fno-strength-reduce
optflags: alpha -O2
optflags: sparc -O2

signature: pgp
pgp_name: Mickeysoft Packaging Account
pgp_path: /home/packages/.pgp

tmppath: /usr/tmp

   е require_vendor һ Կ RPM ǷҪѰ vendor
   һ  verdor Ѷ /etc/rpmrc  spec 
   header  ĺΪ 0 ܰѰҹܹرա 
   趨ʽ ͬ require_distribution  require_group ϡ
   
    ǿ distribution һУ ڴ趨 
   spec  header 趨 ĳ distribution  build ʽ׼
   ʱ 㲻Ҫѯ趨 ݵ趨ȷ Ҳܹ
   vendor һеã  distribution ǳƣ ݲ޶
   (  Joe's Software  Rock Music Emporium )
   
   RPM Ŀǰ֧Ԯƽ̨ܹĳʽ׼ build ܣ ǿ rpmrc 
   ָ ``optflags''  гʽ׼ build ʱ 
   ƽ̨ͣ Ӧضıݡ ǽڽȥ½ ˵ʹ
   Щ
   
    macro 趨⣬ 趨ʽ ʹã
   
rpm --showrc

   鿴ϵͳ tag ɹʹõ flag Щ
   
6.2 The Spec File

   ڴǽ spec 趨 build һʽ׼ʱ Ҫʹõ
   spec  Ϊóʽ׼˵ ⻹һЩָ ָʾ
    build Ḷ́ һݵб Աʾʽ׼еĵ ֱ
   װ
   
   spec ʽ ѭ׼Ĺ ʽӦΪ package
   name-dash-version number-dash-release number-dot-spec
   
   ǾһС͵ spec Ϊ (vim-3.0-1.spec)
   
Summary: ejects ejectable media and controls auto ejection
Name: eject
Version: 1.4
Release: 3
Copyright: GPL
Group: Utilities/System
Source: sunsite.unc.edu:/pub/Linux/utils/disk-management/eject-1.4.tar.gz
Patch: eject-1.4-make.patch
Patch1: eject-1.4-jaz.patch
%description
This program allows the user to eject media that is autoejecting like
CD-ROMs, Jaz and Zip drives, and floppy drives on SPARC machines.

%prep
%setup
%patch -p1
%patch1 -p1

%build
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"

%install
install -s -m 755 -o 0 -g 0 eject /usr/bin/eject
install -m 644 -o 0 -g 0 eject.1 /usr/man/man1

%files
%doc README COPYING ChangeLog

/usr/bin/eject
/usr/man/man1/eject.1

6.3 The Header

    header Ĳݣ мضλݣ 趨ɣ ⻹
   мע 趨ɵλ£
     * Summary: һгȵ ˵ʽ׼ݡ
     * Name: Ʊ׼ʹõ rpm һ¡
     * Version: 汾Ʊ׼ʹõ rpm һ¡
     * Release: ű׼ʹõ rpm һ¡ ( Ҳ˵
       һʽ׼ ᷢЩСС⣬ 
       build һΣ ʱµĳʽ׼ ䷢ű 2  )
     * Icon: ʹ߽׵İװ߳ʽ (  Red Hat 
       ``glint'' ʽ ) ָӦͼʾ һ
       gif  ұλ SOURCES Ŀ¼
     * Source: ָЩδ source  HOME Ŀ¼ 
       Ҫȡ source  ǼǷ°汾ʱ Ҫõ
       趨 ע ĵ ءϵͳϵĵһ
       ( Ҳ˵  source ᣬ Ҫȥ䵵 ) ͬʱ
       ָһϵ source  ʽ£
       
Source0: blah-0.tar.gz
Source1: blah-1.tar.gz
Source2: fooblah.tar.gz

       Щᵽ SOURCES Ŀ¼ ( صĿ¼ṹ˵ 
       "The Source Directory Tree" ½ )
     * Patch: Ҫ patch  Ŀ¼λ趨춴ˡ ע
        ĵ ϵͳʹõ patch  
       һ棬 ǰ source 趨һ Ҳָ patch
       ơ ʽ£
       
Patch0: blah-0.patch
Patch1: blah-1.patch
Patch2: fooblah.patch

       Щᵽ SOURCES Ŀ¼¡
     * Copyright: 趨 ˵ʽ׼úְȨ  GPL
       BSD MIT public domain distributable commercial ȣ 
       ָġ
     * BuildRoot: ָһĿ¼ ᱻ build  install ³
       ʽ׼ ``root'' Ŀ¼ ʵʰװ֮ǰ вԳʽ
        ô趨
     * Group: 趨 춸߽׵İװ߳ʽ (  Red Hat 
       ``glint'' ʽ ) У ˵ʽȺλá ĿǰȺܹ
        
       
Applications
    Communications
    Editors
        Emacs
    Engineering
    Spreadsheets
    Databases
    Graphics
    Networking
    Mail
    Math
    News
    Publishing
        TeX
Base
    Kernel
Utilities
    Archiving
    Console
    File
    System
    Terminal
    Text
Daemons
Documentation
X11
    XFree86
        Servers
    Applications
        Graphics
        Networking
    Games
        Strategy
        Video
    Amusements
    Utilities
    Libraries
    Window Managers
Libraries
Networking
    Admin
    Daemons
    News
    Utilities
Development
    Debuggers
    Libraries
        Libc
    Languages
        Fortran
        Tcl
    Building
    Version Control
    Tools
Shells
Games

     * %description  header Ŀ ӦͬĿһ
       ͬд ÿʽ׼ӳʽ׼ Ӧһ
       description tag ݣ ʹóʽ׼ܹһ
       꾡˵
       
6.4 Prep

    spec һ½ڣ 趨 source  Թ
   һ build  ƽǱ뾭 setup ʵʽ make 
   ڱ½У ǽҪ source  patch  setup
   
   мֵעģ Ķ趨 ʵָֻĳ shell scripts
   λã Խ shell scripts ݣ  sh script ķʽԴ
     script ʽ %prep tag ֮ᣬ ִ source 
   unpack  patch  Ȼ ԭ֮ macro ʽ ӦǷ
   ġ
   
   һҪ˵ macro  %setup ǲ򵥵ĸʽ ( 
   в ) ᵥؽ source  unpack  cd 
   source Ŀ¼ ֮⣬ ʹеѡ
   
     * -n name ѡ趨 build Ŀ¼Ϊ name ԭԤֵΪ
       $NAME-$VERSION Ŀ¼ư $NAME ${NAME}${VERSION}
        tar õĿ¼ ( ע⵽  ``$''  
        spec ı ֻһƣ 
       ڳʽ׼ ʹʵʵĵ汾 )
     * -c ڽ untar ֮ǰ ȽһĿ¼  cd Ŀ¼
     * -b #  cd Ŀ¼֮ǰ Ƚ Source#  untar  ( ѡ
        -c ѡʱ ûģ Ӧͬʱʹ ) 
       ѡ 춶 source ĳϡ
     * -a #  cd Ŀ¼֮ᣬ ٽ Source#  untar 
     * -T ѡǹԭԤ untar  ͬʱҪһ -b 0  -a
       0 ѡϣ ʹõϵ source ʱ Ҫ
       ܡ
     * -D ڽ⿪ʽ׼֮ǰ ҪɾĿ¼ ѡʹ
        setup macro ֮ϣ ֻ춵һ setup macro ֮ ( ǧ
       춵һ֮ )
       
   Ҫ˵ macro  %patch ЭԶ source µ
    صѡܶ࣬ б˵£
     * #  Patch# ֮µ
     * -p # ʱ patch(1) ָָ strip Ŀ¼Ŀ ڴѡ
       м趨
     * -P Ԥ֮ Patch (  Patch0 ) ʹϵ
       %patch macro Ҫһ macro ֮ͬ patch number ʱ 
       ѡԵ൱á ǹԭԤ趯 Ҫһ 0 
       ʹҪ source Խ untar 
     * Ҳʹ %patch# ʹָ %patch # -P
       
   ЩӦþȫҪ֪֮ macro ˵ ˽֮ᣬ Ҳ͸
   sh ֮ script ʽ 趨ͬ setup   %build macro ( һ
   лἰ ) ֮ǰ 趨֮ѡ Ǿ sh ִУ 
   οһǰġ Ҫ
   
6.5 Build

   ½ Ĳ macro  source  untar 
   patch ɣ cd Ŀ¼֮ᣬ ʼ׼ build ʱ 趨
   Щ build ָ ЩָǴ sh κ sh ָ֮
    ڴָ (  comments  )  spec ÿһ½
   趨У ĿǰĿ¼λã ᱻ趨Ϊ source directory 
   ϲ㣬 μģ Ҫʱ  cd صĿ¼
   
6.6 Install

   趨ģ ͬҲ macro ϣ ֻҪڴ趨һЩ
   install ָ֮ ڳʽ׼ ṩ make install
   ָ趨 ڱ趨ɣ Ȼ ҲԸ makefile 
    й make install Ĳݣ Ȼڱ趨ָ make install
   ǣ Ҳ԰ install ָ sh  ס ĿǰĿ
   ¼λã Ӧѱ趨Ϊ source directory ϲ㡣
   
6.7 Optional pre and post Install/Uninstall Scripts

   ʽ׼ڰװװ֮ǰᣬָ script ʹִ
    дҪԭ֮һ µĳϣ Ʃ˵ ڰ
   װװһЩ shared library ĳʽ׼ʱ Ҫִ ldconfig
   ʽ script ֮ macro £
     * %pre ִ pre-install scripts  macro
     * %post ִ post-install scripts  macro
     * %preun ִ pre-uninstall scripts  macro
     * %postun ִ post-uninstall scripts  macro
       
   Щ趨ݣ κ sh ʽ֮ script  ָ
    #!/bin/sh
   
6.8 Files

   趨У гʽ׼֮ơ RPM ޴ӵ
   ֪ ִ make install ֮ᣬ Щ binary װȥ Ŀǰ
   ֱӽ⡣ Щ˽ install ʽ׼ǰᣬ ʹ
   find ָ һʹߵϵͳ£ Ӧǲеģ Ϊ
   ڳʽ׼ build ĹУ ʽ׼޹صĵ
   
   ⻹һЩ macro ǿһЩĹ Ƚ£
     * %doc Աʾ install ʽ׼ʱ Ҫװ֮ source 
       ˵ļЩ Щ˵ļᱻװ
       /usr/doc/$NAME-$VERSION-$RELEASE ϣ Դ macro ͬ
       ʱָü˵ļƣ Դ macro Ϊһһָ
       
     * %config Աʾʽ׼趨Щ  sendmail.cf
       passwd ֮ĵ  uninstall ĳʽ׼ 
       趨 ûиıĵᱻƳ Ѿıĵ
        ԭ֮ᣬ  .rpmsave ơ ͬģ 
       ڴͬʱгơ
     * %dir ڵбУ ĳһضĿ¼ ˵Ŀ¼Ϊĳʽ
       ӵС ڵбָһĿ¼ƣ ȴûǰ
       %dir macro Ŀ¼ڣ еĿ¼ᱻڵб
        ᣬ ǳʽ׼һݶȫװȥ
     * %files -f <filename>  source ֮ build Ŀ¼ ĳݵ
       ݡ ĳһʽ׼ ԽԼĵ嵥ʱ 
       ѡԵ൱ ֻҪø÷ݵ嵥 
       г
       
   ڵб иע Ŀ¼趨 СĽ
   /usr/bin 룬 ĳʽ׼ ϵͳ /usr/bin µе
   
   
6.9 Building It

  The Source Directory Tree
  
   һ£ ѡһʵ build tree 趨 /etc/rpmrc 
   ɣ ˻ֱʹ /usr/src
   
   ܻҪеĿ¼ ʹ build tree 趨ܹɣ
     * BUILD Ŀ¼ RPM  build ĹĿ¼ ر
       ĸĿ¼вԵ build 
     * SOURCES Ŀ¼ġʼ (original) ԭʼ tar  
        patch  RPM ԤѰұĿ¼
     * SPECS Ŀ¼֮ spec 
     * RPMS Ŀ¼ build ֮ binary ʽ RPM 
     * SRPMS Ŀ¼ source ʽ RPM 
       
  Test Building
  
   ȣ ŻҪȡ source  ûʹ RPM £ һ
   Ρġ build  䲽ǣ ⿪ source  Ŀ¼
   Ϊ $NAME.org Ȼٴν⿪ source  Ҫʹôһ source 
    build  һ source Ŀ¼ ָʾ build 
   ༭κζ Ҫһ patch һ build  
    source Ŀ¼ݡ ȷ configure script  в֮
    Ȼ cd ص source Ŀ¼֮ϲ㣬 ִĶ
   
diff -uNr dirname.orig dirname > ../SOURCES/dirname-linux.patch

   ָһ patch  spec ʹõ ע⵽
   ''linux'' ƣ ֻһʾã ʹƣ 
   ''config''  ''bugs'' ֮ʾƣ ˵һ patch 
    ͬʱ Ҳʹ patch ֮ǰ ȹ۲ͷݣ ȷǷ
    binary 
   
  Generating the File List
  
   ڣ Ѿһݿ build  source  Ҳ֪
   صĶ  build  install ȡ ۲ install ʱ 
    ǽɴ˽  spec нһݵб ͨǻڽ
   ͬʱ һ spec  ɵʼ֣ 
   򵥵Ĳ֣ ȻֵٰĲɡ
   
  Building the Package with RPM
  
   һһ spec  һбѾ ׼ build ĲԶ
   õķʽ ʹеָ
   
rpm -ba foobar-1.0.spec

    -b ѡ ǻʹõѡ
     * p ִָֻ spec ֮ prep ݡ
     * l  %files ебıȶԼ鶯
     * c ִ prep  compile Ķ ȷ source Ƿܹ
       build ʱ ѡԵ൱á ûжô Ϊ
       Ҫ޸ source  ֱ build ٿʼʹ RPM
       һϤ RPM ÷ᣬ ᷢı֮
     * i ִ prep compile  install
     * b ִ prep compile install ֻ build һ binary ʽ׼
       
     * a ִе build  (  source  binary ĳʽ׼ )
       
    -b ѡ ⻹һЩϸѡɹʹã Ƿֱǣ
     * --short-circuit ֱĳضĽ׶ (  c  i ѡʹ
        )
     * --clean ִʱ Ƴص build tree
     * --keep-temps е temp  scripts   /tmp Ŀ¼
       ʹ -v ѡ ʵʹ۲Щ
     * --test ʵִκν׶εĶ ִ keep-temp Ĳݡ
       
6.10 Testing It

   һ source  binary  rpm  вԹ 
   õķʽ ʹһ̨ԣ Ҳǽ build ֮Ļ
   Ͼ Ļϣ һѵ make install  ԭ
   ԣ ȻԵ൱˳ޡ
   
   ִ rpm -u packagename вԣ ٵĿܣ
   Ϊ build ĹУ  make install Ķ ڵб
   ©ĳЩ ᱻװ Ȼ reinstall  binary
   ʽ׼ ᷢϵͳģ ʵϵ rpm 
   ⡣ رס ִе rpm -ba package 
   ˣ ֻ rpm -i package ʽ װĳʽ׼  binary 
   Աװʱ ȷ build  install Ķ趨У ûص
   ݶӰ졣
   
6.11 What to do with your new RPMs

   һһԼ RPM  ( ٶݵ ֮ǰδ RPM ʽ
    ) ԽƷ׸ ( ʱٶ RPM  ǿ
   ɴ ) Կǰϴ [3]ftp.redhat.com
   
6.12 What Now?

   ع½ڣ ڡTesting͡What to do with new RPMs 
   ϣе RPM ܱṩ ϣǶǺõ RPM 
    ˣ ໨һʱúõزǣ Ȼٻʱ佫ϴ 
   츣޴ڡ ͬʱ ȷֻϴɹɴ塣 ҵ빲
   ǲӦñϴģ з档 壬 
   Netscape software ssh pgp ȡ
   
7. Multi-architectural RPM Building

   RPM Ŀǰ build ʽҵƽ̨֮ʽ׼  Intel i386 װ
   Linux ֮ Digital Alpha  Sparc  ˲Ա棬 ˵Ҳ
    SGI  HP վʹá RPM ɫ ʹܹɵ֧Ԯڸ
   ʽҵƽ̨ build ʽ׼ һɫ /etc/rpmrc 
   ``optflags'' 趨Ŀ  build ׼ʱ ָƽ̨
   趨ֵ һɫ spec  ``arch'' macro Ŀ 
   Ҫ build ƽ̨ܹ ִָвͬĹ һɫ
   ڵ header  ``Exclude'' 趨Ŀ
   
7.1 Sample spec File

    ``fileutils'' ʽ׼Ϊ  spec Ĳݣ 
   Alpha  Intel ƽ̨ܹϣ  build Ĺ
   
Summary: GNU File Utilities
Name: fileutils
Version: 3.16
Release: 1
Copyright: GPL
Group: Utilities/File
Source0: prep.ai.mit.edu:/pub/gnu/fileutils-3.16.tar.gz
Source1: DIR_COLORS
Patch: fileutils-3.16-mktime.patch

%description
These are the GNU file management utilities.  It includes programs
to copy, move, list, etc, files.

The ls program in this package now incorporates color ls!

%prep
%setup

%ifarch alpha
%patch -p1
autoconf
%endif
%build
configure --prefix=/usr --exec-prefix=/
make CFLAGS="$RPM_OPT_FLAGS" LDFLAGS=-s

%install
rm -f /usr/info/fileutils*
make install
gzip -9nf /usr/info/fileutils*

.
.
.

7.2 Optflags

   ڴһУ Է ``optflags'' 趨Ŀ  /etc/rpmrc
   зá Ⱦ build Ļ һƽ̨ܹ
   뽫ȷ֮趨ֵ ָ RPM_OPT_FLAGS Գʽ׼֮
   Makefile   patch Ķ һЩͨõı趨ֵ Ըı
   Ļ (  -m486  -O2 )  install  source ׼
   ⿪ source  Makefile  Խһҳõ趨ʽ
   Ȼ۲ Makefile  patch ݣ ˽ǱЩı䡣
   
7.3 Macros

   %ifarch һ macro 趨ĿǷǳҪģ ೡϣ Ҫֻĳһ
   ضƽ̨ܹ һ patch  £ RPM ܹ
   ĳһƽ̨ܹ ñҪ patch
   
   У fileutils иṩ 64 bit ʹõ patch Ե
     patch Ҫ Alpha ã ˣ  64 bit 
   patch ݣ һ %ifarch  macro 趨Ŀ £
   
%ifarch axp
%patch1 -p1
%endif

   ܱ֤  Alpha ֮⣬ ƽ̨ܹĻô
   patch
   
7.4 Excluding Architectures from Packages

   һĿ¼ڣ ͬʱʽҵƽ̨ RPM ԭʼ ʹ
   ʽ׼ʱ ޶ĳЩҵƽ̨ϡ 
   ָ
   
rpm --rebuild /usr/src/SRPMS/*.rpm

   ʹȷĳʽ׼ܹ build δֲĳӦóʽĳһض
   ҵƽ̨ Լһݣ
   
ExcludeArch: axp

    source ʽ׼У spec  header  Ȼԭ build
   ҵƽ̨ϣ һ rebuild  ʱ һ Intel 
    build ɵ source ʽ׼ ͬʱҲױơ Alpha 
   
   
7.5 Finishing Up

   ʹ RPM ҵƽ̨ĳʽ׼ ͨȸڸƽ̨
   ף Խĳʽ׼ ЧӦԣ Ϊ ǿ
   ԲοƵԭʼʽ׼ݣ Դʱ⡣
   
8. Copyright Notice

   ˵ļݣ ܰȨ ԭı δ
    תأ Ҳ˵ ܶԭļŰ桢 ӡ 
   ת¼

References

   1. http://www.redhat.com/
   2. ftp://ftp.redhat.com/pub/redhat/code/rpm
   3. ftp://ftp.redhat.com/
