=head1 LIMITATIONS
-Only tar.gz files and .tar files are currently supported; there's
-currently no support for .tar.bz2.
+Only .tar, .tar.gz, and .tar.bz2 files are currently supported; .tar.bz2
+support is experimental, see pristine-bz2(1).
-It could fail on certian spectacularly strange files. If it fails, it will
+It could fail on certain spectacularly strange files. If it fails, it will
fail during creation of the delta, since the delta is tested to make sure it
reproduces the pristine tarball.
# magic identification
use constant GZIP_ID1 => 0x1F;
use constant GZIP_ID2 => 0x8B;
+use constant BZIP2_ID1 => 0x42;
+use constant BZIP2_ID2 => 0x5a;
# compression methods, 0x00-0x07 are reserved
use constant GZIP_METHOD_DEFLATE => 0x08;
+# compression methods, 'h' for Bzip2 ('H'uffman coding), '0' for Bzip1 (deprecated)
+use constant BZIP2_METHOD_HUFFMAN => 0x68;
+
my $verbose=0;
my $debug=0;
my $keep=0;
}
recreatetarball($tempdir, getcwd, clobber_source => 0, %opts);
- my $out=(-e "$tempdir/wrapper") ? $tarball.".tmp" : $tarball;
+ my $out=(-e "$tempdir/wrapper" || -e "$tempdir/wrapper-bz2") ? $tarball.".tmp" : $tarball;
doit("xdelta", "patch", "$tempdir/delta", "$tempdir/recreatetarball", $out);
if (-e "$tempdir/wrapper") {
"gengz", "$tempdir/wrapper", $out);
doit("mv", "-f", $out.".gz", $tarball);
}
+
+ if (-e "$tempdir/wrapper-bz2") {
+ doit("pristine-bz2",
+ ($verbose ? "-v" : "--no-verbose"),
+ ($debug ? "-d" : "--no-debug"),
+ ($keep ? "-k" : "--no-keep"),
+ "genbz2", "$tempdir/wrapper-bz2", $out);
+ doit("mv", "-f", $out.".bz2", $tarball);
+ }
}
sub genmanifest {
my @files=qw(delta manifest version type);
- # Check to see if it's compressed.
+ # Check to see if it's gzip-compressed.
open (IN, "<", $tarball) || error "Cannot read $tarball: $!\n";
my ($chars, $id1, $id2, $method);
if (read(IN, $chars, 10) == 10 &&
$tarball="$tempdir/origtarball";
}
close IN;
-
+
+ # Check to see if it's bzip2-compressed.
+ open (IN, "<", $tarball) || error "Cannot read $tarball: $!\n";
+ if (read(IN, $chars, 3) == 3 &&
+ (($id1, $id2, $method) = unpack("CCC", $chars)) &&
+ $id1 == BZIP2_ID1 && $id2 == BZIP2_ID2 &&
+ $method == BZIP2_METHOD_HUFFMAN) {
+ doit("pristine-bz2",
+ ($verbose ? "-v" : "--no-verbose"),
+ ($debug ? "-d" : "--no-debug"),
+ ($keep ? "-k" : "--no-keep"),
+ "gendelta", $tarball, "$tempdir/wrapper-bz2");
+ push @files, "wrapper-bz2";
+ doit("bzcat $tarball > $tempdir/origtarball");
+ $tarball="$tempdir/origtarball";
+ }
+ close IN;
+
my $sourcedir="$tempdir/tmp";
doit("mkdir", $sourcedir);
doit("tar", "xf", File::Spec->rel2abs($tarball), "-C", $sourcedir);