diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-08-04 21:49:35 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-08-04 21:49:35 +0000 |
commit | 818a53e13ab7d86f84231aa30bac2956a93ea292 (patch) | |
tree | 5f579f14697beb23b52d4a27b162c69bcc71b869 | |
parent | eb0fb524184baa44aef8eba9dfb07cdeaf279343 (diff) |
Track installed module versions, so we can do upgrades properly.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11489 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | make/configure.pm | 17 | ||||
-rwxr-xr-x | modulemanager | 38 |
2 files changed, 38 insertions, 17 deletions
diff --git a/make/configure.pm b/make/configure.pm index 05db6004e..ae88d90ce 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -20,7 +20,7 @@ use warnings FATAL => qw(all); use Exporter 'import'; use POSIX; use make::utilities; -our @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies getmodversion nopedantic resolve_directory yesno showhelp promptstring_s); +our @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s); my $no_svn = 0; @@ -122,21 +122,6 @@ sub getdependencies { return ""; } -sub getmodversion { - my ($file) = @_; - open(FLAGS, $file) or return ""; - while (<FLAGS>) { - if (m#(?:^/* \$|")ModVersion: (\S+)(?: \*\/$|")#) { - my $x = translate_functions($1, $file); - next if ($x eq ""); - close(FLAGS); - return $x; - } - } - close(FLAGS); - return ""; -} - sub nopedantic { my ($file) = @_; open(FLAGS, $file) or return ""; 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; } |