Make Porting/makerel create smaller archives with 7z and advdef
authorLeon Brocard <acme@astray.com>
Tue, 12 Jul 2011 08:08:57 +0000 (09:08 +0100)
committerLeon Brocard <acme@astray.com>
Tue, 12 Jul 2011 08:08:57 +0000 (09:08 +0100)
It automatically will use these to create archives ~5% smaller,
otherwise falls back to gzip and bzip2.

Also, document in Porting/release_managers_guide.pod.

Porting/makerel
Porting/release_managers_guide.pod

index 1e7ca7c..13bcf4a 100755 (executable)
@@ -171,14 +171,39 @@ exit if $opts{n};
 
 my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch
 
-print "Creating and compressing the tar.gz file...\n";
-$cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
-system($cmd) == 0 or die "$cmd failed";
+print "Checking if you have 7z...\n";
+my $output_7z = `7z 2>&1`;
+my $have_7z = defined $output_7z && $output_7z =~ /7-Zip/;
 
-if ($opts{b}) {
-    print "Creating and compressing the tar.bz2 file...\n";
-    $cmd = "tar cf - $reldir | bzip2 > $reldir.tar.bz2";
+print "Checking if you have advdef...\n";
+my $output_advdef = `advdef --version 2>&1`;
+my $have_advdef = defined $output_advdef && $output_advdef =~ /advancecomp/;
+
+if ($have_7z) {
+    print "Creating and compressing the tar.gz file with 7z...\n";
+    $cmd = "tar cf - $reldir | 7z a -tgzip -mx9 -bd -si $reldir.tar.gz";
     system($cmd) == 0 or die "$cmd failed";
+} else {
+    print "Creating and compressing the tar.gz file...\n";
+    $cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
+    system($cmd) == 0 or die "$cmd failed";
+    if ($have_advdef) {
+        print "Recompressing the tar.gz file with advdef...\n";
+        $cmd = "advdef -z -4 $reldir.tar.gz";
+        system($cmd) == 0 or die "$cmd failed";
+    }
+}
+
+if ($opts{b}) {
+    if ($have_7z) {
+        print "Creating and compressing the tar.bz2 file with 7z...\n";
+        $cmd = "tar cf - $reldir | 7z a -tbzip2 -mx9 -bd -si $reldir.tar.bz2";
+        system($cmd) == 0 or die "$cmd failed";
+    } else {
+        print "Creating and compressing the tar.bz2 file...\n";
+        $cmd = "tar cf - $reldir | bzip2 > $reldir.tar.bz2";
+        system($cmd) == 0 or die "$cmd failed";
+    }
 }
 
 print "\n";
index eb84850..6c5f6a3 100644 (file)
@@ -586,6 +586,16 @@ and you'll need to use a new version number for your release.
 
 =head3 build the tarball
 
+Before you run the following, you might want to install 7-Zip (the
+C<p7-full> package under Debian or the C<p7zip> port on MacPorts) or
+the AdvanceCOMP suite (e.g. the C<advancecomp> package under Debian,
+or the C<advancecomp> port on macports - 7-Zip on Windows is the
+same code as AdvanceCOMP, so Windows users get the smallest files
+first time). These compress about 5% smaller than gzip and bzip2.
+Over the lifetime of your distribution this will save a lot of
+people a small amount of download time and disk space, which adds
+up.
+
 Create a tarball. Use the C<-s> option to specify a suitable suffix for
 the tarball and directory name:
 
@@ -610,20 +620,6 @@ your changes were all committed, you can override the suffix with:
 XXX if we go for extra tags and branches stuff, then add the extra details
 here
 
-Optionally, you might want to compress your tarball more. Unix F<gzip>
-doesn't actually produce the smallest possible DEFLATE output. If you have the
-AdvanceCOMP suite (e.g. the C<advancecomp> port on macports), you can run
-
-    $ advdef -z -4 ../perl-x.y.z-RC1.tar.gz
-
-which will probably shrink your tarball by about 5%. Over the lifetime of
-your distribution this will save a lot of people a small amount of download
-time and disk space, which adds up.
-
-(7-Zip on Windows is the same code as AdvanceCOMP, so Windows users get the
-smallest files first time)
-
-
 Finally, clean up the temporary directory, e.g.
 
     $ rm -rf ../perl-x.y.z-RC1