Release packaging & scripting improvements.
[users/jgh/exim.git] / release-process / scripts / mk_exim_release
index b07f088c877a376125f457247e45b431540b1e47..34fe77c6726b1b95680893a6ec34e24c36641bb5 100755 (executable)
@@ -235,6 +235,7 @@ sub move_text_docs_into_pkg {
 
     # move generated documents from docbook stuff
     foreach my $file (qw/exim.8 spec.txt filter.txt/) {
+        die "Empty file \"$file\"\n" if -z File::Spec->catfile( $old_docdir, $file );
         move( File::Spec->catfile( $old_docdir, $file ), File::Spec->catfile( $new_docdir, $file ) );
     }
 
@@ -360,21 +361,25 @@ sub create_tar_files {
         }
     }
 
+    # See also environment variables set in main, tuning compression levels
+    my @COMPRESSIONS = (
+        # compressors-dict-key, file-extension, flags-as-string
+        [ "gzip", "gz", "--gzip" ],
+        [ "bzip2", "bz2", "--bzip2" ],
+        [ "lzip", "lz", "--lzip" ],
+        [ "xz", "xz", "--xz" ],
+    );
+
     foreach my $dir ( glob( File::Spec->catdir( $pkgdirs, ( 'exim*-' . $context->{release} ) ) ) ) {
         my $dirname = ( File::Spec->splitdir($dir) )[-1];
-        if ($context->{compressors}{gzip}) {
-            print "Creating: ${pkgs}/${dirname}.tar.gz\n" if ($verbose || $debug);
-            system("$tar cf  ${pkgs}/${dirname}.tar.gz  --gzip  -C ${pkgdirs} ${dirname}")
-        }
-        if ($context->{compressors}{bzip2}) {
-            print "Creating: ${pkgs}/${dirname}.tar.bz2\n" if ($verbose || $debug);
-            system("$tar cf  ${pkgs}/${dirname}.tar.bz2 --bzip2 -C ${pkgdirs} ${dirname}")
-        }
-        if ($context->{compressors}{lzip}) {
-            print "Creating: ${pkgs}/${dirname}.tar.lz\n" if ($verbose || $debug);
-            system("$tar cf  ${pkgs}/${dirname}.tar.lz  --lzip  -C ${pkgdirs} ${dirname}")
+        foreach my $comp (@COMPRESSIONS) {
+            my ($compkey, $extension, $flags) = @{$comp};
+            next unless $context->{compressors}{$compkey};
+            print "Creating: ${pkgs}/${dirname}.tar.${extension}\n" if ($verbose || $debug);
+            system("$tar cf  ${pkgs}/${dirname}.tar.${extension} ${flags} --numeric-owner -C ${pkgdirs} ${dirname}");
         }
     }
+
 }
 
 # ------------------------------------------------------------------
@@ -393,6 +398,7 @@ MAIN: {
         compressors => {
                 gzip    => 1,
                 bzip2   => 1,
+                xz      => 1,
                 lzip    => 0,
         },
         build_docs   => 1,
@@ -401,6 +407,13 @@ MAIN: {
     my $delete;
     my $cleanup = 1;
     ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
+    # We are creating files for mass distribution, so work harder to make smaller files.
+    $ENV{'GZIP'} = '-9';
+    $ENV{'BZIP2'} = '-9';
+    # xz documents minimum file sizes for levels higher than -6 to be useful and each
+    # requires more RAM on the decompressing system.  Exim tarball currently 24MiB so
+    # using -8.
+    $ENV{'XZ_DEFAULTS'} = '-8';
 
     GetOptions(
         'directory=s'   => \$context->{directory},
@@ -418,6 +431,7 @@ MAIN: {
         'web!'          => \$context->{web},
     ) and @ARGV == 1 or pod2usage;
 
+    umask(022);
     get_and_check_version( shift, $context );
     fix_paths_tar($context);
     $context->{tag} = build_tag($context);