summaryrefslogtreecommitdiff
path: root/modulemanager
diff options
context:
space:
mode:
Diffstat (limited to 'modulemanager')
-rwxr-xr-xmodulemanager38
1 files changed, 37 insertions, 1 deletions
diff --git a/modulemanager b/modulemanager
index 96d58834d..68d32324d 100755
--- a/modulemanager
+++ b/modulemanager
@@ -24,6 +24,7 @@ my %url_seen;
sub parse_url;
+# retrieve and parse entries from sources.list
sub parse_url {
my $src = shift;
return if $url_seen{$src};
@@ -65,6 +66,29 @@ sub parse_url {
}
}
+# hash of installed module versions from our mini-database, key (m_foobar) to version (00abacca..).
+my %mod_versions;
+
+# useless helper stub
+sub getmodversion {
+ my ($file) = @_;
+ return $mod_versions{$file};
+}
+
+# read in installed versions
+if (-e '.modulemanager')
+{
+ open SRC, '.modulemanager' or die ".modulemanager exists but i can't read it: $!";
+ while (<SRC>)
+ {
+ s/\n//;
+ (my $mod, my $ver) = split(/ /, $_);
+ $mod_versions{$mod} = $ver;
+ }
+ close SRC;
+}
+
+# read in external URL sources
open SRC, 'sources.list' or die "Could not open sources.list: $!";
while (<SRC>) {
next if /^\s*#/;
@@ -74,6 +98,7 @@ close SRC;
getmodules(1);
+# determine core version
`./src/version.sh` =~ /InspIRCd-([0-9.]+)/ or die "Cannot determine inspircd version";
$installed{core} = $1;
$modules{core}{$1} = {
@@ -83,10 +108,11 @@ $modules{core}{$1} = {
from => 'local file',
};
+# set up core module list
for my $modname (@modlist) {
my $mod = "m_$modname";
my $modfile = "src/modules/$mod.cpp";
- my $ver = getmodversion($modfile) || '0.0';
+ my $ver = getmodversion($mod) || '0.0';
$ver =~ s/\$Rev: (.*) \$/$1/; # for storing revision in SVN
$installed{$mod} = $ver;
next if $modules{$mod}{$ver};
@@ -270,10 +296,20 @@ for my $mod (sort keys %todo) {
} else {
print "Installing $mod $ver from $url";
}
+ $mod_versions{$mod} = $ver;
+
my $stat = getstore($url, "src/modules/$mod.cpp");
if ($stat == 200) {
print " - done\n";
} else {
print " - HTTP $stat\n";
}
+
+ # write database of installed versions
+ open SRC, '>.modulemanager' or die "can't write installed versions to .modulemanager, won't be able to track upgrades properly: $!";
+ foreach my $key (keys %mod_versions)
+ {
+ print SRC "$key $mod_versions{$key}\n";
+ }
+ close SRC;
}