+ # We ideally do not want local system user information in release tarballs;
+ # those are artifacts of use of tar for backups and have no place in
+ # software release packaging; if someone extracts as root, then they should
+ # get sane file ownerships.
+ my @ownership = (
+ '--owner' => $context->{tar_perms}{user},
+ '--group' => $context->{tar_perms}{group},
+ # on this GNU tar, --numeric-owner works during creation too
+ '--numeric-owner'
+ ) if qx/tar --help 2>&1/ =~ /^\s*--owner=/m;
+
+ # See also environment variables set in main, tuning compression levels
+ my %COMPRESSION = (
+ gzip => { extension => 'gz', flags => '--gzip' },
+ bzip2 => { extension => 'bz2', flags => '--bzip2' },
+ lzip => { extension => 'lz', flags => '--lzip' },
+ xz => { extension => 'xz', flags => '--xz' },
+ );
+
+
+ my (%size, %sha256);
+
+ foreach my $dir ( glob( catdir( $pkg_trees, ( 'exim*-' . $context->{v}{release} ) ) ) ) {
+ my $dirname = ( splitdir($dir) )[-1];
+ foreach my $comp (keys %COMPRESSION) {
+ next unless $context->{compressors}{$comp};
+
+ my $basename = "$dirname.tar.$COMPRESSION{$comp}{extension}";
+ my $outfile = catfile $pkg_tars, $basename;
+
+ print "Creating: $outfile\n" if $verbose || $debug;
+ 0 == system($tar,
+ cf => $outfile,
+ $COMPRESSION{$comp}{flags},
+ @ownership, -C => $pkg_trees, $dirname)
+ or exit $? >> 8;
+
+ # calculate size and md5sum
+ $size{$basename} = -s $outfile;
+ $sha256{$basename} = do {
+ my $sha = Digest::SHA->new(256);
+ $sha->addfile($outfile);
+ $sha->hexdigest;
+ };
+ }