Bzip2 Howto David Fetter, dfetter@best.com <mailto:dfetter@best.com> v1.1, 5 February 1998 ɲ¡ N, isaji@mxu.meshnet.or.jp Wed Feb 25 22:36:00 1998 ±ÌhL gÍbzip2³kvOÌg¢ûÉ¢ÄðàµÄ¢Ü·B ______________________________________________________________________ Ú 1. Cg_NV 2. bzip2Ìüè 2.1 vRpC³ê½bzip2oCiðüè·é 2.2 bzip2\[XÌüè 2.3 }VpÌbzip2ðRpC·é 3. PÆÅbzip2ðg¤ 4. bzip2ðtarÆg¤ 4.1 ÝèµÈÄæ¢F 4.2 g¢â·¢: 5. lessÅbzip2ðg¤ 6. emacsÅbzip2ðg¤ 7. xvÅbzip2ðg¤ 8. (óÒÇÁF)fd,lsÅbzip2ðg¤ 8.1 fd 8.2 ls ______________________________________________________________________ 1. Cg_NV Bzip2Íf[^ð³k·é"¢©·"Vµ¢ASYÅ·B gzipųkµ½ TCYÌ60-70%Ét@Cð³kµÜ·B ±ÌhL gÅÍbzip2ƹpµÄg¦é2,3̤ʵ½AvP[V ðʵÄbµðißÄ¢«Ü·B 2. bzip2Ìüè Bzip2Ìz[y[WÍThe UK home siteÅ·BUnited States~[TCgÍ ±±Å·B Red HatÌftpTCgÅà©Â©èÜ·B 2.1. vRpC³ê½bzip2oCiðüè·é UK home siteðQƵĺ³¢BRed HatÌCeoCiͱ±Å ·BDebian, SlackwareÈÇÍÜàÈoÄ«Ü·B 2.2. bzip2\[XÌüè ö®TCg©çoĢܷ(``Bzip2Ìüè''ÌÍðQƵĺ³¢)BRed HatÌàÌͱ±É èÜ·B (óFbzip2 z[y[WAhttp://www.muraroa.demon.co.uk/) 2.3. }VpÌbzip2ðRpC·é gcc 2.7.2.3ðÁÄ¢éÈç CFLAGS = -O3 -fomit-frame-pointer -funroll-loops ±ÌsÅ-O3ðOµÄ CFLAGS = -fomit-frame-pointer -funroll-loops ÉÏXµÄ¨¢Äº³¢B ±Ì ÆmakeµÄREADMEÅ©êÄ¢éæ¤ÉCXg[µÜ·B 3. PÆÅbzip2ðg¤ }j Ay[WðÇñź³¢ :)B 4. bzip2ðtarÆg¤ î{IÉQÂÌû@ª èÜ·F 4.1. ÝèµÈÄæ¢F ±Ìû@Èç½àÝèµÈÄ·ÝÜ·Bbzip2µ½tarA[JC ufoo.tar.bz2ð un-tar·éÉÍJgfBNgÅA /path/to/bzip2 -cd foo.tar.bz2 | tar xf - ƵܷB±êÅ®ìµÜ·ªA¢¿¢¿üÍ·éÌÍÊ|(PITA)Å·B 4.2. g¢â·¢: ȺÌpb`ðGNU tar 1.12ðÄÄRpC/CXg[µÄº³¢B ±êÅæ¢Å·BtarÆbzip2ª("which tar"A"which bzip2"ÆÀsµÄ) $PATHÉ é©Ç¤©mFµÄ¨«Ü·Bt@CðWJ·éÉÍ tar xyf foo.tar.bz2 ƵܷB Vµ¢A[JCuðìé௶æ¤ÉµÄ tar cyf foo.tar.bz2 file1 file2 file3...directory1 directory2... ƵܷB ȺÍpb`Å· :) (óFpatch -p1 < tar.c.diffÆµÄ Äĺ³¢) ______________________________________________________________________ *** tar.c.orig Sat Feb 28 14:55:45 1998 --- tar.c Sat Feb 28 15:01:54 1998 *************** *** 16,21 **** --- 16,24 ---- with this program; if not, write to the Free Software Foundation, Inc., 59 Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* Feb 2 98: patched by David Fetter to use bzip2 as a + filter (option -y) */ + #include "system.h" #include <getopt.h> *************** *** 196,201 **** --- 199,206 ---- {"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 **** --- 377,383 ---- 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,455 **** 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) { --- 454,460 ---- 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) { *************** *** 806,811 **** --- 811,820 ---- exclude_option = 1; add_exclude_file (optarg); break; + + case 'y': + set_use_compress_program_option ("bzip2"); + break; case 'z': set_use_compress_program_option ("gzip"); ______________________________________________________________________ 5. lessÅbzip2ðg¤ bzip2t@Cð·®ÉWJ·é½ßÉAá¦ÎͶßÉbunzip2ðgí¸ "less"ðg¤½ßÉA"lesspipe.sh"ðìèÜ·(lessÌmany[WQÆ)F ______________________________________________________________________ #!/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 .tar and .tgz files *.tgz) tar tzvvf $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 ______________________________________________________________________ (óF«ÏLESSOPENðÝèµÄ¨«Ü·) 6. emacsÅbzip2ðg¤ ÒÍjka-compr.elÉÄéȺÌpb`ð«Üµ½B auto-compression-modeÉbzip2ðÇÁ·éàÌÅ·B ÆÓFemacs-20.2ÅeXgµ½¾¯Å·ªA¼Ìo[WÅ®ìµÈ¢ Æ¢¤±ÆÍÈ¢Æv¢Ü· 1. emacs-20.2/lisp\[XfBNgÉÚ®µÜ·(untarµ½êªÇ±Å ê)B 2. ºLÌjka-compr.el.diffpb`t@Cðu«Ü·(»êƯ¶¼OÌ t@CÍ èܹñ ;)B 3. patch < jka-compr.el.diff ÆÀsµÜ·B 4. emacsð§¿ã°Ä M-x byte-compile-file jka-compr.el ƵܷB 5. emascðI¹µÜ·B 6. oOª Á½Æ«Ì½ßÉIWiÌjka-compr.elcðÀSÈêÉÚ® µÄ¨«Ü·B 7. Vµ¢jka-compr.elcÆu«·¦Ü·B 8. Have fun! ______________________________________________________________________ --- 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 nil] ["\\.tgz\\'" "zipping" "gzip" ("-c" "-q") "unzipping" "gzip" ("-c" "-q" "-d") ______________________________________________________________________ 7. xvÅbzip2ðg¤ xvÅbzip2t@CÌ©®WJ(auto-decompress)ð·épb`ðgÁÄ®ì³ ¹Ä¢Ü·BcompressâgzipÅs¦éû@É¢ľꩯÄêܹñ ©H 8. (óÒÇÁF)fd,lsÅbzip2ðg¤ 8.1. fd fdÅ·ÅÉÝè³êÄ¢égzip'd tarA[JCuƯ¶Å·B\[XðÏX· éêÍ ______________________________________________________________________ --- orig/archive.c Thu Feb 26 06:33:27 1998 +++ archive.c Thu Feb 26 04:19:35 1998 @@ -117,6 +117,7 @@ {" ^.*\\.tar$", "tar tvf", PM_TAR}, {" ^.*\\.tar\\.Z$", "zcat %C | tar tvf -", PM_TAR}, {" ^.*\\.tar\\.gz$", "gzip -cd %C | tar tvf -", PM_TAR}, + {" ^.*\\.tar\\.bz2$", "bzip2 -cd %C | tar tvf -", PM_TAR}, {NULL, NULL, 255, 0, "", "", "", "", 1} }; archivetable archivelist[MAXARCHIVETABLE] = { @@ -130,8 +131,6 @@ "zcat %C | tar xf - %TA"}, {" ^.*\\.tar\\.gz$", "tar cf %X %T; gzip %X", "gzip -cd %C | tar xf - %TA"}, - {" ^.*\\.tar\\.bz2$", "tar cf %X %T; bzip2 %X", - "bzip2 -cd %C | tar xf - %TA"}, {NULL, NULL, NULL} }; ______________________________________________________________________ ðfd\[XWJfBNgÅpatch -p1 < archive.diffÆ ÄÄ ( é¢Í èżÚÏXµÄ)AmakeµÜ·B ܽ~/.fdrcÅÝè·éêÍA# launcher definitionÅ ______________________________________________________________________ launch ".tar.bz2"\ "tar tvfy" 0,0:1,2-'/',2'/',3,4-'-',4'-'-'-',4[9],5,6 ______________________________________________________________________ ÆÇÁ·é¾¯Å·(# examples for GNU tar >=1.12)B¯lÉ# archiver definitionÉ ______________________________________________________________________ arch ".tar.bz2" "tar cf %X %T; bzip2 %X" "bzip2 -cd %C|tar xf - %TA" ______________________________________________________________________ àÇÁµÄ¨«Ü·BgzipƯ¶ÈÌÅgzipÌÝèªA¼OðϦ龯Š»ÌÜÜg¦Ü·BÈPÅ·ËB ``lessÆg¤''Ílesspipe.sh t@CÉ ______________________________________________________________________ *.tar.bz2) tar tyvvf $1 2>/dev/null ;; ______________________________________________________________________ àÇÁµÜ·BtarÅgzippÌzIvVª éÌƯ¶æ¤Ébzip2pIv VyðtarÉÇÁµÄ¨¢Äº³¢ (``bzip2ðtarÆg¤''Í)B 8.2. ls xterm(kterm)ÅÌA[JCut@CFÉÇÁ·é±ÆÉ¢ÄÍ JF©ça óàoÄ¢éuColour-lsv"3. ls ÌJ[Ýè@"ðQlɵĺ³¢B á¦ÎA/etc/DIR_COLORSt@CðȺÌæ¤ÉÏXµÜ· (êøp)B ______________________________________________________________________ .Z 01;31 .gz 01;31 .bz2 01;31 <--- ±± .jpg 01;35 # image formats .gif 01;35 .bmp 01;35 ______________________________________________________________________