X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=modulemanager;h=ff2bd3056137768cba3fa6cf69b10bb989c12f0c;hb=0fa8cdd7b87779e3517e296689703f1d7a7c86df;hp=0e978977abdc098d17f1b202c8af2e31ff450dba;hpb=4d91c60d55e832c47253a586e9c9de219d24e851;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/modulemanager b/modulemanager index 0e978977a..ff2bd3056 100755 --- a/modulemanager +++ b/modulemanager @@ -1,4 +1,24 @@ -#!/usr/bin/perl +#!/usr/bin/env perl + +# +# InspIRCd -- Internet Relay Chat Daemon +# +# Copyright (C) 2008-2009 Robin Burchell +# +# 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 . +# + + use strict; use warnings FATAL => qw(all); use LWP::Simple; @@ -101,6 +121,18 @@ getmodules(1); # determine core version `./src/version.sh` =~ /InspIRCd-([0-9.]+)/ or die "Cannot determine inspircd version"; $installed{core} = $1; +for my $mod (keys %modules) { + MODVER: for my $mver (keys %{$modules{$mod}}) { + for my $dep (@{$modules{$mod}{$mver}{depends}}) { + next unless $dep =~ /^core (.*)/; + if (!ver_in_range($installed{core}, $1)) { + delete $modules{$mod}{$mver}; + next MODVER; + } + } + } + delete $modules{$mod} unless %{$modules{$mod}}; +} $modules{core}{$1} = { url => 'NONE', depends => [], @@ -129,10 +161,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; } @@ -140,7 +171,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; @@ -151,13 +182,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 {