]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - modulemanager
Change the syntax of FOREACH macros to be less dumb.
[user/henk/code/inspircd.git] / modulemanager
index 41c2c872c54fd3b8467e245b8475bbf6e6701938..7884654af1fd07a8a5d9b939c81f1a82bf8ad94d 100755 (executable)
@@ -1,10 +1,42 @@
 #!/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;
 
+
+if (!module_installed("LWP::Simple"))
+{
+       die "Your system is missing the LWP::Simple Perl module!";
+}
+
+if (!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;
@@ -141,10 +173,9 @@ my %todo = %installed;
 sub ver_cmp {
        ($a,$b) = @_ if @_;
 
-       # string versions first, git IDs
-       if ($a =~ /[a-z0-9]{40}/ or $b =~ /[a-z0-9]{40}/)
+       if ($a !~ /^[0-9.]+$/ or $b !~ /^[0-9.]+$/)
        {
-               # it's a string version. compare them as such.
+               # not a valid version number, don't try to sort
                return $a ne $b;
        }
 
@@ -152,7 +183,7 @@ sub ver_cmp {
        my @a = split /\./, $a;
        my @b = split /\./, $b;
        push @a, 0 while $#a < $#b;
-       push @b, 0 while $#b < $#a;
+       push @b, ($_[2] || 0) while $#b < $#a;
        for my $i (0..$#a) {
                my $d = $a[$i] <=> $b[$i];
                return $d if $d;
@@ -163,13 +194,13 @@ sub ver_cmp {
 sub ver_in_range {
        my($ver, $range) = @_;
        return 1 unless defined $range;
+       my($l,$h) = ($range, $range);
        if ($range =~ /(.*)-(.*)/) {
-               my($l,$h) = ($1,$2);
-               return 0 if $l && ver_cmp($ver, $l) < 0;
-               return 0 if $h && ver_cmp($ver, $h) > 0;
-               return 1;
+               ($l,$h) = ($1,$2);
        }
-       return !ver_cmp($ver, $range);
+       return 0 if $l && ver_cmp($ver, $l) < 0;
+       return 0 if $h && ver_cmp($ver, $h, 9999) > 0;
+       return 1;
 }
 
 sub find_mod_in_range {
@@ -231,7 +262,7 @@ sub resolve_deps {
        }
 }
 
-my $action = lc shift @ARGV;
+my $action = $#ARGV > 0 ? lc shift @ARGV : 'help';
 
 if ($action eq 'install') {
        for my $mod (@ARGV) {