\documentclass[letterpaper]{article}
\nonstopmode
\akai
\usepackage{linuxdoc-sgml}
\usepackage{qwertz}
\usepackage{url}
\usepackage[latin1]{inputenc}
\usepackage{t1enc}
\usepackage[english]{babel}
\usepackage{epsfig}
\usepackage{null}
\def\addbibtoc{
\addcontentsline{toc}{section}{\numberline{\mbox{}}\relax\bibname}
}%end-preamble
\setcounter{page}{1}
\title{RPM HOWTO (RPM at Idle)}
\author{×÷Õß: Donnie Barnes, {\ttfamily djb@redhat.com}\\ 
        ÒëÕß: ºú³çÎ° {\ttfamily marr@cc.nccu.edu.tw}}
\date{v2.0, 8 April 1997}
\abstract{ÈçºÎÊ¹ÓÃ Red Hat °ü×°¹ÜÀí³ÌÊ½¡£}


\begin{document}
\maketitle
\tableofcontents

\section{Introduction}

RPM Ö¸µÄÊÇ {\bfseries R}ed Hat {\bfseries P}ackage {\bfseries M}anager Ö®ËõÐ´£¬
ËäÈ»Ãû³ÆÉÏ°üº¬Öø Red Hat µÄ×ÖºÅ£¬ µ«ÆäÔ­Ê¼Éè¼ÆÀíÄîÊÇ²É¿ªÊÕÊ½µÄ£¬
ÓÃÒâÔÚì¶ÈÃÕâ¸ö³ÌÊ½ÄÜÌá¹©¸øËùÓÐÈËÊ¹ÓÃ¡£ Í¸¹ý rpm µÄ¹ÜÀí£¬
Ê¹ÓÃÕß¿ÉÒÔ½«Ä³¸öÐÂÈíÌåµÄ source code£¬ ÖØÐÂÕûÀí°ü×°³ÉÁíÒ»ÖÖ source
Óë binary µÄµµ°¸ÐÍÊ½£¬ Èç´ËÒ»À´£¬ ÎÒÃÇ¿ÉÒÔÇáËÉµØÓÉ binary
ÐÍÊ½µÄµµ°¸£¬ ½øÐÐ°²×°ÓëÌ×¼þ×·×Ù¹ÜÀíµÄ¹¤×÷£¬ ¶ø source ÐÍÊ½µÄµµ°¸£¬
Ò²ºÜ·½±ãµØÄÜ¹»ÔÙ±»ÖØÐÂÕûÀí°ü×°¡£ Í¬Ê±£¬ rpm ¹ÜÀíÖøÒ»·Ý×ÊÁÏ¿â£¬
ÀïÍ·°üº¬ÁËËùÓÐµÄ³ÌÊ½Ì×¼þµÄµµ°¸×ÊÁÏ£¬ Í¸¹ýÕâ·Ý×ÊÁÏ¿â£¬
ÎÒÃÇ¿ÉÒÔ½øÐÐ³ÌÊ½Ì×¼þÖ®È·ÈÏÓë²éÑ¯¹¤×÷¡£

Red Hat ¹«Ë¾¹ÄÀøÆäËûÐ­Á¦³§ÉÌ£¬ Ò»Í¬·¢Õ¹¼°Ê¹ÓÃ RPM ì¶ËüÃÇµÄ distribution µ±ÖÐ¡£
RPM Ïàµ±¾ßÓÐµ¯ÐÔ£¬ Æä²Ù×÷·Ç³£¼òµ¥£¬ Ìá¹©ÏµÍ³À©³ä·¢Õ¹µÄ»ù´¡£¬
ÁíÒ»·½Ãæ£¬ ËüµÄ·¢Õ¹ÍêÈ«¹«¿ª£¬ ¶øÇÒ¿ÉÃâ·ÑÈ¡µÃ£¬
Ê¹ÓÃÕß¿ÉÒÔ»Ø¸²ÈÎºÎ³ÌÊ½ÂëÉÏµÄ´íÎóÓëÐÞÕýÄÚÈÝ¡£
Ö»ÒªÔÚ·ûºÏ GPL µÄÐû¸æÌõ¼þÏÂ£¬ ´ó¼Ò¿ÉÒÔ×ÔÓÉµØÊ¹ÓÃ¼°´«²¥ RPM ³ÌÊ½¡£

Èç¹ûÄúÏë»ñµÃÓÐ¹Ø RPM ¸üÏêÏ¸µÄÎÄ¼þËµÃ÷£¬ ¿ÉÒÔ²Î¿¼
Ed Bailey Ëù×«Ö® {\itshape Maximum RPM\/} Ò»Êé¡£ Õâ±¾Êé¿ÉÓÉ
\nameurl{http://www.redhat.com}{www.redhat.com}
ÏÂÔØ»ò¹ºÂòµ½¡£




\section{Overview}

Ê×ÏÈ£¬ ÈÃÎÒÃÇÏÈÀ´ÁË½â RPM ±³ááµÄÉè¼ÆÕÜÑ§£¬ ÆäÉè¼ÆµÄÄ¿µÄÖ®Ò»£¬
±ãÊÇÔÊÐíÊ¹ÓÃÕßÄÜ¹»Ê¹ÓÃ¡¸´¿¾»¡¹µÄ source µµ°¸¡£ ¹Øì¶´Ëµã£¬
ÎÒÃÇ±ØÐë»ØËÝÖÁ RPP ³ÌÊ½£¬ ( ÕâÊÇÒ»¸öÔçÆÚËùÊ¹ÓÃµÄ³ÌÊ½Ì×¼þ¹ÜÀíÏµÍ³£¬
²»¹ý£¬ ááÀ´ RPM {\itshape µ¹Ã»ÓÐ\/}ÓÉÆäÑÜÉú )£¬ ËüËù²ÉÓÃµÄ source µµ°¸£¬
¶¼ÊÇ¾­¹ý¶îÍâµÄ¡¸ÆÆ½â´¦Àí¡¹¡£ ÀíÂÛÉÏ£¬ Ê¹ÓÃÕß¿ÉÒÔË³³©ÎÞÎóµØ£¬
´ÓÒ»·Ý RPP Ô­Ê¼µµ£¬ Íê³É install Óë {\ttfamily make} µÄ¶¯×÷¡£
µ«ÊÇÕâÑù´¦Àí¹ýµÄ source µµ°¸£¬ ÒÑÊÇÃæÃ²È«·Ç£¬ Ê¹ÓÃÕß¿ÉÄÜÎÞ´ÓµÃÖª£¬
µµ°¸Àïµ½µ×ÄÄÐ©µØ·½±»¸ü¸Ä¹ý£¬ Í¨³£±ØÐë¶îÍâÈ¡»ØÎ´¾­´¦Àí¹ýµÄ source µµ°¸¡£
¶ø RPM µÄ×ö·¨£¬ ±ãÊÇÈÃÊ¹ÓÃÕßÈ¡µÃ¡¸Î´¾­´¦Àí¹ýµÄ source µµ°¸¡¹£¬
Í¬Ê±ÔÙ¸½ÉÏÒ»·Ý¡¸patch µµ°¸¡¹£¬ ¿É½åÖ®Íê³É³ÌÊ½±àÒëµÄ¹¤×÷¡£
ÎÒÃÇºÜÈÝÒ×·¢ÏÖ£¬ ÕâÑùµÄ×ö·¨´øÀ´²»ÉÙºÃ´¦¡£ Ôõ÷áËµÄØ£¿
¾Ù¸ö×´¿öÎªÀý£¬ ÔÚ Red Hat Linux ÏÂ£¬ Èç¹ûÄ³¸öÐÂ°æµÄ³ÌÊ½ÎÊÊÀÁË£¬
Äú¿ÉÄÜÃ»ÓÐ±ØÒªÔÙÖØÍ·¿ªÊ¼×ö compile ¶¯×÷£¬ ÏÈ¹Û²ì¡¸patch µµ°¸¡¹µÄÄÚÈÝ£¬
¿´¿´ÊÇ·ñÓÐÄÄÐ©²¿·Ý²ÅÊÇÄú{\itshape ÐèÒª\/}×öµÄ¡£ Èç´ËÒ»À´£¬
ËùÓÐÄÚº¬µÄ³ÌÊ½Ô¤ÉèÖµ±ãºÜÈÝÒ×¿´³öÀ´¡£

ÁíÒ»·½Ãæ£¬ RPM Ò²¾ßÓÐÇ¿´óµÄ²éÑ¯¹¦ÄÜ£¬ Äú¿ÉÒÔÕë¶ÔÕû¸ö³ÌÊ½Ì×¼þµÄ×ÊÁÏ¿â£¬
»òÊÇÄ³Ð©ÌØ¶¨µÄµµ°¸£¬ ½øÐÐ²éÑ¯µÄ¶¯×÷£¬ Ò²¿ÉÒÔÇáËÉµØ²é³ö£¬
Ä³¸öµµ°¸ÊÇÊôì¶ÄÄ¸ö³ÌÊ½Ì×¼þ£¬ »òÊÇËü´ò´ÓÄÄÀïÀ´µÄ¡£
RPM µµ°¸±¾ÉíÊÇ¾­¹ýÑ¹ËõµÄ£¬ µ«Äú»¹ÊÇ¿ÉÒÔºÜÈÝÒ×¶ø{\itshape ¿ìËÙ\/}µØ£¬
²éÑ¯Ã¿¸ö³ÌÊ½Ì×¼þµÄÄÚÈÝ£¬ ÒòÎªÔÚ³ÌÊ½Ì×¼þÀï£¬ ÒÑ¾­¼ÓÈëÒ»¶ÎÌØÊâµÄ
binary header£¬ Ëü¼ÇÂ¼ÁËÈ«²¿²éÑ¯Ê±ËùÐèµÄÄÚÈÝ£¬ ÕâÑùµÄ×ö·¨£¬
Ê¹µÃ²éÑ¯¹¦ÄÜ±äµÃ{\itshape Ïàµ±¿ìËÙ\/}¡£

ÁíÒ»ÏîÇ¿´óµÄ¹¦ÄÜ£¬ ±ãÊÇ³ÌÊ½Ì×¼þµÄÍêÕûÈ·ÈÏ¡£
Èç¹ûÄúµ£ÐÄÎó¿³Ä³¸öµµ°¸£¬ ¶øËüÕýÊÇÄ³¸ö³ÌÊ½Ì×¼þµÄÖØÒª²¿·Ý£¬
ÄÇ÷á×ö¸ö¡¸È·ÈÏ¶¯×÷¡¹¾ÍÐÐÁË¡£ ÈçÓÐÈÎºÎ²»Õý³£µÄµØ·½£¬ ±ã»áÍ¨ÖªÄú£¬
ÕâÊ±ºò£¬ Äú¿ÉÒÔÊÓÇé¿öÖØÐÂ°²×°¸Ã³ÌÊ½Ì×¼þ£¬ ¶øÇÒËùÓÐÖ®Ç°µÄÉè¶¨µµ£¬
¶¼»áÍêºÃµØ±»±£´æÏÂÀ´¡£

ÎÒÃÇ·Ç³£¸ÐÐ»À´×Ô BOGUS distribution µÄ¸ßÊÖÃÇ£¬ ËûÃÇÌá¹©ÁËÐí¶àÒâ¼û¹¹Ïë£¬
ááÀ´Ò²¶¼±»²ÉÓÃì¶ RPM µ±ÖÐ¡£ ËäÈ» RPM ÍêÈ«ÊÇÓÉ Red Hat Software Ëù×«Ð´£¬
µ«Æä²Ù×÷Ä£Ê½ÊÇ¸ù¾Ý BOGUS (PM Óë PMS) ËùÐ´µÄ³ÌÊ½Âë¡£




\section{General Information}




\subsection{Acquiring RPM}

×îºÃÇÒ×î¼òµ¥µÄ·½·¨£¬ µ±È»¾ÍÊÇ°²×° Red Hat Linux ÂÞ£¬
Èç¹ûÄúµÖËÀ²»´Ó£¬ ÄÇ÷áÒÀÈ»¿ÉÒÔ´Ó FTP Õ¾£¬ ×¥È¡Ô­Ê¼³ÌÊ½»ØÀ´°²×°¡£
³ÌÊ½µµ°¸µÄÎ»ÖÃÊÇ
\nameurl{ftp://ftp.redhat.com/pub/redhat/code/rpm}{ftp.redhat.com}¡£




\subsection{RPM Requirements}

Ë³ÀûÖ´ÐÐ RPM µÄ×î´óÌõ¼þ£¬ ¾ÍÊÇ¡¸ÒªÓÐ 2.4.2 °æÒÔÉÏµÄ cpio ³ÌÊ½¡¹¡£
RPM Ö÷ÒªÊÇÉè¼Æ¸ø Linux Ê¹ÓÃµÄ£¬ µ«¶Ôì¶ÆäËû Unix ÏµÍ³µÄÏàÈÝÐÔÒ²Ïàµ±²»´í£¬
ÊÂÊµÉÏ£¬ ËüÒÑ¾­Ë³ÀûÔÚ SunOS¡¢ Solaris¡¢ AIX¡¢ Irix¡¢ AmigaOS
¼°ÆäËûÏµÍ³ÉÏÍê³É compile ¶¯×÷¡£ ÖµµÃ×¢ÒâµÄÊÇ£¬ ÓÉ²»Í¬ Unix
×÷ÒµÆ½Ì¨Ëù±àÒë³öÀ´µÄ binary ³ÌÊ½Ì×¼þ£¬ ÊÇ²»ÄÜ±Ë´ËÏàÈÝµÄ¡£

ÉÏÊöÖ»ÊÇ°²×° RPM µÄ×îµÍÐèÇó£¬ Èç¹ûÏëÒªÓÉ source µµ°¸½¨ÔìÆð£¬
ÄÇ÷áÄú»¹ÐèÒª {\ttfamily gcc}£¬ {\ttfamily make} Ö®ÀàµÄ±àÒë¹¤¾ß³ÌÊ½£¬
ÕâºÍ½¨ÔìÒ»°ã³ÌÊ½Ì×¼þ²¢ÎÞ¶þÖÂ¡£




\section{Using RPM}

RPM ¿ÉÒÔÓÃì¶°²×°³ÌÊ½Ì×¼þÉÏ£¬ ×î¼òµ¥µÄ²Ù×÷¸ñÊ½ÈçÏÂ£º
\begin{tscreen}
\begin{verbatim}
rpm -i foobar-1.0-1.i386.rpm
\end{verbatim}
\end{tscreen}

ÁíÒ»¸ö¼òµ¥µÄ²Ù×÷¡õÀý£¬ ÊÇÓÃì¶½â³ýÄ³Ò»¸ö³ÌÊ½Ì×¼þµÄ°²×°£º
\begin{tscreen}
\begin{verbatim}
rpm -e foobar
\end{verbatim}
\end{tscreen}


½ÓÏÂÀ´µÄÖ¸Áî¡õÀý½ÏÎª¸´ÔÓ£¬ µ«Ëü{\itshape ·Ç³£\/}ÓÐÓÃ£¬ ¿ÉÒÔÈÃÄúÍ¸¹ý FTP
À´°²×°³ÌÊ½Ì×¼þ¡£ Èç¹ûÄúÄÜ¹»Á¬ÉÏÍøÂ·£¬ Ïë°²×°Ä³¸öÐÂµÄ³ÌÊ½Ì×¼þÊ±£¬
ËùÐèÏÂ´ïµÄÖ¸Áî£¬ ±ãÊÇÔÚµµ°¸Ç°¼ÓÉÏÊÊµ±µÄ URL ¸ñÊ½£¬ ÀýÈç£º
\begin{tscreen}
\begin{verbatim}
rpm -i ftp://ftp.pht.com/pub/linux/redhat/rh-2.0-beta/RPMS/foobar-1.0-1.i386.rpm
\end{verbatim}
\end{tscreen}


ÇëÌØ±ð×¢Òâ£¬ RPM Ä¿Ç°ÒÑÔÊÐíÍ¸¹ý FTP À´½øÐÐ²éÑ¯»ò°²×°¡£

ÉÏÊö¶¼ÊÇÐ©¼òµ¥µÄÖ¸Áî£¬ rpm »¹ÓÐÐí¶à²»Í¬µÄÑ¡Ïî·½Ê½£¬
ÕâÐ©¿ÉÓÉ {\ttfamily Usage} µÄËµÃ÷ÖÐ¿´³ö£º
\begin{tscreen}
\begin{verbatim}
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}
\end{verbatim}
\end{tscreen}


Äú¿ÉÒÔÔÚ RPM µÄ man page Àï£¬ ÕÒµ½ÕâÐ©Ñ¡ÏîµÄÏêÏ¸ËµÃ÷¡£




\section{Now what can I {\itshape really\/} do with RPM?}

RPM ÊÇ¸ö·Ç³£ÓÐÓÃµÄ¹¤¾ß£¬ ¶øÇÒÈçÄúËùÖªµÄ£¬ Ëü¾ßÓÐÐí¶àÑ¡Ïî¹¦ÄÜ¡£
ÈÃÄúÁË½âÕâÐ©¹¦ÄÜµÄ×îºÃ·½Ê½£¬ ±ãÊÇÊµ¼Ê½éÉÜ¼¸¸ö¡õÀý£¬
Ç°ÃæÎÒÃÇÒÑ¾­Ìá¹ý°²×°Óë½â³ý°²×°µÄ¼òµ¥Àý×Ó£¬ µ×ÏÂÊÇÒ»Ð©¶îÍâµÄ¡õÀý£º
\begin{itemize}
\item ¼ÙÉèËµ£¬ Äú²»Ð¡ÐÄÎóÉ¾ÁË¼¸¸öµµ°¸£¬ µ«²»È·¶¨µ½µ×ÊÇÄÄÐ©µµ°¸£¬
ÄúÏë¶ÔÕû¸öÏµÍ³½øÐÐÈ·ÈÏ¶¯×÷£¬ ÒÔÁË½âÄÄÐ©²¿·Ý¿ÉÄÜÒÑ¾­ÒÅËð£¬ Äú¿ÉÒÔÕâÑù×ö£º
\begin{tscreen}
\begin{verbatim}
rpm -Va
\end{verbatim}
\end{tscreen}
\item ¼ÙÉèËµ£¬ ÄúÅöµ½Ò»¸öÈÏ²»³öÀ´µÄµµ°¸£¬
ÏëÒªÖªµÀËüÊÇÊôì¶ÄÄÒ»¸ö³ÌÊ½Ì×¼þµÄ»°£¬ Äú¿ÉÒÔÕâÑù×ö£º
\begin{tscreen}
\begin{verbatim}
rpm -qf /usr/X11R6/bin/xjewel
\end{verbatim}
\end{tscreen}

Æä½á¹û»áµÃµ½£º
\begin{tscreen}
\begin{verbatim}
xjewel-1.6-1
\end{verbatim}
\end{tscreen}
\item Èç¹ûÄúÕÒµ½Ò»¸öÐÂµÄ RPM µµ°¸£¬ È´²»Çå³þËüµÄÄÚÈÝ£¬
ÏëÒª»ñµÃÏà¹ØµÄ×ÊÑ¶£¬ ¿ÉÒÔÕâÑù×ö£º
\begin{tscreen}
\begin{verbatim}
rpm -qpi koules-1.2-2.i386.rpm
\end{verbatim}
\end{tscreen}

Æä½á¹û»áµÃµ½£º
\begin{tscreen}
\begin{verbatim}
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.
\end{verbatim}
\end{tscreen}
\item Èç¹ûÄúÏëÁË½âÄ³¸ö RPM µµ°¸£¬ »áÔÚÏµÍ³Àï°²×°ÄÄÐ©µµ°¸£¬
Äú¿ÉÒÔÕâÑù×ö£º
\begin{tscreen}
\begin{verbatim}
rpm -qpl koules-1.2-2.i386.rpm
\end{verbatim}
\end{tscreen}

Æä½á¹û»áÊÇ£º
\begin{tscreen}
\begin{verbatim}
/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
\end{verbatim}
\end{tscreen}
\end{itemize}


ÉÏÊöÖ»ÊÇÒ»Ð©¡õÀý£¬ µ±Äú¶Ô RPM Óú¼ÓÊìÏ¤Ê±£¬
Ó¦¸ÃÄÜÏë³öÆäËû¸ü¶àµÄ´´Òâ×éºÏ¡£






\section{Building RPMs}



Èç¹ûÄú¿ÉÒÔ×Ô¸ö¶ùÈ¡µÃËùÐèµÄÈíÌå£¬ÄÇ÷á½¨Ôì RPM µµ°¸Ò²ÊÇ·Ç³£¼òµ¥µÄ¡£

½¨Ôì RPM µµ°¸µÄ»ù±¾²½ÖèÈçÏÂ£º
\begin{itemize}
\item È·¶¨ÄúµÄ {\ttfamily /etc/rpmrc} ÒÑ¾­·ûºÏÏµÍ³ËùÐè£¬ Íê³ÉÉè¶¨¡£
\item È¡»ØËùÒª½¨ÔìµÄ source code¡£
\item ½øÐÐËùÐèµÄ source µµ°¸ patch ¶¯×÷£¬ ÒÔÊ¹µÃÎÒÃÇÄÜË³ÀûµØ
build Õû¸ö³ÌÊ½¡£
\item Îª³ÌÊ½Ì×¼þ×«Ð´Ò»·Ý spec µµ°¸¡£
\item È·ÈÏÃ¿¸öµµ°¸¶¼ÔÚÕýÈ·µÄÄ¿Â¼Î»ÖÃ¡£
\item Ê¹ÓÃ RPM À´ build Õû¸ö³ÌÊ½Ì×¼þ¡£
\end{itemize}


Èç¹ûÒ»ÇÐ²Ù×÷ÕýÈ·£¬ RPM ±ãÄÜË³Àû build Íê³É binary Óë source ³ÌÊ½Ì×¼þ¡£








\subsection{The rpmrc File}



Ä¿Ç°ÎªÖ¹£¬ RPM ÏµÍ³Î¨Ò»µÄÉè¶¨µµ£¬ ÊÇÍ¸¹ý {\ttfamily /etc/rpmrc} µµ°¸À´¹ÜÀí¡£
ÆäÄÚÈÝ¡õÀýÈçÏÂ£º
\begin{tscreen}
\begin{verbatim}
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
\end{verbatim}
\end{tscreen}


µµ°¸ÖÐµÄ {\ttfamily require\_vendor} ÕâÒ»ÐÐÐðÊö£¬ ÓÃÒÔ¿ØÖÆ RPM
ÊÇ·ñÐëÒªÕÒÑ° vendor ÄÇÒ»ÐÐÐðÊö£¬ ¶ø verdor µÄ×ÊÑ¶¿ÉÄÜÀ´×Ô
{\ttfamily /etc/rpmrc} »òÊÇ spec µµ°¸µÄ header ´¦¡£ Èç¹ûÄú°ÑÉÏÊöµÄºÅÂë¸ÄÎª
{\ttfamily 0}£¬ ±ãÄÜ°ÑÕâÏîÑ°ÕÒ¹¦ÄÜ¹Ø±Õ¡£ ÕâÑùµÄÉè¶¨·½Ê½£¬
Í¬ÑùÊÊÓÃì¶ {\ttfamily require\_distribution} Óë {\ttfamily require\_group} µÄÐðÊöÉÏ¡£

½ÓÏÂÀ´£¬ ÎÒÃÇ¿´µ½ {\ttfamily distribution} ÕâÒ»ÐÐ£¬ Äú¿ÉÒÔÔÚ´ËÉè¶¨£¬ »òÊÇÈÕááÔÚ
spec µµ°¸µÄ header ´¦Éè¶¨¡£ µ±ÎÒÃÇÔÚÄ³¸ö distribution ÉÏ build ³ÌÊ½Ì×¼þÊ±£¬
¾ÍËã²»ÐèÒª²éÑ¯Éè¶¨£¬ ´ËÐÐÄÚÈÝµÄÉè¶¨ÕýÈ·£¬ Ò²ÊÇÄÜ¹»´øÀ´Ðí¶à±ãÀû¡£
{\ttfamily vendor} ÄÇÒ»ÐÐµÄ×÷ÓÃ£¬ ºÍÉÏÊöµÄ distribution ·Ç³£ÏàËÆ£¬
µ«ÆäÄÚÈÝ²¢²»ÏÞ¶¨ ( ÀýÈçÊÇ Joe's Software »ò Rock Music Emporium )¡£

RPM Ä¿Ç°Ö§Ô®¡¸¶àÆ½Ì¨¼Ü¹¹¡¹µÄ³ÌÊ½Ì×¼þ build ¹¦ÄÜ£¬ ÎÒÃÇ¿ÉÒÔÔÚ {\ttfamily rpmrc}
µµ°¸ÀïÖ¸¶¨ ``optflags'' ±äÊý£¬ µ±½øÐÐ³ÌÊ½Ì×¼þ build ¶¯×÷Ê±£¬
±ã¿ÉÒÀ¾ÝËùÐèµÄÆ½Ì¨ÀàÐÍ£¬ Ó¦ÓÃÌØ¶¨µÄ±äÊýÄÚÈÝ¡£ ÎÒÃÇ½«»áÔÚ½ÓÏÂÈ¥µÄÕÂ½ÚÀï£¬
ËµÃ÷ÈçºÎÊ¹ÓÃÕâÐ©±äÊý¡£

³ýÁËÉÏÊöµÄ macro Éè¶¨Íâ£¬ »¹ÓÐÐí¶àÆäËûµÄÉè¶¨·½Ê½£¬ Äú¿ÉÒÔÊ¹ÓÃ£º
\begin{tscreen}
\begin{verbatim}
rpm --showrc
\end{verbatim}
\end{tscreen}

À´²é¿´ÏµÍ³µÄ tag Óë¿É¹©Ê¹ÓÃµÄ flag ÓÐÄÄÐ©¡£




\subsection{The Spec File}

ÔÚ´ËÎÒÃÇ½«ÌÖÂÛ spec µµ°¸µÄÉè¶¨¡£ build Ò»¸ö³ÌÊ½Ì×¼þÊ±£¬ ÎÒÃÇÐèÒªÊ¹ÓÃµ½
spec µµ°¸£¬ ÆäÄÚÈÝÎª¸Ã³ÌÊ½Ì×¼þµÄËµÃ÷£¬ ¶îÍâ»¹°üÀ¨Ò»Ð©Ö¸Áî£¬
ÓÃÒÔÖ¸Ê¾Õû¸ö build µÄ¹ý³Ì£¬ »¹ÓÐÒ»·Ýµµ°¸ÁÐ±í£¬ ÓÃÒÔ±íÊ¾³ÌÊ½Ì×¼þÖÐµÄµµ°¸£¬
·Ö±ð±»°²×°µ½ÄÄÀï¡£

spec µµ°¸µÄÃüÃû·½Ê½£¬ ×îºÃÊÇ×ñÑ­±ê×¼µÄ¹ßÀý£¬ Æä¸ñÊ½Ó¦¸ÃÎª
package name-dash-version number-dash-release number-dot-spec¡£

ÕâÀïÎÒÃÇ¾ÙÒ»¸öÐ¡ÐÍµÄ spec µµ°¸ÎªÀý (vim-3.0-1.spec)£º
\begin{tscreen}
\begin{verbatim}
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
\end{verbatim}
\end{tscreen}





\subsection{The Header}

µµ°¸ header µÄ²¿·Ý£¬ ÓÐ¼¸¸öÌØ¶¨µÄÀ¸Î»ÄÚÈÝ£¬ Äú±ØÐë¼ÓÒÔÉè¶¨Íê³É£¬
ÁíÍâ»¹ÓÐ¼¸µã×¢ÒâÊÂÏî¡£ Äú±ØÐëÉè¶¨Íê³ÉµÄÀ¸Î»ÄÚÈÝÈçÏÂ£º
\begin{itemize}
\item {\ttfamily Summary:} ÒÔÒ»ÐÐ³¤¶ÈµÄÃèÊö£¬ À´ËµÃ÷³ÌÊ½Ì×¼þµÄÄÚÈÝ¡£
\item {\ttfamily Name:} Õâ¸öµµ°¸Ãû³Æ±ØÐëÓëÄú×¼±¸Ê¹ÓÃµÄ rpm µµÃûÒ»ÖÂ¡£
\item {\ttfamily Version:} Õâ¸ö°æ±¾Ãû³Æ±ØÐëÓëÄú×¼±¸Ê¹ÓÃµÄ rpm µµÃûÒ»ÖÂ¡£
\item {\ttfamily Release:} Õâ¸ö·¢ÐÐÐòºÅ±ØÐëÓëÄú×¼±¸Ê¹ÓÃµÄ rpm µµÃûÒ»ÖÂ¡£
( Ò²¾ÍÊÇËµ£¬ Èç¹ûÎÒÃÇÍê³ÉÒ»¸ö³ÌÊ½Ì×¼þ£¬ µ«ÊÂáá·¢ÏÖËüÓÐÐ©Ð¡Ð¡µÄÎÊÌâ£¬
±ØÐëÖØÐÂ build Ò»´Î£¬ ´ËÊ±ÐÂµÄ³ÌÊ½Ì×¼þ£¬ Æä·¢ÐÐÐòºÅ±ãÊÇ 2 ºÅ )¡£
\item {\ttfamily Icon:} Èç¹ûÄúÊ¹ÓÃÁËÆäËû¸ß½×µÄ°²×°¹¤¾ß³ÌÊ½
( ÏñÊÇ Red Hat µÄ ``glint'' ³ÌÊ½ )£¬ ÄÇ÷áÕâÀï¿ÉÒÔÖ¸¶¨ÆäÏà¶ÔÓ¦µÄÍ¼Ê¾µµ£¬
Ëü±ØÐëÊÇÒ»¸ö gif µµ°¸£¬ ¶øÇÒ±ØÐëÎ»ì¶ SOURCES Ä¿Â¼¡£
\item {\ttfamily Source:} ÕâÀïÖ¸¶¨ÁËÄÇÐ©¡¸Î´¾­´¦Àí¹ýµÄ source µµ°¸¡¹µÄ
HOME Ä¿Â¼£¬ µ±ÄúÏëÒªÖØÐÂÈ¡µÃ source µµ°¸£¬ »òÊÇ¼ì²ìÊÇ·ñÓÐÐÂ°æ±¾Ê±£¬
¾ÍÐèÒªÓÃµ½Õâ¸öÉè¶¨¡£ ×¢ÒâÊÂÏî£º ÕâÀïµÄµµÃû£¬ ¡¸Îñ±Ø¡¹ÓëÄúÏµÍ³ÉÏµÄµµ°¸Ãû³ÆÒ»ÖÂ
( Ò²¾ÍÊÇËµ£¬ ÏÂÔØ source µµ°¸áá£¬ ²»ÒªÈ¥±ä¸üÆäµµ°¸Ãû³Æ )¡£
Í¬Ê±£¬ Äú¿ÉÒÔÖ¸¶¨Ò»¸öÒÔÉÏµÄ source µµ°¸£¬ ·½Ê½ÈçÏÂ£º
\begin{tscreen}
\begin{verbatim}
Source0: blah-0.tar.gz
Source1: blah-1.tar.gz
Source2: fooblah.tar.gz
\end{verbatim}
\end{tscreen}

ÕâÐ©µµ°¸¶¼»áµ½ {\ttfamily SOURCES} Ä¿Â¼µ×ÏÂ ( Ïà¹ØµÄÄ¿Â¼½á¹¹ËµÃ÷£¬
»áÔÚááÃæµÄ "The Source Directory Tree" ÕÂ½ÚÀï¼ÓÒÔÌÖÂÛ )¡£
\item {\ttfamily Patch:} Èç¹ûÄúÐèÒªÖØÐÂÏÂÔØ patch µµ°¸£¬
ÄÇ÷áÆäÄ¿Â¼Î»ÖÃÉè¶¨ì¶´Ë¡£
×¢ÒâÊÂÏî£º ÕâÀïµÄµµÃû£¬ ±ØÐëÓëÄúÏµÍ³ÉÏÊ¹ÓÃµÄ patch µµ°¸Ãû³ÆÏà·û£¬
ÁíÒ»·½Ãæ£¬ ºÍÇ°Êö¶à¸ö source µµ°¸µÄÉè¶¨Ò»Ñù£¬ ÄúÒ²¿ÉÒÔÖ¸¶¨¶à¸ö
patch µµ°¸Ãû³Æ¡£ Æä¸ñÊ½¡õÀýÈçÏÂ£º
\begin{tscreen}
\begin{verbatim}
Patch0: blah-0.patch
Patch1: blah-1.patch
Patch2: fooblah.patch
\end{verbatim}
\end{tscreen}

ÕâÐ©µµ°¸¶¼»áµ½ {\ttfamily SOURCES} Ä¿Â¼µ×ÏÂ¡£
\item {\ttfamily Copyright:} ÕâÀïµÄÉè¶¨£¬ ÓÃÒÔËµÃ÷³ÌÊ½Ì×¼þ²ÉÓÃºÎÖÖ°æÈ¨ÉùÃ÷¡£
Ïñ GPL¡¢ BSD¡¢ MIT¡¢ public domain¡¢ distributable¡¢ commercial µÈ£¬
¶¼ÊÇÄú¿ÉÒÔÖ¸¶¨µÄ¡£
\item {\ttfamily BuildRoot:} Äú¿ÉÒÔÖ¸¶¨Ò»¸öÄ¿Â¼£¬
Ëü»á±»µ±×÷ÊÇ build Óë install ÐÂ³ÌÊ½Ì×¼þµÄ ``root'' Ä¿Â¼£¬
Èç¹ûÄúÏëÔÚÊµ¼Ê°²×°Ö®Ç°£¬ ÏÈÐÐ²âÊÔ³ÌÊ½ÄÚÈÝ£¬ ¿ÉÒÔÉÆÓÃ´ËÏîÉè¶¨¡£
\item {\ttfamily Group:} ÕâÀïµÄÉè¶¨£¬ ÓÃì¶¸ß½×µÄ°²×°¹¤¾ß³ÌÊ½ ( ÀýÈç
Red Hat µÄ ``glint'' ³ÌÊ½ ) µ±ÖÐ£¬ ÓÃÒÔËµÃ÷³ÌÊ½ËùÊôµÄÈº×éÎ»ÖÃ¡£
Ä¿Ç°µÄÈº×é¼Ü¹¹£¬ ´óÖÂÈçÏÂËùÊö£º
\begin{tscreen}
\begin{verbatim}
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
\end{verbatim}
\end{tscreen}

\item {\ttfamily \%description}  Õâ¸ö²¢·ÇÕæµÄÊÇ header ÏîÄ¿£¬
µ«ÄúÓ¦¸ÃÁ¬Í¬ÉÏÊöµÄÏîÄ¿Ò»Í¬ÌîÐ´£¬ Ã¿¸ö¡¸³ÌÊ½Ì×¼þ¡¹»ò¡¸×Ó³ÌÊ½Ì×¼þ¡¹£¬
¶¼Ó¦¸ÃÓÐÒ»¸ö description tag¡£ ÕâÀïÔÊÐíÄúÊäÈë¶àÐÐÄÚÈÝ£¬
Ê¹µÃ³ÌÊ½Ì×¼þÄÜ¹»¾ßÓÐÒ»·ÝÍêÕûÏê¾¡µÄËµÃ÷¡£
\end{itemize}





\subsection{Prep}

ÕâÀïÊÇ spec µµ°¸µÄÁíÒ»¸ö¶ÎÂäÕÂ½Ú£¬ ÓÃÒÔÉè¶¨ÈÃ source µµ°¸¾ÍÐ÷£¬
ÒÔ¹©ÏÂÒ»²½µÄ build ¶¯×÷¡£ Æ½³£ÎÒÃÇ±ØÐë¾­¹ý setup£¬ ²ÅÄÜÊµ¼Ê½øÐÐ {\ttfamily make}
¶¯×÷£¬ Òò´ËÔÚ±¾¶ÎÂäÕÂ½ÚÖÐ£¬ ÎÒÃÇ½«ÊÓÐèÒª½øÐÐ source µµ°¸µÄ patch Óë setup¡£

ÓÐ¼þÊÂÖµµÃ×¢ÒâµÄ£º ½ÓÏÂÀ´µÄ¶ÎÂäÉè¶¨£¬ Êµ¼ÊÉÏÖ»ÊÇÖ¸Ã÷Ä³¶Î shell scripts
µÄÎ»ÖÃ£¬ Äú¿ÉÒÔ½« shell scripts µÄÄÚÈÝ£¬ ÁíÍâÒÔ {\ttfamily sh} script
µÄ·½Ê½¼ÓÒÔ´æµµ£¬ ²¢½« script ³ÌÊ½Ãû³ÆÖÃì¶ {\ttfamily \%prep} tag Ö®áá£¬
ÓÃÒÔÖ´ÐÐ source µµ°¸µÄ unpack Óë patch ¶¯×÷¡£ µ±È»£¬ ÒÔÔ­ÓÐÖ® macro
ÐÍÊ½À´×ö£¬ Ó¦¸ÃÊÇ·½±ãÐí¶àµÄ¡£

µÚÒ»¸öÒªËµÃ÷µÄ macro ÊÇ {\ttfamily \%setup}¡£
Èç¹ûÎÒÃÇ²ÉÓÃÆä×î¼òµ¥µÄ¸ñÊ½ ( ¼´²»¼ÓÈÎºÎÃüÁîÁÐ²ÎÊýµÄÇé¿ö )£¬
Ëü»áµ¥´¿µØ½« source µµ°¸¼ÓÒÔ unpack£¬ ²¢ {\ttfamily cd} ½øÈë source µµ°¸µÄÄ¿Â¼¡£
³ý´ËÖ®Íâ£¬ Äú»¹¿ÉÒÔÊ¹ÓÃÏÂÁÐµÄÑ¡Ïî£º

\begin{itemize}
\item {\ttfamily -n name} Õâ¸öÑ¡ÏîÉè¶¨»á°Ñ build µÄÄ¿Â¼ÉèÎª {\ttfamily name}£¬
Ô­Ô¤ÉèÖµÎª {\ttfamily \$NAME-\$VERSION}£¬ ÆäËû¿ÉÄÜÄ¿Â¼Ãû³Æ°üÀ¨
{\ttfamily \$NAME}£¬ {\ttfamily \$$\{$NAME$\}$\$$\{$VERSION$\}$}£¬ »òÊÇ tar
µµ°¸±¾ÉíËùÓÃµÄÄ¿Â¼¡£ ( Çë×¢Òâµ½£¬ ÉÏÊöµÄ ``\$'' ±äÊý£¬
²¢{\itshape ²»ÊÇ\/} spec µµ°¸ÀïµÄ±äÊý£¬ ËüÃÇÔÚÕâÀïÖ»ÊÇÓÃÀ´´ú±íÒ»¸ö¡õÀýÃû³Æ£¬
Äú±ØÐëÔÚ³ÌÊ½Ì×¼þÀï£¬ Ê¹ÓÃÊµ¼ÊµÄµµ°¸Ãû³ÆÓë°æ±¾Ãû³Æ )¡£
\item {\ttfamily -c} ÔÚ½øÐÐ untar ¶¯×÷{\itshape Ö®Ç°\/}£¬
»áÏÈ½¨Á¢Ò»¸öÄ¿Â¼£¬ ²¢ cd ½øÈë¸ÃÄ¿Â¼¡£
\item {\ttfamily -b \#} ÔÚ cd ½øÈë¸ÃÄ¿Â¼{\itshape Ö®Ç°\/}£¬
»áÏÈ½« Source\# ½øÐÐ untar ¶¯×÷ ( Õâ¸öÑ¡ÏîÓë {\ttfamily -c} Ñ¡Ïî²¢´æÊ±£¬
ÊÇÃ»ÓÐÒâÒåµÄ£¬ ËùÒÔÓ¦±ÜÃâÍ¬Ê±Ê¹ÓÃ )£¬ ¶øÇÒÕâ¸öÑ¡Ïî£¬
½öÊÊÓÃì¶¶à¸ö source µµ°¸µÄ³¡ºÏ¡£
\item {\ttfamily -a \#} ÔÚ cd ½øÈë¸ÃÄ¿Â¼{\itshape Ö®áá\/}£¬
ÔÙ½« Source\# ½øÐÐ untar ¶¯×÷¡£
\item {\ttfamily -T} Õâ¸öÑ¡Ïî»á¸Ç¹ýÔ­±¾Ô¤ÉèµÄ untar ¶¯×÷£¬
Í¬Ê±ÐèÒªÒ»¸ö {\ttfamily -b 0} »òÊÇ {\ttfamily -a 0} µÄÑ¡ÏîÀ´ÅäºÏ£¬
µ±ÄúÊ¹ÓÃµ½Á½¸öÒÔÉÏµÄ source µµ°¸Ê±£¬ ±ãÐèÒª´ËÏî¹¦ÄÜ¡£
\item {\ttfamily -D} ÔÚ½â¿ª³ÌÊ½Ì×¼þÖ®Ç°£¬ {\itshape ²»Òª\/}É¾³ý¸ÃÄ¿Â¼¡£
Õâ¸öÑ¡Ïî½öÊÊÓÃì¶Ê¹ÓÃÁ½¸öÒÔÉÏ setup macro Ö®³¡ºÏ£¬
¶øÇÒ{\itshape Ö»ÄÜ\/}ÓÃì¶µÚÒ»¸ö setup macro {\itshape Ö®áá\/} ( Ç§Íò±ðÓÃì¶µÚÒ»¸öÖ®ÄÚ )¡£
\end{itemize}


½ÓÏÂÀ´ÒªËµÃ÷µÄ macro ÊÇ {\ttfamily \%patch}¡£
ËüÊÇÓÃÀ´Ð­Öú×Ô¶¯´¦Àí source µµ°¸¸üÐÂµÄ¶¯×÷£¬ ÆäÏà¹ØµÄÑ¡ÏîºÜ¶à£¬ ÁÐ±íËµÃ÷ÈçÏÂ£º
\begin{itemize}
\item {\ttfamily \#} »áÒýÓÃ Patch\# µ±×÷ÆäËùÐèÖ®¸üÐÂµµ¡£
\item {\ttfamily -p \#} ÓÐÊ± patch(1) Ö¸ÁîÐèÅäºÏÖ¸¶¨ strip µÄÄ¿Â¼ÊýÄ¿£¬
Äã¿ÉÒÔÔÚ´ËÑ¡ÏîÖÐ¼ÓÒÔÉè¶¨¡£
\item {\ttfamily -P} ÆäÔ¤ÉèÖ®¶¯×÷ÊÇÒýÓÃ {\ttfamily Patch} ( »ò {\ttfamily Patch0} )£¬
µ±ÄúÊ¹ÓÃÁ½¸öÒÔÉÏµÄ {\ttfamily \%patch} macro£¬ ²¢ÇÒÐèÒªÓëµÚÒ»¸ö
macro ²»Í¬Ö® patch number Ê±£¬ Õâ¸öÑ¡ÏîÏÔµÃÏàµ±ÓÐÓÃ¡£
Ëü»á¸Ç¹ýÔ­±¾µÄÔ¤Éè¶¯×÷£¬ ²¢ÇÒÐèÒªÅäºÏÒ»¸ö {\ttfamily 0}£¬
ÒÔÊ¹µÃÖ÷ÒªµÄ source µµ°¸µÃÒÔ½øÐÐ untar ¶¯×÷¡£
\item  ÄúÒ²¿ÉÒÔÊ¹ÓÃ {\ttfamily \%patch\#}£¬
¶ø²»±ØÊ¹ÓÃÕâÑùµÄÖ¸Áî£º {\ttfamily \%patch \# -P}
\end{itemize}


ÕâÐ©Ó¦¸Ã¾ÍÊÇÈ«²¿ËùÐèÒªÖªµÀÖ® macro ËµÃ÷£¬ ÁË½âËüÃÇÖ®áá£¬
ÄúÒ²¿ÉÒÔÍ¸¹ý {\ttfamily sh} Ö® script ¸ñÊ½£¬ Éè¶¨²»Í¬µÄ setup ·½·¨£¬
ÔÚ {\ttfamily \%build} macro ( ÔÚÏÂÒ»ÕÂ½ÚÖÐ»áÌá¼° ) Ö®Ç°£¬
ÄúËùÉè¶¨Ö®ËùÓÐÑ¡Ïî£¬ ¶¼ÊÇ¾­ÓÉ {\ttfamily sh} À´Ö´ÐÐ£¬
Äú¿ÉÒÔÔÙ²Î¿¼Ò»ÏÂÇ°ÊöµÄ¡õÀý£¬ »òÐí¿ÉÒÔÊÊÓÃì¶ÄúµÄÐèÒª¡£




\subsection{Build}

Õâ¸öÕÂ½ÚÀï£¬ ËùÊö¼°µÄ²¢·ÇÕæÕýµÄ macro¡£ µ±Äú°Ñ source µµ°¸ untar£¬
²¢ÇÒ patch Íê³É£¬ cd ½øÈëÄ¿Â¼Ö®áá£¬ ¿ªÊ¼×¼±¸ build ¶¯×÷Ê±£¬
±ãÊÇÔÚÕâÀïÉè¶¨ÄÇÐ©¿ØÖÆ build ¶¯×÷µÄÖ¸Áî¡£ ¶øÕâÐ©Ö¸Áî¶¼»¹ÊÇ´«¸ø {\ttfamily sh}£¬
ËùÒÔÈÎºÎ {\ttfamily sh} Ö®Ö¸Áî£¬ ¶¼¿ÉÒÔÔÚ´ËÖ¸¶¨ ( °üÀ¨ comments ÔÚÄÚ )¡£
{\bfseries ÔÚ spec µµ°¸ÀïµÄÃ¿Ò»¶ÎÂäÕÂ½ÚÉè¶¨ÖÐ£¬ ÄúµÄÄ¿Ç°ËùÔÚÄ¿Â¼Î»ÖÃ£¬
¶¼»á±»ÖØÐÂÉè¶¨Îª source directory µÄ×îÉÏ²ã}£¬ ËùÒÔÇëÀÎ¼ÇÔÚÐÄ£¬
±ØÒªÊ±£¬ Äú¿ÉÒÔ {\ttfamily cd} ½øÈëÏà¹ØµÄ×ÓÄ¿Â¼¡£




\subsection{Install}

ÕâÀïËùÉè¶¨µÄ£¬ Í¬ÑùÒ²²»ÊÇ macro£¬ »ù±¾ÉÏ£¬ ÄúÖ»ÐëÒªÔÚ´ËÉè¶¨Ò»Ð©
install ËùÐèÖ®Ö¸Áî¡£ Èç¹ûÄú´òËãÔÚ³ÌÊ½Ì×¼þÀï£¬ Ìá¹©ÍêÕûµÄ {\ttfamily make
install} Ö¸ÁîÉè¶¨£¬ ÄÇ÷áÇëÔÚ±¾¶ÎÂäÉè¶¨ÖÐÍê³É£¬ ²»È»£¬
ÄúÒ²¿ÉÒÔ¸ü¸Ä makefile µµ°¸Àï£¬ ÓÐ¹Ø {\ttfamily make install} µÄ²¿·Ý£¬
È»áá½öÔÚ±¾¶ÎÂäÉè¶¨ÖÐÖ¸¶¨ {\ttfamily make install}¡£ »òÊÇ£¬ Ò²¿ÉÒÔ°ÑÕû¸ö
install µÄÖ¸Áî½»¸ø {\ttfamily sh} À´×ö¡£ ¼Ç×¡£¬ ÄúµÄÄ¿Ç°ËùÔÚÄ¿Â¼Î»ÖÃ£¬
Ó¦¸ÃÒÑ±»ÖØÐÂÉè¶¨Îª source directory µÄ×îÉÏ²ã¡£




\subsection{Optional pre and post Install/Uninstall Scripts}

³ÌÊ½Ì×¼þÔÚ°²×°Óë½â³ý°²×°Ö®Ç°áá£¬Äú¿ÉÒÔÖ¸¶¨ script£¬ 
Ê¹ÆäÊÓÇé¿ö¼ÓÒÔÖ´ÐÐ¡£ ½øÐÐ´ËÏî¶¯×÷µÄÖ÷ÒªÔ­ÒòÖ®Ò»£¬
±ãÊÇÓöµ½ÈçÏÂµÄ³¡ºÏ£¬ Æ©ÈçËµ£¬ ÎÒÃÇÔÚ°²×°»ò½â³ý°²×°Ò»Ð©º¬ÓÐ
shared library µÄ³ÌÊ½Ì×¼þÊ±£¬ ÐèÒªÖ´ÐÐ {\ttfamily ldconfig}¡£
¸÷Ê½ script ËùÐèÖ® macro Ãû³ÆÈçÏÂ£º
\begin{itemize}
\item {\ttfamily \%pre} Ö´ÐÐ pre-install scripts µÄ macro¡£
\item {\ttfamily \%post} Ö´ÐÐ post-install scripts µÄ macro¡£
\item {\ttfamily \%preun} Ö´ÐÐ pre-uninstall scripts µÄ macro¡£
\item {\ttfamily \%postun} Ö´ÐÐ post-uninstall scripts µÄ macro¡£
\end{itemize}


ÕâÐ©¶ÎÂäÉè¶¨µÄÄÚÈÝ£¬ ¿ÉÒÔÊÇÈÎºÎ {\ttfamily sh} ÐÍÊ½Ö® script£¬
²»¹ý£¬ Äú{\itshape ÎÞÐë\/}Ö¸¶¨¹Ø¼üÐðÊö {\ttfamily \#!/bin/sh}¡£




\subsection{Files}

±¾¶ÎÂäÉè¶¨µ±ÖÐ£¬ Äú{\itshape ±ØÐë\/}ÁÐ³ö³ÌÊ½Ì×¼þÄÚÖ®ËùÊôµµ°¸Ãû³Æ¡£
RPM ±¾Éí²¢ÎÞ´ÓµÃÖª£¬ Ö´ÐÐ {\ttfamily make install} Ö®áá£¬ µ½µ×ÓÐÄÄÐ©
binary µµ°¸±»°²×°½øÈ¥£¬ Ä¿Ç°{\itshape ²¢ÎÞ\/}Ëû·¨¿ÉÒÔÖ±½Ó½â¾ö´ËÎÊÌâ¡£
ÓÐÐ©ÈË½¨ÒéÔÚ install ³ÌÊ½Ì×¼þµÄÇ°áá£¬ Ê¹ÓÃ {\ttfamily find} Ö¸ÁîÀ´´¦Àí£¬
²»¹ýÔÚÒ»¸ö¶àÊ¹ÓÃÕßµÄÏµÍ³ÏÂ£¬ ÕâÓ¦¸ÃÊÇ²»¿ÉÐÐµÄ£¬ ÒòÎªÔÚ³ÌÊ½Ì×¼þ
build µÄ¹ý³ÌÖÐ£¬ ¿ÉÄÜÓÐÆäËûÓë³ÌÊ½Ì×¼þ±¾ÉíÎÞ¹ØµÄµµ°¸±»²úÉú¡£

ÁíÍâ»¹ÓÐÒ»Ð© macro£¬ ËüÃÇ¿ÉÓÃÀ´×öÒ»Ð©ÌØÊâµÄ¹¤×÷£¬
×È½«ÆäÁÐÊöì¶ÏÂ£º
\begin{itemize}
\item {\ttfamily \%doc} ÓÃÒÔ±êÊ¾ÔÚ install ³ÌÊ½Ì×¼þÊ±£¬
ÄúËùÏëÒª°²×°Ö® source µµ°¸ÀïµÄËµÃ÷ÎÄ¼þÊÇÄÄÐ©£¬
¶øÕâÐ©ËµÃ÷ÎÄ¼þ»á±»°²×°ÔÚ
{\ttfamily /usr/doc/\$NAME-\$VERSION-\$RELEASE}¡£
Äú¿ÉÒÔÔÚÃüÁîÁÐÉÏ£¬ ÒÔ´Ë macro Í¬Ê±Ö¸¶¨ºÃ¼¸¸öËµÃ÷ÎÄ¼þÃû³Æ£¬
»òÊÇÒÔ´Ë macro£¬ ¸÷±ðÎªËüÃÇÒ»Ò»Íê³ÉÖ¸¶¨¡£
\item {\ttfamily \%config} ÓÃÒÔ±êÊ¾³ÌÊ½Ì×¼þÀïµÄÉè¶¨µµ°¸ÊÇÄÄÐ©£¬
Õâ°üÀ¨Ïñ sendmail.cf¡¢ passwd Ö®ÀàµÄµµ°¸¡£
Èç¹ûÄúÊÂáá uninstall ÁËÄ³¸ö³ÌÊ½Ì×¼þ£¬ ¶øÇÒËüº¬ÓÐÉè¶¨µµ°¸£¬
ÄÇ÷áËùÓÐÃ»ÓÐ¸Ä±äµÄµµ°¸»á±»ÒÆ³ý£¬ ¶øËùÓÐÒÑ¾­¸Ä±äµÄµµ°¸£¬
»áÔÚÔ­µµ°¸Ãû³ÆÖ®áá£¬ ¼ÓÉÏ {\ttfamily .rpmsave} µÄÑÓÉìÃû³Æ¡£
Í¬ÑùµÄ£¬ Äú¿ÉÒÔÔÚ´ËÍ¬Ê±ÁÐ³ö¶à¸öµµ°¸Ãû³Æ¡£
\item {\ttfamily \%dir} ÔÚµµ°¸ÁÐ±íÖÐ£¬ ±êÃ÷Ä³Ò»¸öÌØ¶¨µÄÄ¿Â¼£¬
ÓÃÒÔËµÃ÷¸ÃÄ¿Â¼ÎªÄ³³ÌÊ½Ì×¼þËùÓµÓÐ¡£ Èç¹ûÄúÔÚµµ°¸ÁÐ±íÖÐÖ¸¶¨Ò»¸öÄ¿Â¼Ãû³Æ£¬
µ«È´{\itshape Ã»ÓÐ\/}ÔÚÇ°Ãæ¼ÓÉÏ{\ttfamily \%dir} macro£¬ ÄÇ÷á¸ÃÄ¿Â¼ÄÚ£¬
{\itshape ËùÓÐµµ°¸Ä¿Â¼\/}¶¼»á±»°üº¬ÔÚµµ°¸ÁÐ±íµ±ÖÐ£¬ ²¢ÔÚÉÔáá£¬
±»µ±×÷ÊÇ³ÌÊ½Ì×¼þµÄÒ»²¿·Ý¶øÈ«±»°²×°½øÈ¥¡£
\item {\ttfamily \%files -f $<$filename$>$} ÔÊÐíÄúÒýÓÃ source
Ö® build Ä¿Â¼Àï£¬ Ä³·Ýµµ°¸Çåµ¥µÄÄÚÈÝ¡£ µ±ÄúÓöµ½Ä³Ò»¸ö³ÌÊ½Ì×¼þ£¬
Ëü¿ÉÒÔ½¨Á¢×Ô¼ºµÄµµ°¸Çåµ¥Ê±£¬ Õâ¸öÑ¡Ïî±ãÏÔµÃÏàµ±²»´í£¬
ÄúÖ»ÐëÒªÒýÓÃ¸Ã·Ýµµ°¸Çåµ¥£¬ ²»±ØÔÙ×ÔÐÐÐÁ¿àµØÁÐ³ö¡£
\end{itemize}


ÔÚµµ°¸ÁÐ±íÀï£¬ ÓÐ¸ö×î´óµÄ×¢ÒâÊÂÏî£¬ ±ãÊÇÄ¿Â¼µÄÉè¶¨¡£
Èç¹ûÄú²»Ð¡ÐÄ½« {\ttfamily /usr/bin} ÁÐÈë£¬ ÄÇ÷áÄúµÄ³ÌÊ½Ì×¼þ£¬
½«»á°üÀ¨ÏµÍ³Àï {\ttfamily /usr/bin} µ×ÏÂµÄ{\itshape ËùÓÐ\/}µµ°¸¡£




\subsection{Building It}




\subsubsection{The Source Directory Tree}

µÚÒ»¼þÊÂ£¬ Äú±ØÐëÑ¡¶¨Ò»¸öÊÊµ±µÄ build tree£¬
´ËÏîÉè¶¨¿ÉÔÚ {\ttfamily /etc/rpmrc} µµ°¸ÀïÍê³É£¬
¶ø´ó¶àÊýÈË»áÖ±½ÓÊ¹ÓÃ {\ttfamily /usr/src}¡£

Äú¿ÉÄÜ»¹ÐèÒª½¨Á¢ÏÂÁÐµÄÄ¿Â¼£¬ Ê¹µÃ build tree µÄÉè¶¨ÄÜ¹»Íê³É£º
\begin{itemize}
\item {\ttfamily BUILD} ´ËÄ¿Â¼±ãÊÇ RPM ½øÐÐËùÓÐ build ¶¯×÷µÄ¹¤×÷Ä¿Â¼¡£
Äú²»±ØÌØ±ðµØÔÚÄÄ¸öÄ¿Â¼½øÐÐ²âÊÔÐÔµÄ build ¶¯×÷¡£
\item {\ttfamily SOURCES} ´ËÄ¿Â¼´æ·ÅÖøÄúµÄ¡¸ÆðÊ¼¡¹ (original)
Ô­Ê¼ tar µµ°¸¡¢ ÓëÏà¹ØµÄ patch µµ°¸£¬ RPM Ô¤Éè»áÑ°ÕÒ±¾Ä¿Â¼¡£
\item {\ttfamily SPECS} ´ËÄ¿Â¼´æ·ÅËùÓÐÖ® spec µµ°¸¡£
\item {\ttfamily RPMS} ´ËÄ¿Â¼´æ·ÅËùÓÐ build ²úÉúÖ® binary ¸ñÊ½ RPM µµ°¸¡£
\item {\ttfamily SRPMS} ´ËÄ¿Â¼´æ·ÅËùÓÐ source ¸ñÊ½ RPM µµ°¸¡£
\end{itemize}





\subsubsection{Test Building}

Ê×ÏÈ£¬ Äú´ó¸Å»áÏëÒªÈ¡»Ø source µµ°¸£¬ ÔÚÃ»ÓÐÊ¹ÓÃ RPM µÄÇé¿öÏÂ£¬
½øÐÐÒ»´Î¡¸´¿¾»µÄ¡¹ build ¶¯×÷¡£ Æä²½Öè±ãÊÇ£¬ ½â¿ª source µµ°¸£¬
½«¸ÃÄ¿Â¼Ãû³Æ¸ÄÎª \$NAME.org£¬ È»ááÔÙ´Î½â¿ª source µµ°¸£¬
ÎÒÃÇÐèÒªÊ¹ÓÃ´ËÒ» source À´½øÐÐ build ¶¯×÷¡£
½øÈë´ËÒ» source Ä¿Â¼£¬ °´ÕÕÖ¸Ê¾À´½øÐÐ build£¬
Èç¹ûÄú±ØÐë±à¼­ÈÎºÎ¶«Î÷£¬ Äú»áÐèÒªÒ»·Ý patch£¬
Ò»µ©ÄúÍê³É build ¹¤×÷£¬ ±ã¿ÉÇå³ý source Ä¿Â¼ÀïµÄÄÚÈÝ¡£
ÇëÈ·¶¨½« {\ttfamily configure} script Àï£¬ ËùÓÐ²úÉúÖ®µµ°¸¼ÓÒÔÇå³ý£¬
È»ááÔÙ {\ttfamily cd} »Øµ½ source Ä¿Â¼Ö®ÉÏ²ã£¬ ½ÓÖø±ã¿ÉÖ´ÐÐÕâÑùµÄ¶¯×÷£º
\begin{tscreen}
\begin{verbatim}
diff -uNr dirname.orig dirname > ../SOURCES/dirname-linux.patch
\end{verbatim}
\end{tscreen}

ÉÏÊöÖ¸Áî»á²úÉúÒ»·Ý patch£¬ ÄúÔÚ spec µµ°¸¿ÉÒÔÊ¹ÓÃµ½Ëü¡£
×¢Òâµ½ÉÏÃæµÄ ''linux'' Ãû³Æ£¬ ËüÖ»ÊÇÒ»¸öÌáÊ¾×÷ÓÃ£¬
»òÐíÄú¿ÉÒÔÊ¹ÓÃÆäËûÃû³Æ£¬ ÖîÈç ''config'' »ò ''bugs'' Ö®ÀàµÄÌáÊ¾Ãû³Æ£¬
ÓÃÒÔËµÃ÷Äú{\itshape ºÎÒÔ\/}ÖÆ×÷´ËÒ» patch µµ°¸¡£
Í¬Ê±£¬ Äú×îºÃÒ²ÔÚÊ¹ÓÃ patch µµ°¸Ö®Ç°£¬ ÏÈ¹Û²ìÀïÍ·µÄÄÚÈÝ£¬
È·¶¨ÊÇ·ñÎÞÒâ¼ä°üº¬ÁËÆäËûµÄ binary µµ°¸¡£




\subsubsection{Generating the File List}

ÏÖÔÚ£¬ ÄúÒÑ¾­ÓÐÁËÒ»·Ý¿ÉÒÔÄÃÀ´ build µÄ source µµ°¸£¬
¶øÇÒÄúÒ²ÖªµÀÈçºÎÍê³ÉÆäÏà¹ØµÄ¶¯×÷£¬ Èç build Óë install µÈ¡£
¹Û²ì install Ê±£¬ ÒÀÐò²úÉúµÄ½á¹û£¬ ÎÒÃÇ½«ÓÉ´Ë½á¹û£¬
ÔÚ spec µµ°¸ÖÐ½¨Á¢Ò»·Ýµµ°¸ÁÐ±í¡£
Í¨³£ÎÒÃÇ»áÔÚ½øÐÐÉÏÊö²½ÖèµÄÍ¬Ê±£¬ Ò»Æð½¨Á¢ spec µµ°¸£¬
Äú¿ÉÒÔÏÈÍê³Éµµ°¸µÄÆðÊ¼²¿·Ö£¬ ºÍ¼¸¸ö¼òµ¥µÄ²¿·Ö£¬
È»ááÔÙ°ÑÆäËû²¿·ÖµÄ²½Öè¼ÓÒÔÍê³É¡£




\subsubsection{Building the Package with RPM}

Ò»µ©ÄúÓÐÁËÒ»·Ý spec µµ°¸£¬ Ò»ÇÐ±ãÒÑ¾ÍÐ÷£¬ Äú¿ÉÒÔ×¼±¸ build µÄ²âÊÔ¶¯×÷¡£
×îºÃµÄ·½Ê½£¬ ¾ÍÊÇÊ¹ÓÃÀàËÆÏÂÁÐµÄÖ¸Áî£º

\begin{tscreen}
\begin{verbatim}
rpm -ba foobar-1.0.spec
\end{verbatim}
\end{tscreen}


ÅäºÏ {\ttfamily -b} Ñ¡Ïî£¬ ÎÒÃÇ»¹¿ÉÒÔÊ¹ÓÃÆäËûÓÐÓÃµÄÑ¡Ïî£º
\begin{itemize}
\item {\ttfamily p} Ö¸µÄÊÇÖ»Ö´ÐÐ spec µµ°¸Ö® {\ttfamily prep} ²¿·Ý¡£
\item {\ttfamily l} Õë¶Ô {\ttfamily \%files} ½øÐÐµµ°¸ÁÐ±íµÄ±È¶Ô¼ì²é¶¯×÷¡£
\item {\ttfamily c} Ö´ÐÐ prep Óë compile µÄ¶¯×÷¡£ µ±Äú²»È·¶¨ source
µµ°¸ÊÇ·ñÄÜ¹» build Ê±£¬ ´ËÑ¡ÏîÏÔµÃÏàµ±ÓÐÓÃ¡£
»òÐíÄú»á¾õµÃËü²¢Ã»ÓÐ¶à´óÓÃ´¦£¬ ÒòÎªÄú¿ÉÄÜÏëÒª¼ÌÐøÐÞ¸Ä source
µµ°¸±¾Éí£¬ Ö±µ½ build ááÔÙ¿ªÊ¼Ê¹ÓÃ RPM£¬ µ«Ò»µ©ÄúÊìÏ¤ RPM µÄÓÃ·¨áá£¬
»á·¢ÏÖËüµÄ±ãÀûÖ®´¦¡£
\item {\ttfamily i} Ö´ÐÐ prep¡¢ compile¡¢ Óë install¡£
\item {\ttfamily b} Ö´ÐÐ prep¡¢ compile¡¢ install¡¢ ²¢Ö» build ³öÒ»·Ý
binary ³ÌÊ½Ì×¼þ¡£
\item {\ttfamily a} Ö´ÐÐËùÓÐµÄ build ¶¯×÷ ( °üÀ¨  source Óë binary µÄ³ÌÊ½Ì×¼þ )¡£
\end{itemize}

ÅäºÏ {\ttfamily -b} Ñ¡Ïî£¬ ÁíÍâ»¹ÓÐÒ»Ð©Ï¸ÏîÑ¡Ïî¿É¹©Ê¹ÓÃ£¬ ËüÃÇ·Ö±ðÊÇ£º
\begin{itemize}
\item {\ttfamily --short-circuit} »áÖ±½ÓÌøÖÁÄ³¸öÌØ¶¨µÄ½×¶Î ( ½ö¿ÉÅäºÏ
c Óë i Ñ¡ÏîÀ´Ê¹ÓÃ )¡£
\item {\ttfamily --clean} µ±Ö´ÐÐÍê±ÏÊ±£¬ ÒÆ³ýÏà¹ØµÄ build tree¡£
\item {\ttfamily --keep-temps} »á°ÑËùÓÐµÄ temp Óë scripts µµ°¸£¬
¶¼±£ÁôÔÚ /tmp Ä¿Â¼£¬ Äú¿ÉÒÔÊ¹ÓÃ {\ttfamily -v} Ñ¡Ïî£¬ Êµ¼Ê¹Û²ìÓÐÄÄÐ©µµ°¸±»²úÉú¡£
\item {\ttfamily --test} ²¢²»Êµ¼ÊÖ´ÐÐÈÎºÎ½×¶ÎµÄ¶¯×÷£¬ µ«ÓÐÖ´ÐÐ keep-temp µÄ²¿·Ý¡£
\end{itemize}





\subsection{Testing It}

Ò»µ©ÓÐÁË source Óë binary µÄ rpm µµ°¸£¬ Äú±ØÐë½øÐÐ²âÊÔ¹¤×÷¡£
×î¼òµ¥ÇÒ×îºÃµÄ·½Ê½£¬ ¾ÍÊÇÊ¹ÓÃÁíÒ»Ì¨»úÆ÷À´²âÊÔ£¬
Ò²¾ÍÊÇ½øÐÐ build ¶¯×÷Ö®ÍâµÄ»úÆ÷¡£ ±Ï¾¹£¬ Äú¸ÕÔÚÄúµÄ»úÆ÷ÉÏ£¬
Íê³ÉÒ»´ó¶ÑµÄ {\ttfamily make install} ¶¯×÷£¬ ÈôÔÚÔ­»úÆ÷ÉÏ×ö²âÊÔ£¬
µ±È»»áÏÔµÃÏàµ±Ë³ÀûÂÞ¡£

Äú¿ÉÒÔÖ´ÐÐ {\ttfamily rpm -u packagename} À´½øÐÐ²âÊÔ£¬
µ«ÕâÑù×ö»¹ÊÇÓÐÔì¼ÙµÄ¿ÉÄÜ£¬ ÒòÎªÔÚ build µÄ¹ý³ÌÖÐ£¬
Äú×öÁË {\ttfamily make install} µÄ¶¯×÷£¬ Èç¹ûÄúÔÚµµ°¸ÁÐ±íÖÐÒÅÂ©ÁËÄ³Ð©¶«Î÷£¬
ÄÇ÷áËü²»»á±»½â³ý°²×°£¬ È»ááÄúÔÙ reinstall Õâ·Ý binary ³ÌÊ½Ì×¼þ£¬
±ã»á·¢ÏÖÕû¸öÏµÍ³»¹ÊÇÍêÕû¶øÔË×÷Õý³£µÄ£¬ µ«Êµ¼ÊÉÏµÄ rpm µµ°¸»¹ÊÇÓÐÎÊÌâ¡£
Òò´ËÇëÌØ±ð¼Ç×¡£¬ ÓÉì¶ÄúÖ´ÐÐµÄÊÇ {\ttfamily rpm -ba package}£¬ ¶ø´ó¶àÊýµÄÈË£¬
»áÖ»ÒÔ {\ttfamily rpm -i package} ·½Ê½£¬ À´°²×°ÄúµÄ³ÌÊ½Ì×¼þ¡£
µ± binary µµ°¸¶À×Ô±»°²×°Ê±£¬ Äú±ØÐëÈ·¶¨ÔÚ {\ttfamily build} »ò {\ttfamily install}
µÄ¶ÎÂäÉè¶¨ÖÐ£¬ ²¢Ã»ÓÐÏà¹ØµÄ²¿·Ý¶ÔÆäÓÐÓ°Ïì¡£






\subsection{What to do with your new RPMs}

Ò»µ©Äú×÷³öÁËÒ»·Ý×Ô¼ºµÄ RPM µµ°¸ ( ¼Ù¶¨Õâ·Ýµµ°¸£¬ Ö®Ç°²¢Î´ÒÔ RPM
·½Ê½ÖÆ×÷¹ý )£¬ Äú¿ÉÒÔ½«ÄúµÄ×÷Æ·¹±Ï×¸ø±ðÈË ( ´ËÊ±¼Ù¶¨ÄúÖÆ×÷µÄ RPM
µµ°¸£¬ ÊÇ¿ÉÒÔ×ÔÓÉ´«²¼µÄ )¡£ Äú¿ÉÒÔ¿¼ÂÇ°ÑËüÉÏ´«ÖÁ
\nameurl{ftp://ftp.redhat.com}{ftp.redhat.com}¡£






\subsection{What Now?}

Çë»Ø¹ËÉÏÊöµÄÕÂ½Ú£¬ ÔÚ¡¸Testing¡¹ºÍ¡¸What to do with new RPMs¡¹Àï£¬
ÎÒÃÇÏ£ÍûËùÓÐµÄ RPM µµ°¸¶¼ÄÜ±»Ìá¹©³öÀ´£¬ ¶øÇÒÎÒÃÇÏ£ÍûËüÃÇ¶¼»áÊÇºÃµÄ RPM
µµ°¸¡£ Òò´Ë£¬ Çë¶à»¨Ò»µãÊ±¼äºÃºÃµØ²âÊÔËüÃÇ£¬ È»ááÔÙ»¨µãÊ±¼ä½«ËüÃÇÉÏ´«£¬
ÒÔÔì¸£ÆÕÂÞ´óÖÚ¡£ Í¬Ê±£¬ {\itshape Çë\/}È·¶¨ÄúÖ»ÉÏ´«{\itshape ¿É¹©×ÔÓÉ´«²¼µÄÈíÌå\/}¡£
ÉÌÒµÈíÌåÓë¹²ÏíÈíÌåÊÇ{\itshape ²»\/}Ó¦¸Ã±»ÉÏ´«µÄ£¬ ³ý·ÇËüÃÇÓÐ·ÝÐí¿ÉÉùÃ÷ÔÚÉÏÃæ¡£
ÕâÑùµÄÈíÌå£¬ °üÀ¨ÓÐ Netscape software¡¢ ssh¡¢ pgp µÈ¡£




\section{Multi-architectural RPM Building}

RPM Ä¿Ç°¿ÉÓÃì¶ build ¸÷Ê½×÷ÒµÆ½Ì¨Ö®³ÌÊ½Ì×¼þ£¬ Èç Intel i386¡¢
°²×° Linux Ö® Digital Alpha¡¢ Óë Sparc »úÆ÷£¬
¶øÇÒÓÐÈË²âÊÔ±¨¸æ£¬ ËµÃ÷ËüÒ²¿ÉÒÔÔÚ SGI Óë HP ¹¤×÷Õ¾ÉÏÊ¹ÓÃ¡£
RPM ÓÐÐí¶àÌØÉ«£¬ Ê¹µÃËüÄÜ¹»ÇáËÉµØÖ§Ô®ÔÚ¸÷Ê½×÷ÒµÆ½Ì¨ÉÏ build
³ÌÊ½Ì×¼þ£¬ µÚÒ»¸öÌØÉ«±ãÊÇÔÚ {\ttfamily /etc/rpmrc} µµ°¸ÀïµÄ
``optflags'' Éè¶¨ÏîÄ¿£¬ µ±ÎÒÃÇÔÚ build ÈíÌåÌ×¼þÊ±£¬
Ëü¿ÉÓÃì¶Ö¸¶¨Æ½Ì¨¼Ü¹¹µÄÏà¹ØÉè¶¨Öµ¡£ ÁíÒ»¸öÌØÉ«ÊÇ spec µµ°¸ÀïµÄ
``arch'' macro ÏîÄ¿£¬ ¸ù¾ÝËùÒª½øÐÐ build µÄÆ½Ì¨¼Ü¹¹£¬
Äú¿ÉÒÔÖ¸¶¨ËüÃÇÖ´ÐÐ²»Í¬µÄ¹¤×÷¡£
ÁíÒ»¸öÌØÉ«ÊÇÔÚµµ°¸ header ´¦µÄ ``Exclude'' Éè¶¨ÏîÄ¿¡£




\subsection{Sample spec File}

ÏÂÁÐÒÔ ``fileutils'' ³ÌÊ½Ì×¼þÎªÀý£¬ Æä spec µµ°¸µÄ²¿·ÝÄÚÈÝ£¬
¿ÉÓÃÀ´ÔÚ Alpha Óë Intel Æ½Ì¨¼Ü¹¹ÉÏ£¬ ½øÐÐ build µÄ¹¤×÷¡£
\begin{tscreen}
\begin{verbatim}
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*

.
.
.
\end{verbatim}
\end{tscreen}





\subsection{Optflags}

ÔÚ´ËÒ»¡õÀýÖÐ£¬ Äú¿ÉÒÔ·¢ÏÖ ``optflags'' Éè¶¨ÏîÄ¿£¬
ÊÇÈçºÎÓÉ {\ttfamily /etc/rpmrc} µµ°¸ÖÐ·¢»Ó×÷ÓÃ¡£
Ê×ÏÈ¾ö¶¨ÄúËù½øÐÐ build ¶¯×÷µÄ»úÆ÷£¬ ÊÇÄÄÒ»ÖÖÆ½Ì¨¼Ü¹¹£¬
Çë½«ÆäÕýÈ·Ö®Éè¶¨Öµ£¬ Ö¸¶¨µ½ {\ttfamily RPM\_OPT\_FLAGS}¡£
Äú±ØÐëÕë¶Ô³ÌÊ½Ì×¼þÖ® Makefile µµ°¸£¬ ½øÐÐ patch µÄ¶¯×÷£¬
½«Ò»Ð©Í¨ÓÃµÄ±äÊýÉè¶¨Öµ£¬ ¼ÓÒÔ¸Ä±äÒÔÊÊÓÃì¶ÄúµÄ»·¾³
( Èç {\ttfamily -m486} Óë {\ttfamily -O2} )¡£
Äú¿ÉÒÔ install Õâ·Ý source Ì×¼þ£¬ ½ÓÖø½â¿ª source ²¢¼ì²éÆä Makefile µµ°¸£¬
ÒÔ½øÒ»²½ÕÒ³ö¸üºÃµÄÉè¶¨·½Ê½£¬ È»áá¹Û²ì Makefile µÄ patch ÄÚÈÝ£¬
ÒÔÁË½âÎÒÃÇ±ØÐë×öÄÄÐ©¸Ä±ä¡£




\subsection{Macros}

{\ttfamily \%ifarch} ´ËÒ» macro Éè¶¨ÏîÄ¿ÊÇ·Ç³£ÖØÒªµÄ£¬ ÔÚÐí¶à³¡ºÏ£¬
ÄúÐëÒªÖ»Õë¶ÔÄ³Ò»ÌØ¶¨Æ½Ì¨¼Ü¹¹£¬ ½øÐÐÒ»Á½¸ö patch ¹¤×÷£¬
ÕâÖÖÇé¿öÏÂ£¬ RPM ÄÜ¹»ÈÃÄú½öÕë¶ÔÄ³Ò»Æ½Ì¨¼Ü¹¹£¬ ²ÉÓÃ±ØÒªµÄ patch¡£

ÔÚÉÏÊö¡õÀýÖÐ£¬ fileutils ÓÐ¸öÌá¹©¸ø 64 bit »úÆ÷Ê¹ÓÃµÄ patch£¬
ºÜÃ÷ÏÔµØ£¬ ÕâÏî patch ½öÐèÒªÓÉ Alpha »úÆ÷Ëù²ÉÓÃ£¬ Òò´Ë£¬
ÎÒÃÇÕë¶Ô 64 bit µÄ patch ²¿·Ý£¬ Ôö¼ÓÒ»¸ö {\ttfamily \%ifarch} µÄ macro
Éè¶¨ÏîÄ¿£¬ Æä¡õÀýÈçÏÂ£º

\begin{tscreen}
\begin{verbatim}
%ifarch axp
%patch1 -p1
%endif
\end{verbatim}
\end{tscreen}

ÕâÑùÄÜ±£Ö¤£¬ ³ýÁË Alpha »úÆ÷Ö®Íâ£¬ ÆäËûÆ½Ì¨¼Ü¹¹µÄ»úÆ÷²¢²»»á²ÉÓÃ´Ë patch¡£




\subsection{Excluding Architectures from Packages}

Äú¿ÉÒÔÔÚÒ»¸öÄ¿Â¼ÄÚ£¬ Í¬Ê±¹ÜÀí¸÷Ê½×÷ÒµÆ½Ì¨µÄ RPM Ô­Ê¼µµ°¸£¬
ÕâÏî¹¦ÄÜÊ¹µÃÎÒÃÇÔÚÖÆ×÷³ÌÊ½Ì×¼þµÄÊ±ºò£¬ ²»±ØÏÞ¶¨ì¶Ä³Ð©×÷ÒµÆ½Ì¨ÉÏ¡£
Òò´ËÄú¿ÉÒÔÕâÑùÏÂÖ¸Áî£º
\begin{tscreen}
\begin{verbatim}
rpm --rebuild /usr/src/SRPMS/*.rpm
\end{verbatim}
\end{tscreen}

Ê¹µÃÕýÈ·µÄ³ÌÊ½Ì×¼þÄÜ¹»±» build¡£
Èç¹ûÄúÉÐÎ´ÒÆÖ²Ä³¸öÓ¦ÓÃ³ÌÊ½ÖÁÄ³Ò»ÌØ¶¨µÄ×÷ÒµÆ½Ì¨£¬
¿ÉÒÔ¼ÓÉÏÕâÑùµÄÒ»ÐÐÄÚÈÝ£º
\begin{tscreen}
\begin{verbatim}
ExcludeArch: axp
\end{verbatim}
\end{tscreen}

µ½ source ³ÌÊ½Ì×¼þµ±ÖÐ£¬ spec µµ°¸µÄ header ´¦£¬
È»ááÔÚÔ­±¾½øÐÐ build µÄ×÷ÒµÆ½Ì¨ÉÏ£¬ ÔÙ×öÒ»´Î rebuild ¶¯×÷¡£
´ËÊ±£¬ Äú¾ÍÓÐÁËÒ»·ÝÔÚ Intel »úÆ÷ÉÏ build Íê³ÉµÄ source ³ÌÊ½Ì×¼þ£¬
Í¬Ê±ËüÒ²ºÜÈÝÒ×±ãÄÜÒÆ¡õÖÁ Alpha »úÆ÷ÉÏ¡£




\subsection{Finishing Up}

Ê¹ÓÃ RPM À´ÖÆ×÷¡¸¶à×÷ÒµÆ½Ì¨¡¹µÄ³ÌÊ½Ì×¼þ£¬ Í¨³£»á±È¸÷±ðÔÚ¸ÃÆ½Ì¨ÖÆ×÷À´µÃÈÝÒ×£¬
¶øÇÒËæÖøÄúÖÆ×÷Ô½¶àµÄ³ÌÊ½Ì×¼þ£¬ ÆäÐ§Ó¦»á¸ü¼ÓÃ÷ÏÔ£¬ ÒòÎª£¬
ÎÒÃÇ¿ÉÒÔ²Î¿¼ÆäËûÀàËÆµÄÔ­Ê¼³ÌÊ½Ì×¼þÄÚÈÝ£¬ µÃÒÔ´¦ÀíÖÆ×÷Ê±Óöµ½µÄÎÊÌâ¡£




\section{Copyright Notice}

±¾ËµÃ÷ÎÄ¼þ¼°ÆäÄÚÈÝ£¬ ¾ùÊÜ°æÈ¨Ëù±£»¤£¬ ÔÚÔ­ÎÄ±£³ÖÍêÕû¡¢ Î´±»¸ü¶¯µÄÇé¿öÏÂ£¬
ÔÊÐí½«Æä×ªÔØ£¬ Ò²¾ÍÊÇËµ£¬ Äú½öÄÜ¶ÔÔ­ÎÄ¼ÓÒÔÖØÐÂÅÅ°æ¡¢ ÖØÐÂÁÐÓ¡¡¢ »ò½øÐÐ×ªÂ¼¡£





\end{document}
