下面有三種配合 tar 使用 bzip2 的方法,也就是
這個方法跟本就不必做設定。執行解開bzip2'd 的 tar包裹, 在現行目錄底下有個 foo.tar.bz2,執行
/path/to/bzip2 -cd foo.tar.bz2 | tar xf -
成功了,但可能有常需輸入的小缺點。
感謝 Leonard Jean-Marc 貢獻這個小技巧。也謝謝 Alessandro Rubini 從 csh�堣擭� 出 bash 的。
在你的 .bashrc�堙A你可以加入像下面這行:
alias btar='tar --use-compress-program /usr/local/bin/bzip2 '
在你的 .tcshrc 或 .cshrc�堙A可用下面這行相同的:
alias btar 'tar --use-compress-program /usr/local/bin/bzip2'
用下面來方法來修補 gnu tar 1.12:
cd tar-1.12/src; patch < /path/to/tar.diff
編譯、安裝它,你已準備就緒了。用"which tar" 和 "which bzip2"來確認這兩個
tar 和 bzip2 有在你的 $PATH �堙C要使用新的 tar,只需
tar xyf foo.tar.bz2
來壓縮檔案。
要製作新的壓縮檔,同樣地:
tar cyf foo.tar.bz2 檔名1 檔名2 檔名3...目錄1 目錄2...
下面是修補的地方:
*** 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':