aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Check/Input/Updates/Source/NetBSD.pm
blob: 5142001d698d56f08186280cc783f151c08e205d (plain)
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
# $Id$
package Youri::Check::Input::Updates::Source::NetBSD;

=head1 NAME

Youri::Check::Input::Updates::Source::NetBSD - NetBSD source for updates

=head1 DESCRIPTION

This source plugin for L<Youri::Check::Input::Updates> collects updates
 available from NetBSD.

=cut

use warnings;
use strict;
use Carp;
use base 'Youri::Check::Input::Updates::Source';
use IO::Ftp;

=head2 new(%args)

Creates and returns a new Youri::Check::Input::Updates::Source::NetBSD object.

Specific parameters:

=over

=item url $url

URL to NetBSD mirror content file, without ftp: (default: //ftp.free.fr/mirrors/ftp.netbsd.org/NetBSD-current/pkgsrc/README-all.html)

=back

=cut

sub _init {
    my $self    = shift;
    my %options = (
        url => '//ftp.free.fr/mirrors/ftp.netbsd.org/NetBSD-current/pkgsrc/README-all.html',
        @_
    );

    my $versions;
    my $urls;

    my $in = IO::Ftp->new('<',$options{url}) or croak "Can't fetch $options{url}: $!";
    while (my $line = <$in>) {
        next unless $line =~ /<!-- (.+)-([^-]*?)(nb\d*)? \(for sorting\).*?href="([^"]+)"/;
        my $name = $1;
        my $version = $2;
        $versions->{$name} = $version;
        $urls->{$name} = $4;
    }
    close($in);

    $self->{_versions} = $versions;
    $self->{_urls} = $urls;
    $self->{_url} = $options{url};
}

sub _url {
    my ($self, $name) = @_;
    return $self->{_urls}->{$name};
}

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2002-2006, YOURI project

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

=cut

1;