\documentclass[letterpaper]{article}
\nonstopmode
\bkai
\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}\\ 
Ä¶ªÌ:\\ 
ÁÂ±X¤¤ HSIEH KUN-CHUNG, ¥xÆW ¤¤µØ¥Á°ê Taiwan, Republic of China (NOT People's Republic of China)
(¹q¤l¶l¥ó {\ttfamily \onlynameurl{linuxer.bbs@cis.nctu.edu.tw}}
©Î{\ttfamily \onlynameurl{linux4tw@geocities.com}}
 ºô­¶ "Linux for Taiwan ¥xÆW¤Hªº Linux" {\ttfamily \onlynameurl{http://members.xoom.com/linux4tw/}}\\ }
\date{ª©¥» v1.92¡A1998¦~ 8¤ë18¤é}
\abstract{³o¥÷¤å¥ó¦b±Ð§A¦p¦ó¨Ï¥Î·sªº bzip2 À£ÁYµ{¦¡¡C¥Ø«eªº sgml ª©¥»³Q©ñ¦b  EURO
\nameurl{Bzip2-HOWTO.sgml}{³oùØ}¡AÁÙ¦³ "§@ªÌ¥Îªº" sgml ÀÉ©ñ¦b\nameurl{http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml}{³o¨à}¡C}


\begin{document}
\maketitle
\tableofcontents

\section{Â²¤¶}

 Bzip2 ¬O­Ó«Ü´ÎªºÀ£ÁY¸ê®Æ¥Î¤§·s«¬ºtºâªk¡C¤j­P¤W¯à°÷¹F¨ì¥H¥¦ªº¹ï¤â
gzip ©Ò²£¥XªºÀÉ®×¤§ 60-70\% ¥ª¥kªºÀ£ÁY²v¡C



 ³o¥÷¤å¥ó±N±Ð§A´X­Ó bzip2 ªºÀ³¥Î³nÅé¡C



 ¥»¤å¥óªº¥¼¨Óª©±N·|°Q½×§Y±N¥X²{ªº bzip2 µ{¦¡®w¡A¸Óµ{¦¡®w
­ìbzip2 ªº§@ªÌ \nameurl{mailto:Julian_Seward@muraroa.demon.co.uk}{Julian Seward} ´y­z¦p¤U:

\begin{verbatim}
²{¦b¥¿­P¤O©ó bzip2 ªº¤U¤@­Óª©¥»¡A¥¦¤]±N±Ä¥Î¬Û¦Pªº .bz2 ÀÉ®×®æ¦¡¡F
¥D­n¼W¥[ªº¥\¯à¬O¤@­Ó¹³ zlib ªºµ{¦¡®w¡CÅý§Ú­Ì¥i¥H±qµ{¦¡ùØÀY¨ÓÅª¨ú©M®Ñ¼g¸ê®Æ¨ì³oºØ®æ¦¡ªºÀÉ®×ùØ¡C
\end{verbatim}




 ¥»¤å¥óªº¥¼¨Óª©¥»¤]·|¥]§t¬O§_À³¸Ó (¥H¤Î¦p¦ó)Åý Linux kernel ¨Ï¥Î bzip2¤§Ä³ÃDªºµ²½×¡C




\subsection{{\bfseries ªu­²¾ú¥v}}


\subsubsection{v1.92
§ó·s \ref{bzip2-binaries} {(¨ú±o bzip2 ¤G¶i¦ìµ{¦¡½X)} ³¹¸`¡A¥[¤J S.u.S.E.ªº¡C}


\subsubsection{v1.91}

 ¦b \ref{bzip2-with-tar} {(¨Ï¥Î bzip2 °t¦X tar ¨º³¹ùØ)}­×¥¿¤@­Ó½d¨Ò¥H¤Î
§Ë²M·¡¤@¨Ç shell ¥y¤l¡C·PÁÂ Alessandro Rubini¡C



 §ó·s buzzit ¤u¨ã¤£·|¥h stomp ­ì¨Óªº bzip2 À£ÁYÀÉ¡C



 ·s¼W bgrep, ¹³ zgrep-ªº¤u¨ã¡C




\subsubsection{v1.9}

 ¼á²M gcc 2.7.* ªº°ÝÃD¡C·PÁÂ Ulrik Dickow ªº¼ö¤ß«ü¥X¡C



 ¥[¤J Leonard Jean-Marc «Ü´Îªº°t¦X tar



 ¥[¤W Linus Ãkerlund ªº·ç¨å¤åª©¥»¡C



 ¨Ì·Ó Arnaud Launay ªº«ØÄ³­×¥¿¤F wu-ftpd ³¹¸`



 §âÄ¶¤å©ñ¨ì¥¦­Ì¦Û¤vªº¦ì³¹¸`¤W¡C




\subsubsection{v1.8}

 §â buzzit ©M tar.diff ©ñ¨ì sgml ¤å¥óùØ¥¦­ÌÀ³¸Ó³Q©ñ¸mªº¦a¤è¡C
­×¥¿«÷¦r»P®æ¦¡¡C·PÁÂ Arnaud Launay ªº¨ó§U§Ú­×¥¿³o¥÷¤å¥ó¡C:-)



 ±þ±¼ xv ­pµe¡A¦]¦¹¤j®a¤£·P¿³½ì¡C



 ¥[¤W teasers ¬°¥»¤å¥óªº¥¼¨Óª©¥»¡C




\subsubsection{v1.7 }

 ¥[¤J buzzit ¤½¥Îµ{¦¡¡C­×¥¿¹ï gnu tar ªº­×¸É¡C




\subsubsection{v1.6 }

 ¥[¤J TenThumbs ªº Netscape ­P¯àªÌ¡C



 ¥H¤Î¨Ì¾Ú¥¦ªº«ØÄ³§ó§ï lesspipe.sh ¡C¥¦²{¦b¥i¥H¤u§@ªº§ó¦n¤F¡C




\subsubsection{v1.5 }

 ¥[¤J Arnaud Launay ªºªk¤åÄ¶¥»¡A¥H¤Î¥Lªº wu-ftpd ÀÉ¡C




\subsubsection{v1.4 }

 ¥[¤J Tetsu Isaji ªº¤é¤åÄ¶¥»¡C




\subsubsection{v1.3 }

 ¥[¤J Ulrik Dickow µ¹ 19.30 ©Î§ó°ªª©¥»¥Îªº .emacs ÀÉ¡



(ÁÙ¦³­×¥¿µ¹ emacs¥Îªº jka-compr.el ­×¸ÉÀÉ¡CÁV¤F!
Bzip2 ÁÙ¨S¦³(?)  "append" ªººX¼Ð¿ï¶µ¡C)




\subsubsection{v1.2  }

 ¥[¤J¹ï emacs ªº­×¸É¡AÅý¥¦¥i¥H¦Û°Ê¦a¿ìÃÑ¥X .bz2 ÀÉ¡C




\subsubsection{v1.1 }

  ¥[¤J¹ï emacs




\subsubsection{v1.0  }

 ²Ä¤@¦^¦X¡C






\section{¨ú±o bzip2\label{get-bzip2}}

Bzip2 ªº¥Dºô­¶¦b \nameurl{http://www.muraroa.demon.co.uk/}{­^°êªº¥Dºô¯¸}¡C
¬ü°êªº¬M®g¯¸¦b \nameurl{http://www.digistar.com/bzip2/index.html}{³oùØ}¡C§A¤]¥i¥H¦b Red
Hat ªºftp ¯¸ùØ \nameurl{ftp://ftp.redhat.com/pub/contrib}{§ä¨ì}¡C




\subsection{Bzip2-HOWTO ¦UºØ»y¨¥ª©¥»}

 »¡ªk»yªº¤H¥i¥H¬Ý¬Ý Arnaud Launay ªºªk¤å¤å¥ó¡C
ºô­¶ª©¥»¦b \nameurl{http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html}{³oùØ}¡A§A¥i¥H¥Î ftp \nameurl{ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz}{¨Ó¨ú±o}
§A¥i¥H¥Î\nameurl{mailto:zoro@mygale.org}{¹q¤l¶l¥ó}¨Ó³sµ¸Arnaud



 »¡¤é»yªº¤H¥i¥H¬Ý¬Ý Tetsu Isajiªº \nameurl{http://jf.gee.kyoto-u.ac.jp/JF/JF.html}{¤é¤åÄ¶¥»}¡C
§A¥i¥H¥Î¤WIsajiªº \nameurl{http://www2s.biglobe.ne.jp/~kaien/}{ºô¯¸}¡A©Î¬O¥Î \nameurl{mailto:isaji@mxu.meshnet.or.jp}{¹q¤l¶l¥ó}ªº¤è¦¡¡C





 »¡·ç¨å»yªºªB¤Í¥i¥H°Ñ¾\ Linus Ãkerlund ªº·ç¨å¤åÄ¶¥»
\nameurl{http://user.tninet.se/~uxm165t/linux_doc.html}{«ö³o}¡C§A¥i¥H¥Î
\nameurl{mailto:uxm165t@tninet.se}{¹q¤l¶l¥ó} »P Linus ³sµ¸¡C




\subsection{¨ú±o bzip2 ¥¼½sÄ¶ªº¤G¶i¦ìÀÉ\label{bzip2-binaries}}

¬d¤@¤U¥Dºô¯¸¡C



Debian ªºIntel ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://ftp.debian.org/debian/dists/stable/main/binary-i386/utils/bzip2_0.1pl2-5.deb}{³oùØ}¡C



Red Hatªº alpha ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/alpha/RedHat/RPMS/bzip2-0.1pl2-1.alpha.rpm}{³oùØ}¡C



Red Hatªº Intel ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/i386/RedHat/RPMS/bzip2-0.1pl2-1.i386.rpm}{³oùØ}¡C



Red Hatªº SPARC ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://ftp.redhat.com/pub/redhat/redhat-5.1/sparc/RedHat/RPMS/bzip2-0.1pl2-1.sparc.rpm}{³oùØ}¡C



 Slackwareªº Intel ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://www.cdrom.com/pub/linux/slackware-3.5/slakware/a1/bzip2.tgz}{³oùØ}¡C



 S.u.S.E.ªº Intel ¤G¶i¦ìµ{¦¡½X¦b \nameurl{ftp://ftp.suse.com/pub/SuSE-Linux/5.2/suse/ap1/bzip.rpm}{³oùØ}¡C

§A¤]¥i¥H±q³\¦h¬ÛÃþ¦üªº¬M®g¯¸±o¨ú±oÀÉ®×¡C




\subsection{¨ú±o bzip2 ­ì©lµ{¦¡}

§A¥i¥H±q©x¤èªººô¯¸ (¬Ý \ref{get-bzip2} {(Getting Bzip2)}
¡A©Î¬O Red Hat ¤]¦³ \nameurl{ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm}{¥¦})¡C




\subsection{½sÄ¶ bzip2 µ¹§Aªº¾÷¾¹¨Ï¥Î}

{\bfseries ¦pªG§A¦³ gcc 2.7.*}¡A±N¤U­±³o¦æ
\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}


 ¤]´N¬O¡A§â -O2 §ï¦¨ -O3 ¨Ã§â -funroll-loops§R±¼¡C§A¤]¥i¥H¥[¤J¥ô¦ó§A¦b½sÄ¶ kernel ®Éªº -m* ºX¼Ð
(¨Ò¦p¹³ -m486)¡C

  Á×§K¨Ï¥Î -funroll-loops ¬O³Ì­«­nªº¤F¡A¦]¬°¥¦·|³y¦¨³\¦hªº
gcc 2.7²£¥Í¿ù»~ªºµ{¦¡½X¡A¥H¤Î¥þ³¡ªº gcc 2.7 ²£¥Í³t«×ºC¤S¸û­Dªºµ{¦¡½X¡C
¹ï¨ä¥Lªº½sÄ¶¾¹ (lcc, egcs, gcc 2.8.x) ¨Ï¥Î¤º©wªº CFLAGS ´N¨S°ÝÃD¡C

¤§«á¡A¥u»Ý {\ttfamily make} ¥¦¡AµM«á¨Ì·Ó README ¨Ó¦w¸Ë¥¦¡C




\section{¨Ï¥Î bzip2}

½Ð°Ñ¾\«Ü´Îªº¤â¥U :)




\section{°t¦X tar¨Ó¨Ï¥Î bzip2\label{bzip2-with-tar}}

¤U­±¦³¤TºØ°t¦X tar ¨Ï¥Î bzip2 ªº¤èªk¡A¤]´N¬O


\subsection{®e©ö³]¥ß:}

³o­Ó¤èªk¸ò¥»´N¤£¥²°µ³]©w¡C°õ¦æ¸Ñ¶}bzip2'd ªº tar¥]»q¡A
¦b²{¦æ¥Ø¿ý©³¤U¦³­Ó foo.tar.bz2¡A°õ¦æ
\begin{tscreen}
\begin{verbatim}
/path/to/bzip2 -cd foo.tar.bz2 | tar xf -
\end{verbatim}
\end{tscreen}


¦¨¥\¤F¡A¦ý¥i¯à¦³±`»Ý¿é¤Jªº¤p¯ÊÂI¡C




\subsection{®e©ö³]¥ß¡A®e©ö¨Ï¥Î¡A¤£»Ý­n root ªº¯SÅv:}

 ·PÁÂ \nameurl{mailto:leonard@sct1.is.belgacom.be}{Leonard Jean-Marc} °^Äm³o­Ó¤p§Þ¥©¡C¤]ÁÂÁÂ \nameurl{mailto:rubini@morgana.systemy.it}{Alessandro Rubini} ±q cshùØ¤ÀÃþ
¥X bash ªº¡C



¦b§Aªº .bashrcùØ¡A§A¥i¥H¥[¤J¹³¤U­±³o¦æ:
\begin{tscreen}
\begin{verbatim}
alias btar='tar --use-compress-program /usr/local/bin/bzip2 '
\end{verbatim}
\end{tscreen}




¦b§Aªº .tcshrc ©Î .cshrcùØ¡A¥i¥Î¤U­±³o¦æ¬Û¦Pªº:
\begin{tscreen}
\begin{verbatim}
alias btar 'tar --use-compress-program /usr/local/bin/bzip2'
\end{verbatim}
\end{tscreen}





\subsection{¦P¼Ë¬O®e©ö¨Ï¥Î¡A¦ý»Ý­n root ¨Ó¦s¨ú¡C}

¥Î¤U­±¨Ó¤èªk¨Ó­×¸É gnu tar 1.12¡G
\begin{tscreen}
\begin{verbatim}
cd tar-1.12/src; patch < /path/to/tar.diff
\end{verbatim}
\end{tscreen}

½sÄ¶¡B¦w¸Ë¥¦¡A§A¤w·Ç³Æ´Nºü¤F¡C¥Î"which tar" ©M "which bzip2"¨Ó½T»{³o¨â­Ó
tar ©M bzip2 ¦³¦b§Aªº \$PATH ùØ¡C­n¨Ï¥Î·sªº tar¡A¥u»Ý
\begin{tscreen}
\begin{verbatim}
 tar xyf foo.tar.bz2
\end{verbatim}
\end{tscreen}

¨ÓÀ£ÁYÀÉ®×¡C

­n»s§@·sªºÀ£ÁYÀÉ¡A¦P¼Ë¦a:
\begin{tscreen}
\begin{verbatim}
 tar cyf foo.tar.bz2 ÀÉ¦W1 ÀÉ¦W2 ÀÉ¦W3...¥Ø¿ý1 ¥Ø¿ý2...
\end{verbatim}
\end{tscreen}


¤U­±¬O­×¸Éªº¦a¤è:
\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 ¨Ó°t¦X less}

°¨¤W¸ÑÀ£ÁY bzip2 ÀÉ¡A¨Ò¦p¡A¦b¤£¥²¥ý bunzip2 ÀÉ®×ªº«e´£¤U§Y¥i¥Î "less"
¨ì¥¦­Ì¨­¤W¡A§A¥i¥H°µ­Ó lesspipe.sh (man less)¡A¹³¤U­±¡G
\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 ¨Óµ²¦X emacs}


\subsection{¬°¨C­Ó¤H§ïÅÜ emacs:}

§Ú¼g¤F¤U­±ªºµ¹ jka-compr.el ¥Îªº­×¸É¡A¥¦·|¥[¤J bzip2 ¦¨¬°¦Û°ÊÀ£ÁY¼Ò¦¡¡C

{\bfseries °£¥~±ø´Ú:} §Ú¥u¦b emacs-20.2¤W¸Õ¹L³o­Ó¡A¦ý¬O§Ú¤]§ä¤£¨ì¦³
Ô£»ò²z¥Ñ¨Ó¬Û«H¦P¼Ëªº¤èªk«o¤£¯à¦b¨ä¥Lª©¥»¤W¨Ï¥Îªº¡C

¨Ï¥Î¥¦¡A
\begin{enumerate}
\item ¨ì emacs-20.2/lisp ­ì©lµ{¦¡½X¥Ø¿ýùØ (¬Ý§A¦b­þ¨à untarred ¥¦ªº)
\item §â¤U­±ªº­×¸É°µ¦¨¥s jka-compr.el.diff ªºÀÉ®×(¥þ©ñ¦b³oÀÉ®×ùØ
)¡C
\item µM«á°õ¦æ
\begin{tscreen}
\begin{verbatim}
 patch < jka-compr.el.diff
\end{verbatim}
\end{tscreen}
\item ±Ò°Ê emacs¡A¦A°õ¦æ
\begin{tscreen}
\begin{verbatim}
 M-x byte-compile-file jka-compr.el
\end{verbatim}
\end{tscreen}
\item Â÷¶} emacs¡C
\item §â¥¦­ì¨Óªº jka-compr.elc ©ñ¨ì¦w¥þªº¦a¤è¥H¨¾¦³¯ä¦ä®É³Æ¥Î¡C
\item ¥Î·sªº jka-compr.elc¨Ó¥N´À¥¦¡C
\item ¦n¦nª±§a!
\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{¬°¬Y¤H§ïÅÜ emacs:}

³o¦¸­nÁÂÁÂ Ulrik Dickow, \nameurl{mailto:ukdATkampsax.dk}{ukd@kampsax.dk}¡A¥L¬OKampsax Technologyªº¨t²Îµ{¦¡³]­p®v :

¬°¤FÅý«D sysadmin ªºªB¤Í¥i¥H¦Û°Ê¦a¨Ï¥Î bzip2¡A¥u»Ý¦b§Aªº
.emacs ÀÉ®×ùØ¥[¤W¤U¦CªFªF¡C

\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 ¨Ó°t¦X wu-ftpd}

·PÁÂ Arnaud Launay ³o«h¸`¬ÙÀW¼eªº¯µ³Z¡C¤U­±ªº¤º®eÀ³¸Ó¬O©ñ¨ì
/etc/ftpconversions ùØ­±¨Ó¹F¦¨¥H bzip2 ¨Ó°µ§Y®ÉÀ£ÁY¤Î¸ÑÀ£ÁY
¡C½Ð½T»{¸ô®| (¹³ /bin/compress) ­n¥¿½T¡C

\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 ¨Ó°t¦X grep}

¤U­±ªº¤½¥Îµ{¦¡¡A§ÚºÞ¥¦¥s bgrep¡A¨Æ¹ê¤W¬O§â¦ñÀH¦b Linux ªº zgrep °µ­Ó¤p§ó§ï
¦Ó¤w¡C§A¥i¥H¨Ï¥Î¥¦¨Ó grep¡A¦Ó¤£»Ý¥ý bunzip2 ÀÉ®×¡C

\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 °t¦X X ¤Uªº Netscape ¨Ó¨Ï¥Î¡C}

tenthumbs@cybernex.net »¡:

\begin{tscreen}
§Ú§ä¨ì¤@­Ó¥i¥HÅý Linux Netscape ¨Ó¨Ï¥Î bzip2 °µ¬° Content-Encoding
´N¦p¦P¥¦¨Ï¥Î gzip ¤@¼Ë¡C§â¤U­±ªºªFªF¥[¨ì \$HOME/.Xdefaults ©Î¬O
\$HOME/.Xresources
§Ú¨Ï¥Î -s ¿ï¶µ¡A¬O¦]¬°¿ï¾Ü©ñ±ó¸ÑÀ£ÁYªº³t«×¨Ó´«±o RAM ªº¦û¥Î¡C
§A¥i¥H§â¥¦³]¦¨§A¦Û¤v­nªº¡C

\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 ¨Ó¦AÀ£ÁY¨ä¥LªºÀ£ÁY®æ¦¡}

¤U­±ªº perl µ{¦¡·|§â¥H¤U¦CªºÀ£ÁY®æ¦¡ÀÉ (.tar.gz, .tgz. .tar.Z, ©M .Z for this iteration)
­«·s¥´¥]¦¨³Ì¨ÎªºÀ£ÁY­È¡C³o perl ­ì©lµ{¦¡³£¦³¥þ¤è¦ìªº¦n¤å¥ó
¨Ó»¡©ú¥¦°µ¤°»ò¥H¤Î¥¦¦p¦ó¿ì¨ìªº¡C
\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{¤¤Ä¶¥»}

Ä¶ªÌµù: ­Y±zµo²{¥»¤å¥ó¤º®e¦³Â½Ä¶¤£¶¶ºZ©Î¿ù»~ªº¦a¤è¡A½Ð±z¨Ó«H§i¶D§Ú¡A¥H°µ§ó¥¿¡AÁÂÁÂ¡C
Ä¶ªÌ¹q¤l¶l¥ó {\ttfamily \onlynameurl{linuxer.bbs@cis.nctu.edu.tw}}
©Î\onlynameurl{linux4tw@geocities.com}

Ä¶µù¡G³o¥÷ HOWTO ¤å¥óªº¤¤¤åª©¥i¦b¥xÆW Linux ¨Ï¥ÎªÌ²ÕÂ´¤Uªº¤¤¤å Linux
¤å¥ó­pµe\nameurl{http://www.linux.org.tw/CLDP/}{}\\ 
©Î¬O"Linux for Taiwan ¥xÆW¤Hªº Linux "\onlynameurl{http://members.xoom.com/linux4tw/}
¤U¨ú±o¡C

\end{document}
