#!/usr/bin/env perl
+
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+# Copyright (C) 2008-2009 Robin Burchell <robin+git@viroteck.net>
+#
+# This file is part of InspIRCd. InspIRCd is free software: you can
+# redistribute it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+
use strict;
use warnings FATAL => qw(all);
-use LWP::Simple;
use make::configure;
+BEGIN {
+ unless (module_installed("LWP::Simple")) {
+ die "Your system is missing the LWP::Simple Perl module!";
+ }
+ unless (module_installed("Crypt::SSLeay") || module_installed("IO::Socket::SSL")) {
+ die "Your system is missing the Crypt::SSLeay or IO::Socket::SSL Perl modules!";
+ }
+}
+
+use LWP::Simple;
+
our @modlist;
my %installed;
# retrieve and parse entries from sources.list
sub parse_url {
- my $src = shift;
+ chomp(my $src = shift);
return if $url_seen{$src};
$url_seen{$src}++;
- my $doc = get($src);
- die "Could not retrieve $_" unless defined $doc;
+ my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
+ my $response = $ua->get($src);
+
+ unless ($response->is_success) {
+ my $err = $response->message;
+ die "Could not retrieve $src: $err";
+ }
my $mod;
- for (split /\n+/, $doc) {
+ for (split /\n+/, $response->decoded_content) {
s/^\s+//; # ignore whitespace at start
next if /^#/;
if (/^module (\S+) (\S+) (\S+)/) {
}
}
-my $action = lc shift @ARGV;
+my $action = $#ARGV >= 0 ? lc shift @ARGV : 'help';
if ($action eq 'install') {
for my $mod (@ARGV) {
}
$mod_versions{$mod} = $ver;
- my $stat = getstore($url, "src/modules/$mod.cpp");
- if ($stat == 200) {
+ my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
+ my $response = $ua->get($url);
+
+ if ($response->is_success) {
+ open(MF, ">src/modules/$mod.cpp") or die "\nFilesystem not writable: $!";
+ print MF $response->decoded_content;
+ close(MF);
print " - done\n";
} else {
- print " - HTTP $stat\n";
+ printf "\nHTTP %s: %s\n", $response->code, $response->message;
}
}