Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 9 additions & 10 deletions cpan2spec
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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"
Expand Down Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion cpanget
Original file line number Diff line number Diff line change
Expand Up @@ -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=''
Expand Down