1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
|
Bzip2 Howto
David Fetter, dfetter@best.com <mailto:dfetter@best.com>
v1.6, 10 marzo 1998
Questo documento descrive come usare il nuovo programma di compres
sione bzip2. L'originale in sgml si trova presso
<http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml>.
1. Introduzione
Bzip2 un nuovo algoritmo per la compressione dei dati. Generalmente
crea file che sono il 60-70% della dimensione dei corrispondenti
ottenuti usando gzip.
Per mezzo di questo documento potrai utilizzare alcune applicazioni
comuni con bzip2.
Per traduzione in francese puoi far riferimeno a documento di Arnaud
Launay. Una versione web si trova qui
<http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html>, oppure puoi usare
ftp qui <ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz>
Arnaud pu essere contattato via posta elettronica a questo indirizzo
<mailto:zoro@mygale.org>
Per traduzione in giapponese puoi far riferimento qui
<http://jf.gee.kyoto-u.ac.jp/JF/JF.html> ai documenti di Tetsu Isaji.
Isaji pu essere contattato tramite la sua home page
<http://www2s.biglobe.ne.jp/~kaien/>, oppure via posta elettronica a
questo indirizzo. <mailto:isaji@mxu.meshnet.or.jp>
1.1. Storia delle revisioni
1.1.1. v1.6 Aggiunto il Netscape enabler di TenThumbs.
Modificato anche lesspipe.sh secondo i sui suggerimenti. Adesso
dovrebbe funzionare meglio.
1.1.2. v1.5 Aggiunta la traduzione francese di Arnaud Launay, e il
suo wu-ftpd file.
1.1.3. v1.4 Aggiunta la traduzione giapponese di Tetsu Isaji.
1.1.4. v1.3 Aggiunto .emacs di Ulrik Dickow per 19.30 e superiori.
(Su suo consiglio, corretta anche la patch jka-compr.el per emacs.
Oops! Bzip2 non ha ancora(?) un'opzione "append".)
1.1.5. v1.2 Modificata la patch per emacs cos riconosce automatica
mente i file .bz2.
1.1.6. v1.1 Aggiunta patch per emacs.
1.1.7. v1.0 Prima Versione.
2. Come ottenere bzip2
L'home page di Bzip2 si trova presso l'home site UK
<http://www.muraroa.demon.co.uk/>. Il sito mirror negli STATI UNITI
qui <http://www.digistar.com/bzip2/index.html>. Puoi anche trovarlo
sul sito della Red Hat qui <ftp://ftp.redhat.com/pub/contrib>.
2.1. Ottenere bzip2 precompilato
Vedi gli home site. I binari per Intel della Red Hat si trovano qui
<ftp://ftp.redhat.com/pub/contrib/i386/bzip2-0.1pl2-1.i386.rpm>. Per
la Debian sono qui <ftp://ftp.debian.org/debian/hamm/hamm/binary-
i386/utils/bzip2_0.1pl2-4.deb>, e qui
<http://www.cdrom.com/pub/linux/slackware-3.4/slakware/a9/bzip2.tgz>
per la Slackware. Puoi prenderlo negli analogi posti presso i vari
siti mirror.
2.2. Ottenere i sorgenti di bzip2
Sono reperibili dal sito ufficiale (vedi ``Ottenere Bzip2''), oppure
qui <ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm>
presso Red Hat.
2.3. Compilare bzip2 per la tua macchina
Se hai gcc 2.7.2.3, cambia la linea
CFLAGS = -O3 -fomit-frame-pointer -funroll-loops
in
CFLAGS = -fomit-frame-pointer -funroll-loops
ovvero, togli la parte -O3. Dopo di che semplicemente lancia make e
installalo come spiegato nel README.
3. Usare bzip2 da solo
Leggi la raffinata pagina del manuale :)
4. Usare bzip2 con tar
Di base, ci sono due modi di usarlo, chiamiamoli
4.1. Facile impostazione:
questo metodo non richiede un setup generale. Per un-tarare un archivo
tar bzip2, foo.tar.bz2, nella corrente directory, fai
/percorso/per/bzip2 -cd foo.tar.bz2 | tar xf -
Questo metodo funziona, ma pu essere un po' noioso da scrivere
spesso.
4.2. Facile da usare:
Applica la seguente patch a gnu tar 1.12, compilalo, ed installalo, e
sei pronto per partire. Assicurati che tar and bzip2 si trovino nel
tuo $PATH con "which tar" e "which bzip2". Per usarlo, semplicemente
usa
tar xyf foo.tar.bz2
per decomprimere un file.
Per creare un nuovo archivio, analogamnte:
tar cyf foo.tar.bz2 file1 file2 file3...directory1 directory2...
E questa la patch :)
*** tar.c.orig Sat Apr 26 05:09:49 1997
--- tar.c Feb 2 00:50:47 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,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)
--- 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)
***************
*** 805,810 ****
--- 811,820 ----
case 'X':
exclude_option = 1;
add_exclude_file (optarg);
+ break;
+
+ case 'y':
+ set_use_compress_program_option ("bzip2");
break;
case 'z':
5. Usare bzip2 con less
Per decomprimere i file bzip2 al volo, ad esempio usare "less" senza
prima bunziparli, tu puoi fare un lesspipe.sh (man less) simile a
questo:
#!/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
6. Usare bzip2 con emacs
6.1. Cambiare emacs per tutti:
Ho scritto la seguente patch per jka-compr.el la quale aggiunge bzip2
ad auto-compression-mode.
Disclaimer: Io l'ho solo testato con emacs-20.2, ma non c' nessuna
ragione per credere che un simile approccio non funzioni con altre
versioni.
Come usarlo
1. Vai nella directory dei sorgenti emacs-20.2/lisp (oppure dove li
hai un-tarati)
2. Metti la seguente patch in un file chiamato jka-compr.el.diff (deve
essere l'unico file ;).
3. Fai
patch < jka-compr.el.diff
4. Avvia emacs, e fai
M-x byte-compile-file jka-compr.el
5. Esci da emacs.
6. Metti il tuo jka-compr.elc originale in un posto sicuro in caso di
bachi.
7. Sostituisci il nuovo jka-compr.elc.
8. Hai fatto!
--- 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")
6.2. Modificare emacs per un solo utente:
Un ringraziamento per questa cosa va a Ulrik Dickow, ukd@kampsax.dk
<mailto:ukd@kampsax.dk>, Programmatore di Sistema presso Kampsax
Technology:
Per fare in modo di usare bzip2 autmaticamente, senza essere un
sysadmin, aggiungi ci che segue nel tuo file .emacs.
;; 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)
7. Usare bzip2 con wu-ftpd
Ringrazio Arnaud Launay per questo salva banda. Ci che segue va in
/etc/ftpconversions per comprimere e decomprimere con bzip2 al volo.
Assicurati che i percorsi (simile a /bin/compress) siano giusti.
:.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 -I -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+BZIP2
8. Usare bzip2 con Netscape sotto XWindows
tenthumbs@cybernex.net dice:
Ho trovato un modo di far usare bzip2 al Netscape per Linux per Con
tent-Encoding nello stesso modo con cui usa gzip. Aggiungi quanto
segue a $HOME/.Xdefaults oppure $HOME/.Xresources
Io uso l opzione -s poich preferisco sacrificare un po' di velocit
di decompressione piuttosto che l'utilizzo di memoria RAM. Puoi
togliere questa opzione se non ne hai bisogno.
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
9. Usare bzip2 con xv
Sto lavorando ad una patch, in modo tale che xv autodecomprima i file
bzip2 nello stesso modo con cui pu decomprimere quelli di gzip.
Nessuno vuole aiutarmi?
|