diff --git a/README.md b/README.md index 6233c55..77d38fd 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,6 @@ Please install these modules first (You can use `cpanm`): - Text::Autoformat - YAML - LWP::UserAgent + - LWP::Protocol::https - Parse::CPAN::Packages + - Digest::SHA \ No newline at end of file diff --git a/cpan2spec b/cpan2spec index 017d00e..12399e8 100755 --- a/cpan2spec +++ b/cpan2spec @@ -217,6 +217,7 @@ use File::Basename; use LWP::UserAgent; use Parse::CPAN::Packages; use Pod::Simple::TextContent; +use Digest::SHA; # Apparently gets pulled in by another module. #use Cwd; @@ -240,7 +241,7 @@ our $outdir='library-perl'; # default output dir our $cleanup_source=1; # default: remove downloaded source archives our $skip_postprocess=0; # default: enable spec post-processing our $source; -our $cpan=$ENV{'CPAN'} || "http://www.cpan.org"; +our $cpan=$ENV{'CPAN'} || "https://www.cpan.org"; our $home=$ENV{'HOME'} || (getpwuid($<))[7]; die "Can't locate home directory. Please define \$HOME.\n" @@ -568,18 +569,16 @@ sub get_sha256($) { return "0" x 64 if (!-f $file); - my @output=`sha256sum "$file" 2>/dev/null`; + open my $fh, '<', $file + or die "Can't open $file: $!\n"; - if ($? != 0) { - warn "Failed to calculate SHA256 for $file: $!\n"; - return "0" x 64; - } + binmode $fh; - if (@output && $output[0] =~ /^([a-f0-9]{64})\s+/) { - return $1; - } + my $sha256 = Digest::SHA->new(256) + ->addfile($fh) + ->hexdigest; - return "0" x 64; + return $sha256 || ("0" x 64); } diff --git a/cpanget b/cpanget index 936643f..ce8b24e 100755 --- a/cpanget +++ b/cpanget @@ -2,7 +2,7 @@ set -e -CPAN=${CPAN:-"http://www.cpan.org"} +CPAN=${CPAN:-"https://www.cpan.org"} packages=$HOME/.cpan/sources/modules/02packages.details.txt.gz quiet=''