-
Notifications
You must be signed in to change notification settings - Fork 89
/
mk-download.pl
executable file
·120 lines (99 loc) · 2.48 KB
/
mk-download.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl
require "./date.pm";
my $dir="download";
opendir(DIR, $dir) || die "cannot opendir $dir: $!";
my @files = readdir(DIR);
closedir DIR;
opendir(DIR, "$dir/archeology") || die "cannot opendir $dir/archeology: $!";
while (readdir DIR) {
push @files, "archeology/$_";
}
closedir DIR;
sub filesize {
my ($filename)=@_;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
return $size;
}
for(@files) {
my $file = $_;
if($file =~ /([0-9.]*)\..*(zip|bz2|lzma|xz|gz)\z/) {
my ($version, $ext)=($1, $2);
$exts{$version}.="$ext,";
$allext{$ext}++;
$file{$version.$ext}=$file;
$versions{$version}=1;
}
}
open(HEAD, "<head.html");
while(<HEAD>) {
$_ =~ s/<title>curl<\/title>/<title>curl downloads<\/title>\n<base href=\"https:\/\/curl.se\">/;
print $_;
}
close(HEAD);
my $nice = TodayNicelyEng();
my $ae;
for(keys %allext) {
$ae .= "$_ ";
}
print <<MOO
<div class="where"><a href="https://curl.se/">curl</a> / <b>download archive</b></div>
<h1>curl download archive</h1>
<div class="relatedbox">
<b>Related:</b>
<br><a href="https://curl.se/changes.html">Changelog</a>
<br><a href="https://curl.se/download.html">Download page</a>
<br><a href="https://curl.se/docs/releases.html">Release table</a>
</div>
<p>
<table class="daily" cellspacing="0" cellpadding="3">
<tr class="tabletop"><th>Version</th>
MOO
;
for(sort split(" ", $ae)) {
print "<th>$_</th>\n";
}
print "</tr>\n";
sub num {
my ($t)=@_;
if($t =~ /^(\d)\.(\d+)\.(\d+)/) {
return 10000*$1 + 100*$2 + $3;
}
elsif($t =~ /^(\d)\.(\d+)/) {
return 10000*$1 + 100*$2;
}
}
sub sortthem {
return num($a) <=> num($b);
}
my $i;
for(reverse sort sortthem keys %versions) {
my $date=$_;
$finedate = $date;
if($date =~ /(\d\d\d\d)(\d\d)(\d\d)/) {
$finedate = sprintf("%s %d, %04d", MonthNameEng($2), $3, $1);
}
printf "<tr class=\"%s\"><td>$finedate</td> ",
$i++&1?"odd":"even";
for(sort split(" ", $ae)) {
my $ext=$_;
my $file = $file{$date.$ext};
if($file && -f "$dir/$file" ) {
printf "<td><a href=\"$dir/%s\">%.2fMB</a></td>",
$file, filesize("$dir/$file")/(1024*1024);
}
else {
print "<td> </td>\n";
}
}
print "</tr>\n";
}
print "</table>\n";
print <<MOO
<p>
MOO
;
open(FOOT, "<foot.html");
print <FOOT>;
close(FOOT);