  RPM HOWTO
  Donnie Barnes, djb@redhat.com,  Alex Ott
  ott@phtd.tpu.edu.ru
  v2.0, 8  1997
  ____________________________________________________________

  Table of Contents


  1. 

  2. 

  3.  

     3.1  RPM
     3.2  RPM

  4.  RPM

  5.   

  6.   RPM

     6.1  rpmrc
     6.2 Spec-
     6.3 
     6.4  Prep
     6.5  Build
     6.6  Install
     6.7       / 
     6.8  Files
     6.9  
        6.9.1    
        6.9.2   
        6.9.3   
        6.9.4     RPM
     6.10  
     6.11       RPMs
     6.12  ?

  7.  RPM   

     7.1  spec-
     7.2  Optflags
     7.3 
     7.4    
     7.5 

  8.    



  ______________________________________________________________________

   ::      , 
  .

  11..  

  RPM  RRed Hat PPackage MManager (  RedHat).   
   Red Hat   ,     
         . 
         
           , 
          , 
     .      
       ,     
         / .


  Red Hat Software      
    RPM      
  . RPM       
  ,        .
       ,     
     .    
     RPM     GPL.


      RPM    Ed Bailey, _M_a_x_i_m_u_m
  _R_P_M.         www.redhat.com
  <http://www.redhat.com>.


  22..  

        RPM.   
         ``''
   .  RPP (     
  RPM   ______)    ``'', 
     .   -  
       RPP     . 
             
    ,    .  
      .  RPM  
       ,  
   .      . 
   .     ,   
           RHL.
       (patch),    
   .       
     .


  RPM  ,     .  
             
   .       
       .   RPM  
  ,         
  , -      
            . 
    _______ .


     --   .    
  ,        ,  
  .      .     
   ,   .  
    .


         BOGUS 
      ,    RPM.  RPM 
    Red Hat Software,     ,
   BOGUS (PM  PMS).


  33..   



  33..11..   RRPPMM

     RPM   Red Hat Linux.   
    ,        
  RPM.      ftp.redhat.com
  <ftp://ftp.redhat.com/pub/redhat/code/rpm>.


  33..22..   RRPPMM

      RPM   cpio 2.4.2  .
         Linux,  
       Unix-.  
    SunOS, Solaris, AIX, Irix, AmigaOS,  .
   ,  ,    
   Unix   .


       RPM.   RPM 
   ,       
   ,  gcc, make,  ..


  44..   RRPPMM

     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.rpm





  ,  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.


  55..     --    RRPPMM??

  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 1996
       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 -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6..    RRPPMM

    RPM  ,     
   ,     
    .

       RPM :


    ,   /etc/rpmrc    .

             RPM 
      .

        ,    
        .

     spec-  .

    ,     .

       RPM.

    , RPM       
   .


  66..11..   rrppmmrrcc

   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   . 
      /etc/rpmrc     spec-. 
    ,    0.    
    require_distribution  require_group.

      distribution.    
       spec-.    
          ,
     .   vendor   , 
      (, Joe's Software and Rock Music
  Emporium).

  RPM        
  .  rpmrc    ``optflags'' 
   ,      
    .      
    .

      ,   .  
   :


       rpm --showrc




            .


  66..22..  SSppeecc--

      spec-. Spec-   
  . Spec-      
          
   .


       spec-  
  .    :  --
  --  ()--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6..33..  

      ,   
  .    .  
     :


    Summary:    .

    Name:         rpm,  
      .

    Version:         rpm, 
       .

    Release:          
     (,      ,   
           ,   
        2).

    Icon:    ,    
        ( ``glint''  Red
     Hat).      gif    
     SOURCES.

    Source:      ""  
     .        
         . :    
             
        (    
       ).       
          :



       Source0: blah-0.tar.gz
       Source1: blah-1.tar.gz
       Source2: fooblah.tar.gz





        SOURCES. (
       "  
  ").

    Patch:       ,   
       . :   
            
      .    ,     
              
     .     - :



       Patch0: blah-0.patch
       Patch1: blah-1.patch
       Patch2: fooblah.patch





        SOURCES.

    Copyright:        
     .    -  GPL, BSD, MIT, public
     domain, distributable,  commercial.

    BuildRoot:       
     ``''      .  
              
      .

    Group:      
       (  ``glint'' Red Hat)  
           .  
          :


















  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      ,  
             .
             / . 
      ,     
        .
  66..44..   PPrreepp

      spec-.     
     .      
          
    ,     
  make.


   :       
      .    
  sh-      %prep   
     .     
     .


        %setup.    
  (  ),      
   cd    .    
  :


    -n name       
       name.     $NAME-$VERSION. 
        $NAME, ${NAME}${VERSION},  
        . (,    
     ``$'' __     
     spec-.       . 
             , 
       ).

    -c    __   .

    -b #    Source# __  cd 
      (      -c   
      ).        
     .

    -a #    Source# _____  
     .

    -T         
         -b 0  -a 0   
        .      
        .

    -D __    .     
         setup.    
     ______   setup _____  (     
     ).


        %patch.  
        
  .    ,  :


    #   Patch#   .

    -p #      
     patch(1).

    -P    --  Patch ( Patch0).  
            0 
          .    
      ( )  %patch,   
          .

        %patch#   : %patch
     # -P


       .      
  ,       , 
  ,    sh.      
  %build (   )   sh.
           
      .


  66..55..   BBuuiilldd

       .    
          
         
  ,         . 
       sh,     sh
     ( )   
           
   ,    .    
     .


  66..66..   IInnssttaallll

        .   
      .    
    make install,     .  
   ,       makefile,  
   make install     make install,   
        sh.   
          
  .


  66..77..  //      
  

           
     .     -- 
      ldconfig   
   ,    .  
       :


    %pre     .

    %post     .

    %preun       .

    %postun       .


       sh ,   __ 
    #!/bin/sh.


  66..88..   FFiilleess

      ______     .  RPM
          
   make install. __    . 
     find     . 
         
         ,  
       .


         .
      :


    %doc       
     ,      .  
        /usr/doc/$NAME-$VERSION-$RELEASE. 
            
           ,  
        .

    %config      
     .      sendmail.cf, passwd, 
     ..       
     ,         
           .rpmsave  
     .        .

    %dir        
        .  ,    
      ___  %dir,  ___    
              .

    %files -f <filename>      
           . 
            ,  
         .    
              
     .


        
  .     /usr/bin,    
    ___    /usr/bin   .


  66..99..   

  66..99..11..     

       --    
  .     /etc/rpmrc. 
      /usr/src.


          :


    BUILD         RPM.
               
     ,     RPM    .

    SOURCES        
         .    RPM   
      .

    SPECS       spec-.


    RPMS    RPM     RPM  
     .

    SRPMS      RPM   .


  66..99..22..    

         --  
      RPM.    
         $NAME.orig.   
    .      
  .       
     .   -  
    .      
  ,    .    
      configure.    
         .  
   - :



               diff -uNr dirname.orig dirname > ../SOURCES/dirname-linux.patch




      ,      
  spec-.   ``linux'',      
    .     -
     ``config''  ``bugs''   ______ 
    .       ,
    ,       
     .


  66..99..33..    

       ,      
      .    
           
    spec-.    spec-  
    .       
     ,       
    .


  66..99..44..      RRPPMM

     spec-,       .
       --   
   :



               rpm -ba foobar-1.0.spec





         -b:


    p     prep spec-.

    l   ,     
     %files.

    c   prep  .    , 
             .  
     , -       
             
     RPM,      RPM   
        .

    i  prep,   .

    b  prep, , ,   
     .

    a   (       ).

       -b. :


    --short-circuit      
     (    c  i).

    --clean      .

    --keep-temps        
       /tmp.       
        /tmp   -v.

    --test     ,   keep-temp.


  66..1100..   

             ,
     .      --- 
       ,    
     .       
    make install   ,     
  .


     rpm -u packagename   ,  
     -     
   make install.    -   
  ,      .    
    ,        , 
      .     ,   
   rpm -ba package,      
      rpm -i package.   ,   
      build  install,    
       .


  66..1111..        RRPPMMss

          RPM  -
  (       RPM)    
     ( ,   RPM 
  ).       
     ftp.redhat.com <ftp://ftp.redhat.com>.





  66..1122..   ??

      " "  "  
     RPM".       RPM
            
  .        
         .  __________
   ,     ________ ________________
  ___________ ___________.     
  shareware __          
   ,      .
      Netscape, ssh, pgp,  ..


  77..   RRPPMM   

   RPM       Intel i386,
  Digital Alpha   Linux  the Sparc.   , 
  RPM   SGI    HP.   
  ,        .
        ``optflags''   /etc/rpmrc.
          
       
   .     ``arch'' 
  spec-.         
        . 
      ``Exclude''  .


  77..11..   ssppeecc--

      spec-   ``fileutils''. 
       Alpha   Intel .

































  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7..22..   OOppttffllaaggss

         ``optflags''  
   /etc/rpmrc.        
   ,    
  RPM_OPT_FLAGS.    Makefile   
      ,    
   (  -m486  -O2).   
           
  ,       Makefile. 
      Makefile     
    .


  77..33..  

   %ifarch  .      
    ,     . 
    RPM        
  .

    , fileutils    64-
  . ,        Alpha. 
      %ifarch   64- 
   :

       %ifarch axp
       %patch1 -p1
       %endif




    ,       
     alpha.


  77..44..     

             
         ``''
      .     
      :



       rpm --rebuild /usr/src/SRPMS/*.rpm




      .     
     ,      
     :



       ExcludeArch: axp




    spec-    .  
          .  
      ,     
  Intel        Alpha.


  77..55..  

   RPM      
   ,        
  .         
     .


  88..     

         .
        
   .      
       .










