Bzip2 Howto
David Fetter,
[email protected] <mailto:
[email protected]>
v1.1, 5 February 1998
�ɍ��� �N,
[email protected]
Wed Feb 25 22:36:00 1998
���̃h�L�������g��bzip2���k�v���O�����̎g�����ɂ��ĉ���Ă��܂��B
______________________________________________________________________
�ڎ�
1. �C���g���_�N�V����
2. bzip2�̓���
2.1 �v���R���p�C�����ꂽbzip2�o�C�i����肷��
2.2 bzip2�\�[�X�̓���
2.3 �}�V���p��bzip2��R���p�C������
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. (��Ғlj��F)fd,ls��bzip2��g��
8.1 fd
8.2 ls
______________________________________________________________________
1. �C���g���_�N�V����
Bzip2�̓f�[�^��k����"������"�V�����A���S���Y���ł��B gzip�ň��k����
�T�C�Y��60-70%�Ƀt�@�C����k���܂��B
���̃h�L�������g�ł�bzip2�ƕ��p���Ďg����2,3�̋��ʂ����A�v���P�[�V����
��ʂ��Ęb����i�߂Ă����܂��B
2. bzip2�̓���
Bzip2�̃z�[���y�[�W��The UK home site�ł��BUnited States�~���[�T�C�g��
�����ł��B Red Hat��ftp�T�C�g�ł�����܂��B
2.1. �v���R���p�C�����ꂽbzip2�o�C�i����肷��
UK home site��Q�Ƃ��ĉ������BRed Hat�̃C���e���o�C�i���͂�����
���BDebian, Slackware�Ȃǂ͂܂�Ȃ��o�Ă��܂��B
2.2. bzip2�\�[�X�̓���
�����T�C�g����o�Ă��܂�(``Bzip2�̓���''�̏͂�Q�Ƃ��ĉ�����)�BRed
Hat�̂�̂͂����ɂ���܂��B
(�Fbzip2 �z�[���y�[�W�A
http://www.muraroa.demon.co.uk/)
2.3. �}�V���p��bzip2��R���p�C������
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�ŏ�����Ă���悤�ɃC���X�g�[�����܂��B
3. �P�Ƃ�bzip2��g��
�}�j���A���y�[�W��ǂ�ʼn����� :)�B
4. bzip2��tar�Ǝg��
��{�I�ɂQ�̕��@������܂��F
4.1. �ݒ肵�Ȃ��Ă悢�F
���̕��@�Ȃ牽��ݒ肵�Ȃ��Ă��݂܂��Bbzip2����tar�A�[�J�C
�ufoo.tar.bz2�� un-tar����ɂ̓J�����g�f�B���N�g���ŁA
/path/to/bzip2 -cd foo.tar.bz2 | tar xf -
�Ƃ��܂��B����œ��삵�܂����A�����������͂���͖̂ʓ|(PITA)�ł��B
4.2. �g���₷��:
�ȉ��̃p�b�`��GNU tar 1.12�ĂăR���p�C��/�C���X�g�[�����ĉ������B
����ł悢�ł��Btar��bzip2��("which tar"�A"which bzip2"�Ǝ��s����)
$PATH�ɂ��邩�ǂ����m�F���Ă����܂��B�t�@�C����W�J����ɂ�
tar xyf foo.tar.bz2
�Ƃ��܂��B
�V�����A�[�J�C�u���鎞�����悤�ɂ���
tar cyf foo.tar.bz2 file1 file2 file3...directory1 directory2...
�Ƃ��܂��B
�ȉ��̓p�b�`�ł� :) (�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��
bzip2�t�@�C������ɓW�J���邽�߂ɁA�Ⴆ�͂��߂�bunzip2��g�킸
"less"��g�����߂ɁA"lesspipe.sh"����܂�(less��man�y�[�W�Q��)�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�ɓ��Ă�ȉ��̃p�b�`����܂����B
auto-compression-mode��bzip2��lj������̂ł��B
�Ɛӎ����Femacs-20.2�Ńe�X�g���������ł����A���̃o�[�W�����œ��삵�Ȃ�
�Ƃ������Ƃ͂Ȃ��Ǝv���܂�
1. emacs-20.2/lisp�\�[�X�f�B���N�g���Ɉړ����܂�(untar�����ꏊ���ǂ���
����)�B
2. ���L��jka-compr.el.diff�p�b�`�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. �o�O���������Ƃ��̂��߂ɃI���W�i����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��bzip2�t�@�C���̎����W�J(auto-decompress)���p�b�`��g���ē��삳
���Ă��܂��Bcompress��gzip�ōs�����@�ɂ��Ă��ꂩ�����Ă���܂���
���H
8. (��Ғlj��F)fd,ls��bzip2��g��
8.1. fd
fd�ł��łɐݒ肳��Ă���gzip'd tar�A�[�J�C�u�Ɠ����ł��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�\�[�X�W�J�f�B���N�g����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
______________________________________________________________________
�ƒlj����邾���ł�(# 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"
______________________________________________________________________
��lj����Ă����܂��Bgzip�Ɠ����Ȃ̂�gzip���̐ݒ肪�A���O��ς��邾����
���̂܂g���܂��B�ȒP�ł��ˁB
``less�Ǝg��''��lesspipe.sh �t�@�C����
______________________________________________________________________
*.tar.bz2) tar tyvvf $1 2>/dev/null ;;
______________________________________________________________________
��lj����܂��Btar��gzip�p��z�I�v�V����������̂Ɠ����悤��bzip2�p�I�v
�V����y��tar�ɒlj����Ă����ĉ����� (``bzip2��tar�Ǝg��''��)�B
8.2. ls
xterm(kterm)�ł̃A�[�J�C�u�t�@�C���F�ɒlj����邱�Ƃɂ��Ă� JF����a
���o�Ă���uColour-ls�v"3. ls �̃J���[�ݒ�@"��Q�l�ɂ��ĉ������B
�Ⴆ�A/etc/DIR_COLORS�t�@�C����ȉ��̂悤�ɕύX���܂� (�ꕔ���p)�B
______________________________________________________________________
.Z 01;31
.gz 01;31
.bz2 01;31 <--- ����
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
______________________________________________________________________