upstream tarballs.
pristine-tar supports compressed tarballs, calling out to pristine-gz(1)
-to produce the pristine gzip files.
+and pristine-bz2(1) to produce the pristine gzip and bzip2 files.
=head1 COMMANDS
=head1 LIMITATIONS
-Only .tar, .tar.gz, and .tar.bz2 files are currently supported; .tar.bz2
-support is experimental, see pristine-bz2(1).
+Only .tar, .tar.gz, and .tar.bz2 files are currently supported.
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
}
recreatetarball($tempdir, getcwd, clobber_source => 0, %opts);
- my $out=(-e "$tempdir/wrapper" || -e "$tempdir/wrapper-bz2") ? $tarball.".tmp" : $tarball;
+ my $out=(-e "$tempdir/wrapper") ? $tarball.".tmp" : $tarball;
doit("xdelta", "patch", "$tempdir/delta", "$tempdir/recreatetarball", $out);
if (-e "$tempdir/wrapper") {
- doit("pristine-gz",
- ($verbose ? "-v" : "--no-verbose"),
- ($debug ? "-d" : "--no-debug"),
- ($keep ? "-k" : "--no-keep"),
- "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);
+ my $type=`tar xOzf $tempdir/wrapper`;
+ chomp $type;
+ if ($type eq 'gz') {
+ doit("pristine-gz",
+ ($verbose ? "-v" : "--no-verbose"),
+ ($debug ? "-d" : "--no-debug"),
+ ($keep ? "-k" : "--no-keep"),
+ "gengz", "$tempdir/wrapper", $out);
+ doit("mv", "-f", $out.".gz", $tarball);
+ }
+ elsif ($type eq 'bz2') {
+ doit("pristine-bz2",
+ ($verbose ? "-v" : "--no-verbose"),
+ ($debug ? "-d" : "--no-debug"),
+ ($keep ? "-k" : "--no-keep"),
+ "genbz2", "$tempdir/wrapper", $out);
+ doit("mv", "-f", $out.".bz2", $tarball);
+ }
+ else {
+ error "unknown wrapper file type: $type";
+ }
}
}
my @files=qw(delta manifest version type);
- # Check to see if it's gzip-compressed.
+ # Check to see if it's compressed.
+ my $compression=undef;
open (IN, "<", $tarball) || error "Cannot read $tarball: $!\n";
my ($chars, $id1, $id2, $method);
if (read(IN, $chars, 10) == 10 &&
(($id1, $id2, $method) = unpack("CCC", $chars)) &&
$id1 == GZIP_ID1 && $id2 == GZIP_ID2 &&
$method == GZIP_METHOD_DEFLATE) {
- doit("pristine-gz",
- ($verbose ? "-v" : "--no-verbose"),
- ($debug ? "-d" : "--no-debug"),
- ($keep ? "-k" : "--no-keep"),
- "gendelta", $tarball, "$tempdir/wrapper");
- push @files, "wrapper";
+ $compression='gz';
doit("zcat $tarball > $tempdir/origtarball");
- $tarball="$tempdir/origtarball";
+ }
+ else {
+ seek(IN, 0, 0) || die "seek: $!";
+ if (read(IN, $chars, 3) == 3 &&
+ (($id1, $id2, $method) = unpack("CCC", $chars)) &&
+ $id1 == BZIP2_ID1 && $id2 == BZIP2_ID2 &&
+ $method == BZIP2_METHOD_HUFFMAN) {
+ $compression='bz2';
+ $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",
+
+ # Generate a wrapper file to recreate the compressed file.
+ if (defined $compression) {
+ doit("pristine-$compression",
($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");
+ "gendelta", $tarball, "$tempdir/wrapper");
+ push @files, "wrapper";
$tarball="$tempdir/origtarball";
}
- close IN;
my $sourcedir="$tempdir/tmp";
doit("mkdir", $sourcedir);