blob: 3a7651d86a60a620a6145835a558cb1a29a201d1 (
plain) (
blame)
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
|
#!/usr/bin/perl -w
# arch_size.pl -- html output of archive size per architecture
# Copyright (C) Simon Paillard Nov 2008
use strict;
use LWP::UserAgent;
# Work around LWP::UserAgent not being able to verify certs correctly
my $ca_dir = '/etc/ssl/ca-debian';
$ENV{HTTPS_CA_DIR} = $ca_dir if -d $ca_dir;
# Parameters
my $inputfile="https://ftp-master.debian.org/arch-space";
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $inputfile);
$ua->timeout("10");
my $res = $ua->request($req);
## Check the outcome of the response
if (!$res->is_success) {
my $status = $res->status_line;
die "Input file cannot be fetched from $inputfile:\n$status";
}
my $arch_space = $res->content;
my $total ;
my $space;
for my $line (split("\n",$arch_space)) {
if ((my $arch, my $size) = split (/\s+/, $line)) {
$space->{$arch}=$size/1000000000 ;
$total += $size ;
}
}
open (OUTPUT, ">size.data") or die $!;
select OUTPUT;
printf "<tr><td>source</td>\t<td>%.0f</td></tr>\n", $space->{"Source"};
foreach my $key (sort keys %$space) {
printf "<tr><td>$key</td>\t<td>%.0f</td></tr>\n", $space->{$key} unless ($key eq "Source");
}
$total /= 1000000000 ;
printf "<tr><td>Total</td>\t<td>%.0f</td></tr>\n", $total ;
close OUTPUT;
|