\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{Bzip2 Howto}
\author{×÷Õß: \\ 
David Fetter, \nameurl{mailto:dfetter@best.com}{dfetter@best.com}\\ 
ÒëÕß:\\ 
Ð»À¥ÖÐ HSIEH KUN-CHUNG, Ì¨Íå ÖÐ»ªÃñ¹ú Taiwan, Republic of China (NOT People's Republic of China)
(µç×ÓÓÊ¼þ {\ttfamily \onlynameurl{linuxer.bbs@cis.nctu.edu.tw}}
»ò{\ttfamily \onlynameurl{linux4tw@geocities.com}}
 ÍøÒ³ "Linux for Taiwan Ì¨ÍåÈËµÄ Linux" {\ttfamily \onlynameurl{http://members.xoom.com/linux4tw/}}\\ }
\date{°æ±¾ v1.92£¬1998Äê 8ÔÂ18ÈÕ}
\abstract{Õâ·ÝÎÄ¼þÔÚ½ÌÄãÈçºÎÊ¹ÓÃÐÂµÄ bzip2 Ñ¹Ëõ³ÌÊ½¡£Ä¿Ç°µÄ sgml °æ±¾±»·ÅÔÚ  EURO
\nameurl{Bzip2-HOWTO.sgml}{Õâ¡õ}£¬»¹ÓÐ "×÷ÕßÓÃµÄ" sgml µµ·ÅÔÚ\nameurl{http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml}{Õâ¶ù}¡£}


\begin{document}
\maketitle
\tableofcontents

\section{¼ò½é}

 Bzip2 ÊÇ¸öºÜ°ôµÄÑ¹Ëõ×ÊÁÏÓÃÖ®ÐÂÐÍÑÝËã·¨¡£´óÖÂÉÏÄÜ¹»´ïµ½ÒÔËüµÄ¶ÔÊÖ
gzip Ëù²ú³öµÄµµ°¸Ö® 60-70\% ×óÓÒµÄÑ¹ËõÂÊ¡£



 Õâ·ÝÎÄ¼þ½«½ÌÄã¼¸¸ö bzip2 µÄÓ¦ÓÃÈíÌå¡£



 ±¾ÎÄ¼þµÄÎ´À´°æ½«»áÌÖÂÛ¼´½«³öÏÖµÄ bzip2 ³ÌÊ½¿â£¬¸Ã³ÌÊ½¿â
Ô­bzip2 µÄ×÷Õß \nameurl{mailto:Julian_Seward@muraroa.demon.co.uk}{Julian Seward} ÃèÊöÈçÏÂ:

\begin{verbatim}
ÏÖÔÚÕýÖÂÁ¦ì¶ bzip2 µÄÏÂÒ»¸ö°æ±¾£¬ËüÒ²½«²ÉÓÃÏàÍ¬µÄ .bz2 µµ°¸¸ñÊ½£»
Ö÷ÒªÔö¼ÓµÄ¹¦ÄÜÊÇÒ»¸öÏñ zlib µÄ³ÌÊ½¿â¡£ÈÃÎÒÃÇ¿ÉÒÔ´Ó³ÌÊ½¡õÍ·À´¶ÁÈ¡ºÍÊéÐ´×ÊÁÏµ½ÕâÖÖ¸ñÊ½µÄµµ°¸¡õ¡£
\end{verbatim}




 ±¾ÎÄ¼þµÄÎ´À´°æ±¾Ò²»á°üº¬ÊÇ·ñÓ¦¸Ã (ÒÔ¼°ÈçºÎ)ÈÃ Linux kernel Ê¹ÓÃ bzip2Ö®ÒéÌâµÄ½áÂÛ¡£




\subsection{{\bfseries ÑØ¸ïÀúÊ·}}


\subsubsection{v1.92
¸üÐÂ \ref{bzip2-binaries} {(È¡µÃ bzip2 ¶þ½øÎ»³ÌÊ½Âë)} ÕÂ½Ú£¬¼ÓÈë S.u.S.E.µÄ¡£}


\subsubsection{v1.91}

 ÔÚ \ref{bzip2-with-tar} {(Ê¹ÓÃ bzip2 ÅäºÏ tar ÄÇÕÂ¡õ)}ÐÞÕýÒ»¸ö¡õÀýÒÔ¼°
ÅªÇå³þÒ»Ð© shell ¾ä×Ó¡£¸ÐÐ» Alessandro Rubini¡£



 ¸üÐÂ buzzit ¹¤¾ß²»»áÈ¥ stomp Ô­À´µÄ bzip2 Ñ¹Ëõµµ¡£



 ÐÂÔö bgrep, Ïñ zgrep-µÄ¹¤¾ß¡£




\subsubsection{v1.9}

 ³ÎÇå gcc 2.7.* µÄÎÊÌâ¡£¸ÐÐ» Ulrik Dickow µÄÈÈÐÄÖ¸³ö¡£



 ¼ÓÈë Leonard Jean-Marc ºÜ°ôµÄÅäºÏ tar



 ¼ÓÉÏ Linus ÅÊerlund µÄÈðµäÎÄ°æ±¾¡£



 ÒÀÕÕ Arnaud Launay µÄ½¨ÒéÐÞÕýÁË wu-ftpd ÕÂ½Ú



 °ÑÒëÎÄ·Åµ½ËüÃÇ×Ô¼ºµÄÎ»ÕÂ½ÚÉÏ¡£




\subsubsection{v1.8}

 °Ñ buzzit ºÍ tar.diff ·Åµ½ sgml ÎÄ¼þ¡õËüÃÇÓ¦¸Ã±»·ÅÖÃµÄµØ·½¡£
ÐÞÕýÆ´×ÖÓë¸ñÊ½¡£¸ÐÐ» Arnaud Launay µÄÐ­ÖúÎÒÐÞÕýÕâ·ÝÎÄ¼þ¡£:-)



 É±µô xv ¼Æ»­£¬Òò´Ë´ó¼Ò²»¸ÐÐËÈ¤¡£



 ¼ÓÉÏ teasers Îª±¾ÎÄ¼þµÄÎ´À´°æ±¾¡£




\subsubsection{v1.7 }

 ¼ÓÈë buzzit ¹«ÓÃ³ÌÊ½¡£ÐÞÕý¶Ô gnu tar µÄÐÞ²¹¡£




\subsubsection{v1.6 }

 ¼ÓÈë TenThumbs µÄ Netscape ÖÂÄÜÕß¡£



 ÒÔ¼°ÒÀ¾ÝËüµÄ½¨Òé¸ü¸Ä lesspipe.sh ¡£ËüÏÖÔÚ¿ÉÒÔ¹¤×÷µÄ¸üºÃÁË¡£




\subsubsection{v1.5 }

 ¼ÓÈë Arnaud Launay µÄ·¨ÎÄÒë±¾£¬ÒÔ¼°ËûµÄ wu-ftpd µµ¡£




\subsubsection{v1.4 }

 ¼ÓÈë Tetsu Isaji µÄÈÕÎÄÒë±¾¡£




\subsubsection{v1.3 }

 ¼ÓÈë Ulrik Dickow ¸ø 19.30 »ò¸ü¸ß°æ±¾ÓÃµÄ .emacs µµ¡õ


(»¹ÓÐÐÞÕý¸ø emacsÓÃµÄ jka-compr.el ÐÞ²¹µµ¡£ÔãÁË!
Bzip2 »¹Ã»ÓÐ(?)  "append" µÄÆì±êÑ¡Ïî¡£)




\subsubsection{v1.2  }

 ¼ÓÈë¶Ô emacs µÄÐÞ²¹£¬ÈÃËü¿ÉÒÔ×Ô¶¯µØ°ìÊ¶³ö .bz2 µµ¡£




\subsubsection{v1.1 }

  ¼ÓÈë¶Ô emacs




\subsubsection{v1.0  }

 µÚÒ»»ØºÏ¡£






\section{È¡µÃ bzip2\label{get-bzip2}}

Bzip2 µÄÖ÷ÍøÒ³ÔÚ \nameurl{http://www.muraroa.demon.co.uk/}{Ó¢¹úµÄÖ÷ÍøÕ¾}¡£
ÃÀ¹úµÄÓ³ÉäÕ¾ÔÚ \nameurl{http://www.digistar.com/bzip2/index.html}{Õâ¡õ}¡£ÄãÒ²¿ÉÒÔÔÚ Red
Hat µÄftp Õ¾¡õ \nameurl{ftp://ftp.redhat.com/pub/contrib}{ÕÒµ½}¡£




\subsection{Bzip2-HOWTO ¸÷ÖÖÓïÑÔ°æ±¾}

 Ëµ·¨ÓïµÄÈË¿ÉÒÔ¿´¿´ Arnaud Launay µÄ·¨ÎÄÎÄ¼þ¡£
ÍøÒ³°æ±¾ÔÚ \nameurl{http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html}{Õâ¡õ}£¬Äã¿ÉÒÔÓÃ ftp \nameurl{ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz}{À´È¡µÃ}
Äã¿ÉÒÔÓÃ\nameurl{mailto:zoro@mygale.org}{µç×ÓÓÊ¼þ}À´Á¬ÂçArnaud



 ËµÈÕÓïµÄÈË¿ÉÒÔ¿´¿´ Tetsu IsajiµÄ \nameurl{http://jf.gee.kyoto-u.ac.jp/JF/JF.html}{ÈÕÎÄÒë±¾}¡£
Äã¿ÉÒÔÓÃÉÏIsajiµÄ \nameurl{http://www2s.biglobe.ne.jp/~kaien/}{ÍøÕ¾}£¬»òÊÇÓÃ \nameurl{mailto:isaji@mxu.meshnet.or.jp}{µç×ÓÓÊ¼þ}µÄ·½Ê½¡£





 ËµÈðµäÓïµÄÅóÓÑ¿ÉÒÔ²ÎÔÄ Linus ÅÊerlund µÄÈðµäÎÄÒë±¾
\nameurl{http://user.tninet.se/~uxm165t/linux_doc.html}{°´Õâ}¡£Äã¿ÉÒÔÓÃ
\nameurl{mailto:uxm165t@tninet.se}{µç×ÓÓÊ¼þ} Óë Linus Á¬Âç¡£




\subsection{È¡µÃ bzip2 Î´±àÒëµÄ¶þ½øÎ»µµ\label{bzip2-binaries}}

²éÒ»ÏÂÖ÷ÍøÕ¾¡£



Debian µÄIntel ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://ftp.debian.org/debian/dists/stable/main/binary-i386/utils/bzip2_0.1pl2-5.deb}{Õâ¡õ}¡£



Red HatµÄ alpha ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/alpha/RedHat/RPMS/bzip2-0.1pl2-1.alpha.rpm}{Õâ¡õ}¡£



Red HatµÄ Intel ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/i386/RedHat/RPMS/bzip2-0.1pl2-1.i386.rpm}{Õâ¡õ}¡£



Red HatµÄ SPARC ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/sparc/RedHat/RPMS/bzip2-0.1pl2-1.sparc.rpm}{Õâ¡õ}¡£



 SlackwareµÄ Intel ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://www.cdrom.com/pub/linux/slackware-3.5/slakware/a1/bzip2.tgz}{Õâ¡õ}¡£



 S.u.S.E.µÄ Intel ¶þ½øÎ»³ÌÊ½ÂëÔÚ \nameurl{ftp://ftp.suse.com/pub/SuSE-Linux/5.2/suse/ap1/bzip.rpm}{Õâ¡õ}¡£

ÄãÒ²¿ÉÒÔ´ÓÐí¶àÏàÀàËÆµÄÓ³ÉäÕ¾µÃÈ¡µÃµµ°¸¡£




\subsection{È¡µÃ bzip2 Ô­Ê¼³ÌÊ½}

Äã¿ÉÒÔ´Ó¹Ù·½µÄÍøÕ¾ (¿´ \ref{get-bzip2} {(Getting Bzip2)}
£¬»òÊÇ Red Hat Ò²ÓÐ \nameurl{ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm}{Ëü})¡£




\subsection{±àÒë bzip2 ¸øÄãµÄ»úÆ÷Ê¹ÓÃ}

{\bfseries Èç¹ûÄãÓÐ gcc 2.7.*}£¬½«ÏÂÃæÕâÐÐ
\begin{tscreen}
\begin{verbatim}
CFLAGS = -O3 -fomit-frame-pointer -funroll-loops
\end{verbatim}
\end{tscreen}


¸Ä³É
\begin{tscreen}
\begin{verbatim}
CFLAGS = -O2 -fomit-frame-pointer
\end{verbatim}
\end{tscreen}


 Ò²¾ÍÊÇ£¬°Ñ -O2 ¸Ä³É -O3 ²¢°Ñ -funroll-loopsÉ¾µô¡£ÄãÒ²¿ÉÒÔ¼ÓÈëÈÎºÎÄãÔÚ±àÒë kernel Ê±µÄ -m* Æì±ê
(ÀýÈçÏñ -m486)¡£

  ±ÜÃâÊ¹ÓÃ -funroll-loops ÊÇ×îÖØÒªµÄÁË£¬ÒòÎªËü»áÔì³ÉÐí¶àµÄ
gcc 2.7²úÉú´íÎóµÄ³ÌÊ½Âë£¬ÒÔ¼°È«²¿µÄ gcc 2.7 ²úÉúËÙ¶ÈÂýÓÖ½ÏÅÖµÄ³ÌÊ½Âë¡£
¶ÔÆäËûµÄ±àÒëÆ÷ (lcc, egcs, gcc 2.8.x) Ê¹ÓÃÄÚ¶¨µÄ CFLAGS ¾ÍÃ»ÎÊÌâ¡£

Ö®áá£¬Ö»Ðè {\ttfamily make} Ëü£¬È»ááÒÀÕÕ README À´°²×°Ëü¡£




\section{Ê¹ÓÃ bzip2}

Çë²ÎÔÄºÜ°ôµÄÊÖ²á :)




\section{ÅäºÏ tarÀ´Ê¹ÓÃ bzip2\label{bzip2-with-tar}}

ÏÂÃæÓÐÈýÖÖÅäºÏ tar Ê¹ÓÃ bzip2 µÄ·½·¨£¬Ò²¾ÍÊÇ


\subsection{ÈÝÒ×ÉèÁ¢:}

Õâ¸ö·½·¨¸ú±¾¾Í²»±Ø×öÉè¶¨¡£Ö´ÐÐ½â¿ªbzip2'd µÄ tar°ü¹ü£¬
ÔÚÏÖÐÐÄ¿Â¼µ×ÏÂÓÐ¸ö foo.tar.bz2£¬Ö´ÐÐ
\begin{tscreen}
\begin{verbatim}
/path/to/bzip2 -cd foo.tar.bz2 | tar xf -
\end{verbatim}
\end{tscreen}


³É¹¦ÁË£¬µ«¿ÉÄÜÓÐ³£ÐèÊäÈëµÄÐ¡È±µã¡£




\subsection{ÈÝÒ×ÉèÁ¢£¬ÈÝÒ×Ê¹ÓÃ£¬²»ÐèÒª root µÄÌØÈ¨:}

 ¸ÐÐ» \nameurl{mailto:leonard@sct1.is.belgacom.be}{Leonard Jean-Marc} ¹±Ï×Õâ¸öÐ¡¼¼ÇÉ¡£Ò²Ð»Ð» \nameurl{mailto:rubini@morgana.systemy.it}{Alessandro Rubini} ´Ó csh¡õ·ÖÀà
³ö bash µÄ¡£



ÔÚÄãµÄ .bashrc¡õ£¬Äã¿ÉÒÔ¼ÓÈëÏñÏÂÃæÕâÐÐ:
\begin{tscreen}
\begin{verbatim}
alias btar='tar --use-compress-program /usr/local/bin/bzip2 '
\end{verbatim}
\end{tscreen}




ÔÚÄãµÄ .tcshrc »ò .cshrc¡õ£¬¿ÉÓÃÏÂÃæÕâÐÐÏàÍ¬µÄ:
\begin{tscreen}
\begin{verbatim}
alias btar 'tar --use-compress-program /usr/local/bin/bzip2'
\end{verbatim}
\end{tscreen}





\subsection{Í¬ÑùÊÇÈÝÒ×Ê¹ÓÃ£¬µ«ÐèÒª root À´´æÈ¡¡£}

ÓÃÏÂÃæÀ´·½·¨À´ÐÞ²¹ gnu tar 1.12£º
\begin{tscreen}
\begin{verbatim}
cd tar-1.12/src; patch < /path/to/tar.diff
\end{verbatim}
\end{tscreen}

±àÒë¡¢°²×°Ëü£¬ÄãÒÑ×¼±¸¾ÍÐ÷ÁË¡£ÓÃ"which tar" ºÍ "which bzip2"À´È·ÈÏÕâÁ½¸ö
tar ºÍ bzip2 ÓÐÔÚÄãµÄ \$PATH ¡õ¡£ÒªÊ¹ÓÃÐÂµÄ tar£¬Ö»Ðè
\begin{tscreen}
\begin{verbatim}
 tar xyf foo.tar.bz2
\end{verbatim}
\end{tscreen}

À´Ñ¹Ëõµµ°¸¡£

ÒªÖÆ×÷ÐÂµÄÑ¹Ëõµµ£¬Í¬ÑùµØ:
\begin{tscreen}
\begin{verbatim}
 tar cyf foo.tar.bz2 µµÃû1 µµÃû2 µµÃû3...Ä¿Â¼1 Ä¿Â¼2...
\end{verbatim}
\end{tscreen}


ÏÂÃæÊÇÐÞ²¹µÄµØ·½:
\begin{verbatim}
*** tar.c       Thu Jun 11 00:09:23 1998
--- tar.c.new   Thu Jun 11 00:14:24 1998
***************
*** 196,201 ****
--- 196,203 ----
    {"block-number", no_argument, NULL, 'R'},
    {"block-size", required_argument, NULL, OBSOLETE_BLOCKING_FACTOR},
    {"blocking-factor", required_argument, NULL, 'b'},
+   {"bzip2", required_argument, NULL, 'y'},
+   {"bunzip2", required_argument, NULL, 'y'},
    {"catenate", no_argument, NULL, 'A'},
    {"checkpoint", no_argument, &checkpoint_option, 1},
    {"compare", no_argument, NULL, 'd'},
***************
*** 372,377 ****
--- 374,380 ----
                PATTERN                at list/extract time, a globbing PATTERN\n\
    -o, --old-archive, --portability   write a V7 format archive\n\
        --posix                        write a POSIX conformant archive\n\
+   -y, --bzip2, --bunzip2             filter the archive through bzip2\n\
    -z, --gzip, --ungzip               filter the archive through gzip\n\
    -Z, --compress, --uncompress       filter the archive through compress\n\
        --use-compress-program=PROG    filter through PROG (must accept -d)\n"),
***************
*** 448,454 ****
     Y  per-block gzip compression */

  #define OPTION_STRING \
!   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz"

  static void
  set_subcommand_option (enum subcommand subcommand)
--- 451,457 ----
     Y  per-block gzip compression */

  #define OPTION_STRING \
!   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxyz"

  static void
  set_subcommand_option (enum subcommand subcommand)
***************
*** 805,810 ****
--- 808,817 ----
        case 'X':
        exclude_option = 1;
        add_exclude_file (optarg);
+       break;
+
+       case 'y':
+       set_use_compress_program_option ("bzip2");
        break;

        case 'z':
\end{verbatim}





\section{Ê¹ÓÃ bzip2 À´ÅäºÏ less}

ÂíÉÏ½âÑ¹Ëõ bzip2 µµ£¬ÀýÈç£¬ÔÚ²»±ØÏÈ bunzip2 µµ°¸µÄÇ°ÌáÏÂ¼´¿ÉÓÃ "less"
µ½ËüÃÇÉíÉÏ£¬Äã¿ÉÒÔ×ö¸ö lesspipe.sh (man less)£¬ÏñÏÂÃæ£º
\begin{verbatim}
#!/bin/sh
# This is a preprocessor for 'less'.  It is used when this environment
# variable is set:   LESSOPEN="|lesspipe.sh %s"

  case "$1" in
  *.tar) tar tvvf $1 2>/dev/null ;; # View contents of various tar'd files
  *.tgz) tar tzvvf $1 2>/dev/null ;;
# This one work for the unmodified version of tar:
  *.tar.bz2) bzip2 -cd $1 $1 2>/dev/null | tar tzvvf - ;;
#This one works with the patched version of tar:
# *.tar.bz2) tyvvf $1 2>/dev/null ;;
  *.tar.gz) tar tzvvf $1 2>/dev/null ;;
  *.tar.Z) tar tzvvf $1 2>/dev/null ;;
  *.tar.z) tar tzvvf $1 2>/dev/null ;;
  *.bz2) bzip2 -dc $1  2>/dev/null ;; # View compressed files correctly
  *.Z) gzip -dc $1  2>/dev/null ;;
  *.z) gzip -dc $1  2>/dev/null ;;
  *.gz) gzip -dc $1  2>/dev/null ;;
  *.zip) unzip -l $1 2>/dev/null ;;
  *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` ; # groff src
    FILE=`echo $FILE | cut -d ' ' -f 2`
    if [ "$FILE" = "troff" ]; then
      groff -s -p -t -e -Tascii -mandoc $1
    fi ;;
  *) cat $1 2>/dev/null ;;
#  *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings'
#    FILE1=`echo $FILE | cut -d ' ' -f 2`
#    FILE2=`echo $FILE | cut -d ' ' -f 3`
#    if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
#         -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
#      strings $1
#    fi ;;
  esac
\end{verbatim}





\section{Ê¹ÓÃ bzip2 À´½áºÏ emacs}


\subsection{ÎªÃ¿¸öÈË¸Ä±ä emacs:}

ÎÒÐ´ÁËÏÂÃæµÄ¸ø jka-compr.el ÓÃµÄÐÞ²¹£¬Ëü»á¼ÓÈë bzip2 ³ÉÎª×Ô¶¯Ñ¹ËõÄ£Ê½¡£

{\bfseries ³ýÍâÌõ¿î:} ÎÒÖ»ÔÚ emacs-20.2ÉÏÊÔ¹ýÕâ¸ö£¬µ«ÊÇÎÒÒ²ÕÒ²»µ½ÓÐ
É¶÷áÀíÓÉÀ´ÏàÐÅÍ¬ÑùµÄ·½·¨È´²»ÄÜÔÚÆäËû°æ±¾ÉÏÊ¹ÓÃµÄ¡£

Ê¹ÓÃËü£¬
\begin{enumerate}
\item µ½ emacs-20.2/lisp Ô­Ê¼³ÌÊ½ÂëÄ¿Â¼¡õ (¿´ÄãÔÚÄÄ¶ù untarred ËüµÄ)
\item °ÑÏÂÃæµÄÐÞ²¹×ö³É½Ð jka-compr.el.diff µÄµµ°¸(È«·ÅÔÚÕâµµ°¸¡õ
)¡£
\item È»ááÖ´ÐÐ
\begin{tscreen}
\begin{verbatim}
 patch < jka-compr.el.diff
\end{verbatim}
\end{tscreen}
\item Æô¶¯ emacs£¬ÔÙÖ´ÐÐ
\begin{tscreen}
\begin{verbatim}
 M-x byte-compile-file jka-compr.el
\end{verbatim}
\end{tscreen}
\item Àë¿ª emacs¡£
\item °ÑËüÔ­À´µÄ jka-compr.elc ·Åµ½°²È«µÄµØ·½ÒÔ·ÀÓÐ³ô³æÊ±±¸ÓÃ¡£
\item ÓÃÐÂµÄ jka-compr.elcÀ´´úÌæËü¡£
\item ºÃºÃÍæ°É!
\end{enumerate}

\begin{verbatim}
--- jka-compr.el        Sat Jul 26 17:02:39 1997
+++ jka-compr.el.new    Thu Feb  5 17:44:35 1998
@@ -44,7 +44,7 @@
 ;; The variable, jka-compr-compression-info-list can be used to
 ;; customize jka-compr to work with other compression programs.
 ;; The default value of this variable allows jka-compr to work with
-;; Unix compress and gzip.
+;; Unix compress and gzip.  David Fetter added bzip2 support :)
 ;;
 ;; If you are concerned about the stderr output of gzip and other
 ;; compression/decompression programs showing up in your buffers, you
@@ -121,7 +121,9 @@


 ;;; I have this defined so that .Z files are assumed to be in unix
-;;; compress format; and .gz files, in gzip format.
+;;; compress format; and .gz files, in gzip format, and .bz2 files,
+;;; in the snappy new bzip2 format from http://www.muraroa.demon.co.uk.
+;;; Keep up the good work, people!
 (defcustom jka-compr-compression-info-list
   ;;[regexp
   ;; compr-message  compr-prog  compr-args
@@ -131,6 +133,10 @@
      "compressing"    "compress"     ("-c")
      "uncompressing"  "uncompress"   ("-c")
      nil t]
+    ["\\.bz2\\'"
+     "bzip2ing"        "bzip2"         ("")
+     "bunzip2ing"      "bzip2"         ("-d")
+     nil t]
     ["\\.tgz\\'"
      "zipping"        "gzip"         ("-c" "-q")
      "unzipping"      "gzip"         ("-c" "-q" "-d")
\end{verbatim}





\subsection{ÎªÄ³ÈË¸Ä±ä emacs:}

Õâ´ÎÒªÐ»Ð» Ulrik Dickow, \nameurl{mailto:ukdATkampsax.dk}{ukd@kampsax.dk}£¬ËûÊÇKampsax TechnologyµÄÏµÍ³³ÌÊ½Éè¼ÆÊ¦ :

ÎªÁËÈÃ·Ç sysadmin µÄÅóÓÑ¿ÉÒÔ×Ô¶¯µØÊ¹ÓÃ bzip2£¬Ö»ÐèÔÚÄãµÄ
.emacs µµ°¸¡õ¼ÓÉÏÏÂÁÐ¶«¶«¡£

\begin{verbatim}
;; Automatic (un)compression on loading/saving files (gzip(1) and similar)
;; We start it in the off state, so that bzip2(1) support can be added.
;; Code thrown together by Ulrik Dickow for ~/.emacs with Emacs 19.34.
;; Should work with many older and newer Emacsen too.  No warranty though.
;;
(if (fboundp 'auto-compression-mode) ; Emacs 19.30+
    (auto-compression-mode 0)
  (require 'jka-compr)
  (toggle-auto-compression 0))
;; Now add bzip2 support and turn auto compression back on.
(add-to-list 'jka-compr-compression-info-list
             ["\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'"
              "zipping"        "bzip2"         ()
              "unzipping"      "bzip2"         ("-d")
              nil t])
(toggle-auto-compression 1 t)
\end{verbatim}





\section{ÓÃ bzip2 À´ÅäºÏ wu-ftpd}

¸ÐÐ» Arnaud Launay ÕâÔò½ÚÊ¡Æµ¿íµÄÃØ¾÷¡£ÏÂÃæµÄÄÚÈÝÓ¦¸ÃÊÇ·Åµ½
/etc/ftpconversions ¡õÃæÀ´´ï³ÉÒÔ bzip2 À´×ö¼´Ê±Ñ¹Ëõ¼°½âÑ¹Ëõ
¡£ÇëÈ·ÈÏÂ·¾¶ (Ïñ /bin/compress) ÒªÕýÈ·¡£

\begin{verbatim}
 :.Z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
 :   : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
 :.gz: :  :/bin/gzip -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP
 :   : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
 :.bz2: :  :/bin/bzip2 -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:BUNZIP2
 :   : :.bz2:/bin/bzip2 -9 -c %s:T_REG:O_COMPRESS:BZIP2
 :   : :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
 :   : :.tar.Z:/bin/tar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
 :   : :.tar.gz:/bin/tar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
 :   : :.tar.bz2:/bin/tar -c -y -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+BZIP2
\end{verbatim}





\section{Ê¹ÓÃ bzip2 À´ÅäºÏ grep}

ÏÂÃæµÄ¹«ÓÃ³ÌÊ½£¬ÎÒ¹ÜËü½Ð bgrep£¬ÊÂÊµÉÏÊÇ°Ñ°éËæÔÚ Linux µÄ zgrep ×ö¸öÐ¡¸ü¸Ä
¶øÒÑ¡£Äã¿ÉÒÔÊ¹ÓÃËüÀ´ grep£¬¶ø²»ÐèÏÈ bunzip2 µµ°¸¡£

\begin{verbatim}
#!/bin/sh

# bgrep -- a wrapper around a grep program that decompresses files as needed
PATH="/usr/bin:$PATH"; export PATH

prog=`echo $0 | sed 's|.*/||'`
case "$prog" in
        *egrep) grep=${EGREP-egrep}     ;;
        *fgrep) grep=${FGREP-fgrep}     ;;
        *)      grep=${GREP-grep}       ;;
esac
pat=""
while test $# -ne 0; do
  case "$1" in
  -e | -f) opt="$opt $1"; shift; pat="$1"
           if test "$grep" = grep; then  # grep is buggy with -e on SVR4
             grep=egrep
           fi;;
  -*)      opt="$opt $1";;
   *)      if test -z "$pat"; then
             pat="$1"
           else
             break;
           fi;;
  esac
  shift
done

if test -z "$pat"; then
  echo "grep through bzip2 files"
  echo "usage: $prog [grep_options] pattern [files]"
  exit 1
fi

list=0
silent=0
op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
case "$op" in
  *l*) list=1
esac
case "$op" in
  *h*) silent=1
esac

if test $# -eq 0; then
  bzip2 -cd | $grep $opt "$pat"
  exit $?
fi

res=0
for i do
  if test $list -eq 1; then
    bzip2 -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i
    r=$?
  elif test $# -eq 1 -o $silent -eq 1; then
    bzip2 -cd "$i" | $grep $opt "$pat"
    r=$?
  else
    bzip2 -cd "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
    r=$?
  fi
  test "$r" -ne 0 && res="$r"
done
exit $res
\end{verbatim}





\section{bzip2 ÅäºÏ X ÏÂµÄ Netscape À´Ê¹ÓÃ¡£}

tenthumbs@cybernex.net Ëµ:

\begin{tscreen}
ÎÒÕÒµ½Ò»¸ö¿ÉÒÔÈÃ Linux Netscape À´Ê¹ÓÃ bzip2 ×öÎª Content-Encoding
¾ÍÈçÍ¬ËüÊ¹ÓÃ gzip Ò»Ñù¡£°ÑÏÂÃæµÄ¶«¶«¼Óµ½ \$HOME/.Xdefaults »òÊÇ
\$HOME/.Xresources
ÎÒÊ¹ÓÃ -s Ñ¡Ïî£¬ÊÇÒòÎªÑ¡Ôñ·ÅÆú½âÑ¹ËõµÄËÙ¶ÈÀ´»»µÃ RAM µÄÕ¼ÓÃ¡£
Äã¿ÉÒÔ°ÑËüÉè³ÉÄã×Ô¼ºÒªµÄ¡£

\end{tscreen}


\begin{verbatim}
Netscape*encodingFilters:      \
        x-compress :  : .Z     : uncompress -c  \n\
        compress   :  : .Z     : uncompress -c  \n\
        x-gzip     :  : .z,.gz : gzip -cdq      \n\
        gzip       :  : .z,.gz : gzip -cdq      \n\
        x-bzip2    :  : .bz2   : bzip2 -ds \n
\end{verbatim}





\section{Ê¹ÓÃ bzip2 À´ÔÙÑ¹ËõÆäËûµÄÑ¹Ëõ¸ñÊ½}

ÏÂÃæµÄ perl ³ÌÊ½»á°ÑÒÔÏÂÁÐµÄÑ¹Ëõ¸ñÊ½µµ (.tar.gz, .tgz. .tar.Z, ºÍ .Z for this iteration)
ÖØÐÂ´ò°ü³É×î¼ÑµÄÑ¹ËõÖµ¡£Õâ perl Ô­Ê¼³ÌÊ½¶¼ÓÐÈ«·½Î»µÄºÃÎÄ¼þ
À´ËµÃ÷Ëü×öÊ²÷áÒÔ¼°ËüÈçºÎ°ìµ½µÄ¡£
\begin{verbatim}
#!/usr/bin/perl -w

#######################################################
#                                                     #
# This program takes compressed and gzipped programs  #
# in the current directory and turns them into bzip2  #
# format.  It handles the .tgz extension in a         #
# reasonable way, producing a .tar.bz2 file.          #
#                                                     #
#######################################################
$counter = 0;
$saved_bytes = 0;
$totals_file = '/tmp/machine_bzip2_total';
$machine_bzip2_total = 0;

while(<*[Zz]>) {
    next if /^bzip2-0.1pl2.tar.gz$/;
    push @files, $_;
}
$total = scalar(@files);

foreach (@files) {
    if (/tgz$/) {
        ($new=$_) =~ s/tgz$/tar.bz2/;
    } else {
        ($new=$_) =~ s/\.g?z$/.bz2/i;
    }
    $orig_size = (stat $_)[7];
    ++$counter;
    print "Repacking $_ ($counter/$total)...\n";
    if ((system "gzip -cd $_ |bzip2 >$new") == 0) {
        $new_size = (stat $new)[7];
        $factor = int(100*$new_size/$orig_size+.5);
        $saved_bytes += $orig_size-$new_size;
        print "$new is about $factor% of the size of $_. :",($factor<100)?')':'(',"\n";
        unlink $_;
    } else {
        print "Arrgghh!  Something happened to $_: $!\n";
    }
}
print "You've ",
      ($saved_bytes>=0)?"saved":"lost",
      " $saved_bytes bytes of storage space :",
       ($saved_bytes>=0)?")":"(", "\n";

unless (-e '/tmp/machine_bzip2_total') {
    system ('echo "0" >/tmp/machine_bzip2_total');
    system ('chmod', '0666', '/tmp/machine_bzip2_total');
}


chomp($machine_bzip2_total = `cat $totals_file`);
open TOTAL, ">$totals_file"
     or die "Can't open system-wide total: $!";
$machine_bzip2_total += $saved_bytes;
print TOTAL $machine_bzip2_total;
close TOTAL;

print "That's a machine-wide total of ",`cat $totals_file`," bytes saved.\n";
\end{verbatim}





\section{ÖÐÒë±¾}

ÒëÕß×¢: ÈôÄú·¢ÏÖ±¾ÎÄ¼þÄÚÈÝÓÐ·­Òë²»Ë³³©»ò´íÎóµÄµØ·½£¬ÇëÄúÀ´ÐÅ¸æËßÎÒ£¬ÒÔ×ö¸üÕý£¬Ð»Ð»¡£
ÒëÕßµç×ÓÓÊ¼þ {\ttfamily \onlynameurl{linuxer.bbs@cis.nctu.edu.tw}}
»ò\onlynameurl{linux4tw@geocities.com}

Òë×¢£ºÕâ·Ý HOWTO ÎÄ¼þµÄÖÐÎÄ°æ¿ÉÔÚÌ¨Íå Linux Ê¹ÓÃÕß×éÖ¯ÏÂµÄÖÐÎÄ Linux
ÎÄ¼þ¼Æ»­\nameurl{http://www.linux.org.tw/CLDP/}{}\\ 
»òÊÇ"Linux for Taiwan Ì¨ÍåÈËµÄ Linux "\onlynameurl{http://members.xoom.com/linux4tw/}
ÏÂÈ¡µÃ¡£

\end{document}
