Added new global attribute <exclude_from_update>
Added new parameter <changed> to updatefhem git-svn-id: https://svn.fhem.de/fhem/trunk@1601 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -38,7 +38,9 @@
|
|||||||
new global attribute <backupsymlink> added
|
new global attribute <backupsymlink> added
|
||||||
new global attribute <backupcmd> added
|
new global attribute <backupcmd> added
|
||||||
new global attribute <backup_before_update> added
|
new global attribute <backup_before_update> added
|
||||||
- feature: new module 57_Calendar.pm (Boris(
|
- feature: new module 57_Calendar.pm (Boris)
|
||||||
|
- feature: new parameter <changed> for updatefhem added (M. Fischer)
|
||||||
|
new global attribute <exclude_from_update> added (M. Fischer)
|
||||||
|
|
||||||
- 2011-12-31 (5.2)
|
- 2011-12-31 (5.2)
|
||||||
- bugfix: applying smallscreen attributes to firefox/opera
|
- bugfix: applying smallscreen attributes to firefox/opera
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ use IO::Socket;
|
|||||||
sub CommandUpdatefhem($$);
|
sub CommandUpdatefhem($$);
|
||||||
sub CommandCULflash($$);
|
sub CommandCULflash($$);
|
||||||
sub GetHttpFile($$@);
|
sub GetHttpFile($$@);
|
||||||
|
sub ParseChanges($);
|
||||||
|
sub ReadOldFiletimes($);
|
||||||
|
sub SplitNewFiletimes($);
|
||||||
sub FileList($);
|
sub FileList($);
|
||||||
|
|
||||||
my $server = "fhem.de:80";
|
my $server = "fhem.de:80";
|
||||||
@@ -46,7 +49,7 @@ CommandUpdatefhem($$)
|
|||||||
my $msg;
|
my $msg;
|
||||||
|
|
||||||
if(!$param && !-d $wwwdir) {
|
if(!$param && !-d $wwwdir) {
|
||||||
$ret = "Usage: updatefhem [<filename>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]\n";
|
$ret = "Usage: updatefhem [<changed>|<filename>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]\n";
|
||||||
$ret .= "Please note: The update routine has changed! Please consider the manual of command 'updatefhem'!";
|
$ret .= "Please note: The update routine has changed! Please consider the manual of command 'updatefhem'!";
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -56,7 +59,13 @@ CommandUpdatefhem($$)
|
|||||||
|
|
||||||
if(@args) {
|
if(@args) {
|
||||||
|
|
||||||
if (uc($args[0]) eq "PRESERVE") {
|
# Get list of changes
|
||||||
|
if (uc($args[0]) eq "CHANGED") {
|
||||||
|
$ret = ParseChanges($moddir);
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
# Preserve current structur
|
||||||
|
} elsif (uc($args[0]) eq "PRESERVE") {
|
||||||
|
|
||||||
# Check if new wwwdir already exists and an argument is given
|
# Check if new wwwdir already exists and an argument is given
|
||||||
if(-d $wwwdir && @args > 1) {
|
if(-d $wwwdir && @args > 1) {
|
||||||
@@ -138,45 +147,33 @@ CommandUpdatefhem($$)
|
|||||||
|
|
||||||
# help
|
# help
|
||||||
} elsif (uc($args[0]) eq "?") {
|
} elsif (uc($args[0]) eq "?") {
|
||||||
return "Usage: updatefhem [<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]";
|
return "Usage: updatefhem [<changed>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]";
|
||||||
# user wants to update a file / module of the old structure
|
# user wants to update a file / module of the old structure
|
||||||
} elsif (!-d $wwwdir) {
|
} elsif (!-d $wwwdir) {
|
||||||
return "Usage: updatefhem [<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]";
|
return "Usage: updatefhem [<changed>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read in the OLD filetimes.txt
|
# Read in the OLD filetimes.txt
|
||||||
my %oldtime = ();
|
my $oldtime = ReadOldFiletimes("$moddir/$ftime");
|
||||||
if(open FH, "$moddir/$ftime") {
|
|
||||||
while(my $l = <FH>) {
|
|
||||||
chomp($l);
|
|
||||||
my ($ts, $fs, $file) = split(" ", $l, 3);
|
|
||||||
$oldtime{$file} = $ts;
|
|
||||||
}
|
|
||||||
close(FH);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# Get new filetimes.txt
|
||||||
my $filetimes = GetHttpFile($server, "$sdir/$ftime");
|
my $filetimes = GetHttpFile($server, "$sdir/$ftime");
|
||||||
return "Can't get $ftime from $server" if(!$filetimes);
|
return "Can't get $ftime from $server" if(!$filetimes);
|
||||||
|
|
||||||
my (%filetime, %filesize) = ();
|
# split filetime and filesize
|
||||||
foreach my $l (split("[\r\n]", $filetimes)) {
|
my ($sret, $filetime, $filesize) = SplitNewFiletimes($filetimes);
|
||||||
chomp($l);
|
return "$sret" if($sret);
|
||||||
return "Corrupted filetimes.txt file"
|
|
||||||
if($l !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /);
|
|
||||||
my ($ts, $fs, $file) = split(" ", $l, 3);
|
|
||||||
$filetime{$file} = $ts;
|
|
||||||
$filesize{$file} = $fs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# Check for new / modified files
|
||||||
my $c = 0;
|
my $c = 0;
|
||||||
foreach my $f (sort keys %filetime) {
|
foreach my $f (sort keys %$filetime) {
|
||||||
if($param) {
|
if($param) {
|
||||||
next if($f !~ m/$param/);
|
next if($f !~ m/$param/);
|
||||||
} else {
|
} else {
|
||||||
if(!$clean) {
|
if(!$clean) {
|
||||||
next if($oldtime{$f} && $filetime{$f} eq $oldtime{$f});
|
next if($oldtime->{$f} && $filetime->{$f} eq $oldtime->{$f});
|
||||||
}
|
}
|
||||||
next if($f =~ m/.hex$/); # skip firmware files
|
next if($f =~ m/.hex$/); # skip firmware files
|
||||||
}
|
}
|
||||||
@@ -189,14 +186,14 @@ CommandUpdatefhem($$)
|
|||||||
my $doBackup = (!defined($attr{global}{backup_before_update}) ? 1 : $attr{global}{backup_before_update});
|
my $doBackup = (!defined($attr{global}{backup_before_update}) ? 1 : $attr{global}{backup_before_update});
|
||||||
|
|
||||||
if ($doBackup) {
|
if ($doBackup) {
|
||||||
$ret = AnalyzeCommandChain(undef, "backup");
|
my $cmdret = AnalyzeCommandChain(undef, "backup");
|
||||||
if($ret !~ m/backup done.*/) {
|
if($cmdret !~ m/backup done.*/) {
|
||||||
Log 1, "updatefhem: The operation was canceled. Please check manually!";
|
Log 1, "updatefhem: The operation was canceled. Please check manually!";
|
||||||
$msg = "Something went wrong during backup:\n$ret\n";
|
$msg = "Something went wrong during backup:\n$cmdret\n";
|
||||||
$msg .= "The operation was canceled. Please check manually!";
|
$msg .= "The operation was canceled. Please check manually!";
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
$ret .= "\n";
|
$ret .= "$cmdret\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my @reload;
|
my @reload;
|
||||||
@@ -205,12 +202,19 @@ CommandUpdatefhem($$)
|
|||||||
my $remfile;
|
my $remfile;
|
||||||
my $oldfile;
|
my $oldfile;
|
||||||
my $delfile;
|
my $delfile;
|
||||||
foreach my $f (sort keys %filetime) {
|
my $excluded = (!defined($attr{global}{exclude_from_update}) ? "" : $attr{global}{exclude_from_update});
|
||||||
|
|
||||||
|
foreach my $f (sort keys %$filetime) {
|
||||||
|
my $ef = substr $f,rindex($f,'/')+1;
|
||||||
|
if($excluded =~ /$ef/) {
|
||||||
|
$ret .= "excluded $f\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
if($param) {
|
if($param) {
|
||||||
next if($f !~ m/$param/);
|
next if($f !~ m/$param/);
|
||||||
} else {
|
} else {
|
||||||
if(!$clean) {
|
if(!$clean) {
|
||||||
next if($oldtime{$f} && $filetime{$f} eq $oldtime{$f});
|
next if($oldtime->{$f} && $filetime->{$f} eq $oldtime->{$f});
|
||||||
}
|
}
|
||||||
next if($f =~ m/.hex$/); # skip firmware files
|
next if($f =~ m/.hex$/); # skip firmware files
|
||||||
}
|
}
|
||||||
@@ -240,7 +244,7 @@ CommandUpdatefhem($$)
|
|||||||
|
|
||||||
my $content = GetHttpFile($server, "$sdir/$remfile");
|
my $content = GetHttpFile($server, "$sdir/$remfile");
|
||||||
my $l1 = length($content);
|
my $l1 = length($content);
|
||||||
my $l2 = $filesize{$f};
|
my $l2 = $filesize->{$f};
|
||||||
return "File size for $f ($l1) does not correspond to ".
|
return "File size for $f ($l1) does not correspond to ".
|
||||||
"filetimes.txt entry ($l2)" if($l1 ne $l2);
|
"filetimes.txt entry ($l2)" if($l1 ne $l2);
|
||||||
open(FH,">$localfile") || return "Can't write $localfile";
|
open(FH,">$localfile") || return "Can't write $localfile";
|
||||||
@@ -340,21 +344,15 @@ CommandCULflash($$)
|
|||||||
my $filetimes = GetHttpFile($server, "$sdir/$ftime");
|
my $filetimes = GetHttpFile($server, "$sdir/$ftime");
|
||||||
return "Can't get $ftime from $server" if(!$filetimes);
|
return "Can't get $ftime from $server" if(!$filetimes);
|
||||||
|
|
||||||
my (%filetime, %filesize);
|
# split filetime and filesize
|
||||||
foreach my $l (split("[\r\n]", $filetimes)) {
|
my ($ret, $filetime, $filesize) = SplitNewFiletimes($filetimes);
|
||||||
chomp($l);
|
return $ret if($ret);
|
||||||
return "Corrupted filetimes.txt file"
|
|
||||||
if($l !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /);
|
|
||||||
my ($ts, $fs, $file) = split(" ", $l, 3);
|
|
||||||
$filetime{$file} = $ts;
|
|
||||||
$filesize{$file} = $fs;
|
|
||||||
}
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Now get the firmware file:
|
# Now get the firmware file:
|
||||||
my $content = GetHttpFile($server, "$sdir/$target.hex");
|
my $content = GetHttpFile($server, "$sdir/FHEM/$target.hex");
|
||||||
return "File size for $target.hex does not correspond to filetimes.txt entry"
|
return "File size for $target.hex does not correspond to filetimes.txt entry"
|
||||||
if(length($content) ne $filesize{"$target.hex"});
|
if(length($content) ne $filesize->{"FHEM/$target.hex"});
|
||||||
my $localfile = "$moddir/$target.hex";
|
my $localfile = "$moddir/$target.hex";
|
||||||
open(FH,">$localfile") || return "Can't write $localfile";
|
open(FH,">$localfile") || return "Can't write $localfile";
|
||||||
print FH $content;
|
print FH $content;
|
||||||
@@ -416,6 +414,97 @@ GetHttpFile($$@)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
ParseChanges($)
|
||||||
|
{
|
||||||
|
my $moddir = shift;
|
||||||
|
my $excluded = (!defined($attr{global}{exclude_from_update}) ? "" : $attr{global}{exclude_from_update});
|
||||||
|
my $ret = "List of new / modified files since last update:\n";
|
||||||
|
|
||||||
|
# get list of files
|
||||||
|
my $filetimes = GetHttpFile($server, "$sdir/$ftime");
|
||||||
|
return $ret."Can't get $ftime from $server" if(!$filetimes);
|
||||||
|
|
||||||
|
# split filetime and filesize
|
||||||
|
my ($sret, $filetime, $filesize) = SplitNewFiletimes($filetimes);
|
||||||
|
$ret .= "$sret\n" if($sret);
|
||||||
|
|
||||||
|
# Read in the OLD filetimes.txt
|
||||||
|
my $oldtime = ReadOldFiletimes("$moddir/$ftime");
|
||||||
|
|
||||||
|
# Check for new / modified files
|
||||||
|
my $c = 0;
|
||||||
|
foreach my $f (sort keys %$filetime) {
|
||||||
|
next if($oldtime->{$f} && $filetime->{$f} eq $oldtime->{$f});
|
||||||
|
next if($f =~ m/.hex$/); # skip firmware files
|
||||||
|
$c = 1;
|
||||||
|
my $ef = substr $f,rindex($f,'/')+1;
|
||||||
|
if($excluded !~ /$ef/) {
|
||||||
|
$ret .= "$filetime->{$f} $f\n";
|
||||||
|
} else {
|
||||||
|
$ret .= "$filetime->{$f} $f ==> excluded from update!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$c) {
|
||||||
|
$ret .= "nothing to do...";
|
||||||
|
} else {
|
||||||
|
# get list of changes
|
||||||
|
$ret .= "\nList of changes:\n";
|
||||||
|
my $changed = GetHttpFile($server, "$sdir/CHANGED");
|
||||||
|
if(!$changed || $changed =~ m/Error 404/g) {
|
||||||
|
$ret .= "Can't get list of changes from $server";
|
||||||
|
} else {
|
||||||
|
my @lines = split(/\015\012|\012|\015/,$changed);
|
||||||
|
foreach my $line (@lines) {
|
||||||
|
last if($line eq "");
|
||||||
|
$ret .= $line."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
ReadOldFiletimes($)
|
||||||
|
{
|
||||||
|
my $filetimes = shift;
|
||||||
|
my %oldtime = ();
|
||||||
|
my $excluded = (!defined($attr{global}{exclude_from_update}) ? "" : $attr{global}{exclude_from_update});
|
||||||
|
|
||||||
|
# Read in the OLD filetimes.txt
|
||||||
|
if(open FH, "$filetimes") {
|
||||||
|
while(my $l = <FH>) {
|
||||||
|
chomp($l);
|
||||||
|
my ($ts, $fs, $file) = split(" ", $l, 3);
|
||||||
|
my $ef = substr $file,rindex($file,'/')+1;
|
||||||
|
next if($excluded =~ /$ef/);
|
||||||
|
$oldtime{$file} = $ts;
|
||||||
|
}
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
return (\%oldtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
SplitNewFiletimes($)
|
||||||
|
{
|
||||||
|
my $filetimes = shift;
|
||||||
|
my $ret;
|
||||||
|
my (%filetime, %filesize) = ();
|
||||||
|
foreach my $l (split("[\r\n]", $filetimes)) {
|
||||||
|
chomp($l);
|
||||||
|
$ret = "Corrupted filetimes.txt file"
|
||||||
|
if($l !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /);
|
||||||
|
last if($ret);
|
||||||
|
my ($ts, $fs, $file) = split(" ", $l, 3);
|
||||||
|
$filetime{$file} = $ts;
|
||||||
|
$filesize{$file} = $fs;
|
||||||
|
}
|
||||||
|
return ($ret, \%filetime, \%filesize);
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
FileList($)
|
FileList($)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -509,3 +509,7 @@
|
|||||||
- Sat Jun 02 2012 (M. Fischer)
|
- Sat Jun 02 2012 (M. Fischer)
|
||||||
- Added new global attribute <backup_before_update>
|
- Added new global attribute <backup_before_update>
|
||||||
- Backuproutine from updatefhem removed. updatefhem use the command backup from now.
|
- Backuproutine from updatefhem removed. updatefhem use the command backup from now.
|
||||||
|
|
||||||
|
- Sun Jun 03 2012 (M. Fischer)
|
||||||
|
- Added new global attribute <exclude_from_update>
|
||||||
|
- Added new parameter <changed> to updatefhem
|
||||||
|
|||||||
@@ -775,7 +775,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<a name="updatefhem"></a>
|
<a name="updatefhem"></a>
|
||||||
<h3>updatefhem</h3>
|
<h3>updatefhem</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<code>updatefhem [<filename>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]</code> <br>
|
<code>updatefhem [<changed>|<filename>|<housekeeping> [<clean>] [<yes>]|<preserve> [<filename>]]</code> <br>
|
||||||
<br>
|
<br>
|
||||||
Update the fhem modules and documentation from a nightly SVN checkout. For
|
Update the fhem modules and documentation from a nightly SVN checkout. For
|
||||||
this purpose Fhem contacts http://fhem.de/fhemupdate, compares the stored
|
this purpose Fhem contacts http://fhem.de/fhemupdate, compares the stored
|
||||||
@@ -796,6 +796,17 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
the global attribute <a href="#backup_before_update">backup_before_update</a> to 0.
|
the global attribute <a href="#backup_before_update">backup_before_update</a> to 0.
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
Have you change or replace original files of the Fhem Distribution,
|
||||||
|
these files will normally be overwritten during an update. To protect
|
||||||
|
your locally modified or replaced files during an update, you can exclude
|
||||||
|
these files with the global attribute <a href="#exclude_from_update">exclude_from_update</a>.
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
If <changed> is specified, updatefhem returns a list of new or
|
||||||
|
modified files since the last update. Furthermore it returns the last
|
||||||
|
changes from the CHANGED file (if the file exists on the update server).
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
If an explicit <filename> is given, then only this file will be
|
If an explicit <filename> is given, then only this file will be
|
||||||
downloaded.
|
downloaded.
|
||||||
<br>
|
<br>
|
||||||
@@ -1236,6 +1247,16 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
be written to this file.
|
be written to this file.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
<a name="exclude_from_update"></a>
|
||||||
|
<li>exclude_from_update<br>
|
||||||
|
Contains a space separated list of file which will be excluded by an update.
|
||||||
|
This Attribute is used by the <a href="#updatefhem">updatefhem</a> command.<br>
|
||||||
|
Example:<br>
|
||||||
|
<ul>
|
||||||
|
attr global exclude_from_update 21_OWTEMP.pm temp4hum4.gplot FS20.on.png FS20.off.png
|
||||||
|
</ul>
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<a name="holiday2we"></a>
|
<a name="holiday2we"></a>
|
||||||
<li>holiday2we<br>
|
<li>holiday2we<br>
|
||||||
If this attribute is set, then the <a href="#perl">$we</a> variable
|
If this attribute is set, then the <a href="#perl">$we</a> variable
|
||||||
|
|||||||
@@ -193,12 +193,11 @@ $modules{Global}{AttrList} =
|
|||||||
"archivecmd allowfrom apiversion archivedir configfile lastinclude logfile " .
|
"archivecmd allowfrom apiversion archivedir configfile lastinclude logfile " .
|
||||||
"modpath nrarchive pidfilename port statefile title userattr " .
|
"modpath nrarchive pidfilename port statefile title userattr " .
|
||||||
"verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " .
|
"verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " .
|
||||||
"autoload_undefined_devices dupTimeout latitude longitude ".
|
"autoload_undefined_devices dupTimeout latitude longitude " .
|
||||||
"backupcmd backupdir backupsymlink backup_before_update";
|
"backupcmd backupdir backupsymlink backup_before_update " .
|
||||||
|
"exclude_from_update ";
|
||||||
$modules{Global}{AttrFn} = "GlobalAttr";
|
$modules{Global}{AttrFn} = "GlobalAttr";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%cmds = (
|
%cmds = (
|
||||||
"?" => { Fn=>"CommandHelp",
|
"?" => { Fn=>"CommandHelp",
|
||||||
Hlp=>",get this help" },
|
Hlp=>",get this help" },
|
||||||
|
|||||||
Reference in New Issue
Block a user