diff --git a/fhem/FHEM/98_version.pm b/fhem/FHEM/98_version.pm new file mode 100755 index 000000000..7af1a156b --- /dev/null +++ b/fhem/FHEM/98_version.pm @@ -0,0 +1,150 @@ +# $Id$ + +package main; +use strict; +use warnings; + +sub version_Initialize($$) { + + $cmds{version} = { Fn => "CommandVersion", + Hlp=>"[filter],print SVN version of loaded modules"}; +} + +##################################### +sub +CommandVersion($$) +{ + my ($cl, $param) = @_; + + my @ret = ("# $cvsid") ; + push @ret, cfgDB_svnId() if(configDBUsed()); + my $max = 7 ; # length("fhem.pl") = 7 + my $modpath = (exists($attr{global}{modpath}) ? $attr{global}{modpath} : ""); + foreach my $m (keys %INC) + { + next unless($INC{$m} =~ /^$modpath.FHEM/ or $INC{$m} =~ /^FHEM/); # configDB + my $fn = $INC{$m}; + my $mod_name = ($fn=~ /[\/\\]([^\/\\]+)$/ ? $1 : $fn); + next if($param && $mod_name !~ /$param/); + next if(grep(/$mod_name/, @ret)); + Log 4, "Looking for SVN Id in module $mod_name"; + + if($max < length($mod_name)) { + $max = length($mod_name) + } + my $line; + + if(!open(FH, $fn)) { + $line = "$fn: $!"; + if(configDBUsed()){ + Log 4, "Looking for module $m in configDB to find SVN Id"; + $line = cfgDB_Fileversion($fn,$line); + } + } else { + ($line) = grep(/#.*\$Id\:[^\$\n\r].+\$/, ); + } + + $line = "No Id found for $mod_name" unless($line); + push @ret, $line; + } + + @ret = map {/\$Id\: (\S+) (\S+) (.+?) \$/ ? sprintf("%-".$max."s %5d %s",$1,$2,$3) : $_} + @ret; + @ret = grep {(defined($param) ? $_ =~ /$param/ : 1)} @ret; + @ret = sort {version_sortModules($a, $b)} @ret; + return "no loaded modules found that match: $param" if($param && !@ret); + return sprintf("%-".$max."s %s","File","Rev Last Change\n\n"). + join("\n", grep (($_ =~ /^fhem.pl|\d\d_/), @ret)).(!$param ? "\n\n":""). + join("\n", grep (($_ !~ /^fhem.pl|\d\d_/), @ret)); +} + +##################################### +sub version_sortModules($$) +{ + my ($a, $b) = @_; + + $a =~ s/^No Id found for //; + $b =~ s/^No Id found for //; + + my @a_vals = split(' ', $a); + my @b_vals = split(' ', $b); + + return -1 if($a_vals[0] eq "fhem.pl"); # fhem.pl always at top + + $a_vals[0] =~ s/^\d\d_//; + $b_vals[0] =~ s/^\d\d_//; + + return uc($a_vals[0]) cmp uc($b_vals[0]); +} + +1; + +=pod +=begin html + + +

version

+ + +=end html + +=begin html_DE + + +

version

+ +=end html_DE + +=cut diff --git a/fhem/MAINTAINER.txt b/fhem/MAINTAINER.txt index 1ec8280c7..6dc158993 100644 --- a/fhem/MAINTAINER.txt +++ b/fhem/MAINTAINER.txt @@ -331,6 +331,7 @@ FHEM/98_statistics.pm tupol http://forum.fhem.de Unterstue FHEM/98_structure.pm rudolfkoenig http://forum.fhem.de Automatisierung FHEM/98_telnet.pm rudolfkoenig http://forum.fhem.de Automatisierung FHEM/98_update.pm rudolfkoenig http://forum.fhem.de Sonstiges +FHEM/98_version.pm markusbloch http://forum.fhem.de Sonstiges FHEM/98_weblink.pm rudolfkoenig http://forum.fhem.de Frontends FHME/98_weekprofile.pm risiko http://forum.fhem.de Frontends FHEM/99_SUNRISE_EL.pm rudolfkoenig http://forum.fhem.de Automatisierung diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index d03974843..dc7f01f26 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1296,24 +1296,6 @@ The following local attributes are used by a wider range of devices:
- -

version

- diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index 535ca6ee1..18b0371c6 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -1376,25 +1376,6 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet: blockiert. Das ist unerwünscht, und im FHEM-Log wird eine Warnung protokolliert. - - -

version

-