--- mirror_cpan.pl 2004/01/20 19:48:05 1.5 +++ mirror_cpan.pl 2004/01/31 18:25:54 1.6 @@ -27,6 +27,16 @@ my $TRACE = 0; +# This may or may not save you some disks space (depending on filesystem +# that you use to store CPAN mirror) +# +# If you want to create gziped readme files, change $readme_ext to +# my $readme_ext = '.readme.gz'; +# +# I found out that gziping readme files doesn't save any +# space at one server and saves space on my laptop. YMMV +my $readme_ext = '.readme.gz'; + ### END CONFIG ## core - @@ -130,13 +140,13 @@ sub clean_unmirrored { find sub { - return if /\.readme.gz$/; # don't erase readme files + return if /${readme_ext}$/; # don't erase readme files check_readme($File::Find::name); return unless -f and not $mirrored{$File::Find::name}; print "$File::Find::name ... removed\n" if $TRACE; unlink $_ or warn "Cannot remove $File::Find::name: $!"; my $path = $File::Find::name; - if ($path =~ s/(\.tar\.gz|\.tgz)/.readme.gz/g && -f $path) { + if ($path =~ s/(\.tar\.gz|\.tgz)/${readme_ext}/g && -f $path) { # only if we erase archive also! unlink $path or warn "Cannot remove $path: $!"; } @@ -148,7 +158,7 @@ my $path = shift; # fixup some things my $readme_path = $path; - $readme_path =~ s/\.(tar\.gz|\.tgz)/.readme.gz/g || return; # just .tar.gz is supported! + $readme_path =~ s/\.(tar\.gz|\.tgz)/${readme_ext}/g || return; # just .tar.gz is supported! my $at = Archive::Tar->new($path) or die "Archive::Tar failed on $path\n"; @@ -158,7 +168,12 @@ my $readme; if ($readme = shift @readmes) { - my $fh = IO::Zlib->new($readme_path, "wb"); + my $fh; + if ($readme_ext =~ m/\.gz/) { + $fh = IO::Zlib->new($readme_path, "wb"); + } else { + $fh = IO::File->new($readme_path, "w"); + } if (defined $fh) { print $fh $at->get_content($readme); $fh->close;