#< LICENSE: WTFPL >
use warnings;
use strict;
-use Digest::SHA1;
+use Digest::SHA;
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
#< Config START >
-my $scan_dir = '/xxxxxxxxxxxxxxxxxxxxxx/sf-download/';
+my $scan_dir = shift(@ARGV)
+ or die "Local package directory not specified (first argument)\n";
+my $save_rss_file = shift(@ARGV)
+ or die "RSS output file path not specified (second argument)\n";
my $base_dlurl = 'https://www.privoxy.org/sf-download-mirror/';
-my $save_rss_file ='/xxxxxxxxxxxxxxxxxxxxxx/release.xml'; # e.g., release.rss
my $maxlimit = 1000;
my $max_advertised_files = 100;
my $yday;
my $isdst;
my $target;
-my $target_sha1;
+my $target_sha256;
my $target_uri;
my $target_time;
my $target_line;
$target = $scan_dir . $fi1 . '/' . $fi2 . '/' . $fi3;
next if (!-e $target); # skip if file is not exist
- # Get SHA-1 hash
+ # Get SHA-256 hash
my $filedata;
open($filedata, "<", $target)
or die "Can't open '$target' to generate checksum $!";
- my $sha1 = Digest::SHA1->new;
- $sha1->addfile($filedata);
+ my $sha256 = Digest::SHA->new("SHA-256");
+ $sha256->addfile($filedata);
close($filedata);
- $target_sha1 = $sha1->hexdigest;
+ $target_sha256 = $sha256->hexdigest;
# URI and Time
$target_uri = $fi1 . '/' . $fi2 . '/' . $fi3;
$target_line .=
'<description><![CDATA['
. $target_uri
- . ' (SHA-1: '
- . $target_sha1
+ . ' (SHA-256: '
+ . $target_sha256
. ')]]></description>';
$target_line .=
'<link>'
$target_line .= '<pubDate>';
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
gmtime($target_time);
- $target_line .=
- "$days[$wday], $mday $months[$mon] "
- . ($year + 1900)
- . " $hour:$min:$sec GMT";
+ $target_line .= sprintf("%s, %s %s %d %.2d:%.2d:%.2d GMT",
+ $days[$wday], $mday, $months[$mon], ($year + 1900),
+ $hour, $min, $sec);
$target_line .= '</pubDate></item>';
# Add it to Array