summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiko Miyagawa <miyagawa@bulknews.net>2018-05-04 11:22:14 -0700
committerTatsuhiko Miyagawa <miyagawa@bulknews.net>2018-05-04 11:22:14 -0700
commit68d84dad3606ad201bb7216863bc25a12566f6f0 (patch)
tree9a387046480d26ba9f9974e972a278d65ff30753
parent9122643dfbbb5a919e505810eeaaae938ab8b8d0 (diff)
downloadcarton-68d84dad3606ad201bb7216863bc25a12566f6f0.tar.gz
support 5.8 without IO::Compress::Gzip
-rw-r--r--lib/Carton/Builder.pm22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Carton/Builder.pm b/lib/Carton/Builder.pm
index d03318f..d3aa010 100644
--- a/lib/Carton/Builder.pm
+++ b/lib/Carton/Builder.pm
@@ -42,14 +42,28 @@ sub bundle {
}
}
- require IO::Compress::Gzip;
- my $index = $cache_path->child("modules/02packages.details.txt.gz");
+ my $has_io_gzip = eval { require IO::Compress::Gzip; 1 };
+
+ my $ext = $has_io_gzip ? ".txt.gz" : ".txt";
+ my $index = $cache_path->child("modules/02packages.details$ext");
$index->parent->mkpath;
warn "Writing $index\n";
- my $out = IO::Compress::Gzip->new($index->openw)
- or die "gzip failed: $IO::Compress::Gzip::GzipError";
+
+ my $out = $index->openw;
+ if ($has_io_gzip) {
+ $out = IO::Compress::Gzip->new($out)
+ or die "gzip failed: $IO::Compress::Gzip::GzipError";
+ }
+
$snapshot->index->write($out);
+ close $out;
+
+ unless ($has_io_gzip) {
+ unlink "$index.gz";
+ !system 'gzip', $index
+ or die "Running gzip command failed: $!";
+ }
}
sub install {