2011-06-26 11:20:14 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
###############################
|
|
|
|
# This is quite a big mess here.
|
|
|
|
|
2012-07-01 11:36:26 +00:00
|
|
|
use IO::File;
|
|
|
|
|
2011-11-05 08:59:29 +00:00
|
|
|
# Server-Side script to check out the fhem SVN repository, and upload the
|
2011-06-26 11:20:14 +00:00
|
|
|
# changed files to the server
|
|
|
|
|
2012-01-05 12:13:48 +00:00
|
|
|
$ENV{CVS_RSH}="/usr/bin/ssh";
|
|
|
|
|
|
|
|
print "\n\n";
|
2011-06-26 11:20:14 +00:00
|
|
|
print localtime() . "\n";
|
|
|
|
|
2012-03-18 13:30:52 +00:00
|
|
|
#my $homedir="/Users/rudi/Projects/fhem/fhemupdate";
|
|
|
|
my $homedir="/home/rudi/fhemupdate";
|
|
|
|
#goto NEWSTYLE;
|
|
|
|
|
|
|
|
chdir("$homedir/culfw");
|
2012-01-05 12:13:48 +00:00
|
|
|
system("svn update .");
|
2012-10-30 18:46:58 +00:00
|
|
|
|
2012-03-18 13:30:52 +00:00
|
|
|
chdir("$homedir/fhem");
|
2012-10-30 18:46:58 +00:00
|
|
|
system("mkdir -p fhemupdate");
|
2012-01-05 12:13:48 +00:00
|
|
|
system("svn update .");
|
2011-11-05 08:59:29 +00:00
|
|
|
die "SVN failed, exiting\n" if($?);
|
2011-06-26 11:20:14 +00:00
|
|
|
|
2012-12-29 17:21:04 +00:00
|
|
|
`../copyfiles.sh`;
|
2012-01-05 12:13:48 +00:00
|
|
|
|
2012-03-18 13:30:52 +00:00
|
|
|
#################################
|
|
|
|
# Old style
|
2011-06-26 11:20:14 +00:00
|
|
|
my @filelist = (
|
2012-01-05 12:13:48 +00:00
|
|
|
"./fhem.pl.txt",
|
2011-06-26 11:20:14 +00:00
|
|
|
"FHEM/.*.pm",
|
2012-07-01 11:36:26 +00:00
|
|
|
"FHEM/FhemUtils/.*.pm",
|
2012-12-29 16:40:28 +00:00
|
|
|
"FHEM/lib/.*.pm",
|
2012-10-30 18:46:58 +00:00
|
|
|
"www/gplot/.*.gplot",
|
|
|
|
"www/images/dark/.*.png",
|
|
|
|
"www/images/default/.*.png",
|
|
|
|
"www/images/smallscreen/.*.png",
|
|
|
|
"www/pgm2/.*\.(js|css|svg)",
|
2012-12-29 17:21:04 +00:00
|
|
|
"docs/commandref(_..)?.html",
|
|
|
|
"docs/faq(_..)?.html",
|
|
|
|
"docs/HOWTO(_..)?.html",
|
2011-06-26 11:20:14 +00:00
|
|
|
"docs/fhem.*.png",
|
|
|
|
"docs/.*.jpg",
|
2012-01-05 12:13:48 +00:00
|
|
|
"../culfw/Devices/CUL/.*.hex",
|
2012-06-03 15:19:01 +00:00
|
|
|
"./CHANGED",
|
2011-06-26 11:20:14 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
# Read in the file timestamps
|
|
|
|
my %filetime;
|
|
|
|
my %filesize;
|
|
|
|
my %filedir;
|
|
|
|
foreach my $fspec (@filelist) {
|
|
|
|
$fspec =~ m,^(.+)/([^/]+)$,;
|
|
|
|
my ($dir,$pattern) = ($1, $2);
|
2012-06-03 15:19:01 +00:00
|
|
|
|
2011-06-26 11:20:14 +00:00
|
|
|
opendir DH, $dir || die("Can't open $dir: $!\n");
|
|
|
|
foreach my $file (grep { /$pattern/ && -f "$dir/$_" } readdir(DH)) {
|
|
|
|
my @st = stat("$dir/$file");
|
|
|
|
my @mt = localtime($st[9]);
|
|
|
|
$filetime{$file} = sprintf "%04d-%02d-%02d_%02d:%02d:%02d",
|
|
|
|
$mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0];
|
|
|
|
$filesize{$file} = $st[7];
|
|
|
|
$filedir{$file} = $dir;
|
|
|
|
}
|
|
|
|
closedir(DH);
|
|
|
|
}
|
|
|
|
|
|
|
|
my %oldtime;
|
2012-10-30 18:46:58 +00:00
|
|
|
if(open FH, "fhemupdate/filetimes.txt") {
|
2011-06-26 11:20:14 +00:00
|
|
|
while(my $l = <FH>) {
|
|
|
|
chomp($l);
|
|
|
|
my ($ts, $fs, $file) = split(" ", $l, 3);
|
2012-01-05 12:13:48 +00:00
|
|
|
$oldtime{"$file.txt"} = $ts if($file eq "fhem.pl");
|
2011-06-26 11:20:14 +00:00
|
|
|
$oldtime{$file} = $ts;
|
|
|
|
}
|
|
|
|
close(FH);
|
|
|
|
}
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
chdir("$homedir/fhem/fhemupdate");
|
2011-06-26 11:20:14 +00:00
|
|
|
open FH, ">filetimes.txt" || die "Can't open filetimes.txt: $!\n";
|
|
|
|
my $cnt;
|
|
|
|
foreach my $f (sort keys %filetime) {
|
2012-01-05 12:13:48 +00:00
|
|
|
my $fn = $f;
|
|
|
|
$fn =~ s/.txt$// if($fn =~ m/.pl.txt$/);
|
|
|
|
print FH "$filetime{$f} $filesize{$f} $fn\n";
|
|
|
|
|
2011-06-26 11:20:14 +00:00
|
|
|
my $newfname = $f;
|
|
|
|
if(!$oldtime{$f} || $oldtime{$f} ne $filetime{$f}) {
|
2012-01-05 12:13:48 +00:00
|
|
|
system("cp ../$filedir{$f}/$f $f");
|
2011-06-26 11:20:14 +00:00
|
|
|
$cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close FH;
|
2012-03-18 13:30:52 +00:00
|
|
|
NEWSTYLE:
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
for(my $loop = 0; $loop < 2; $loop++) {
|
|
|
|
#################################
|
|
|
|
# new Style
|
|
|
|
chdir("$homedir/fhem");
|
|
|
|
my $uploaddir2= ($loop ? "fhemupdate4" : "fhemupdate2");
|
|
|
|
system("mkdir -p $uploaddir2");
|
|
|
|
|
|
|
|
my %filelist2 = (
|
|
|
|
"./fhem.pl.txt" => { type=>",fhem,", dir=>"." },
|
|
|
|
"./CHANGED" => { type=>",fhem,", dir=>"." },
|
|
|
|
"FHEM/.*.pm" => { type=>",fhem,", dir=>"FHEM" },
|
|
|
|
"FHEM/FhemUtils/.*.pm" => { type=>",fhem,", dir=>"FHEM/FhemUtils"},
|
2012-12-29 16:47:46 +00:00
|
|
|
"FHEM/lib/.*.pm" => { type=>",fhem,", dir=>"FHEM/lib"},
|
2012-10-30 18:46:58 +00:00
|
|
|
"../culfw/Devices/CUL/.*.hex" => { type=>",fhem,", dir=>"FHEM",
|
|
|
|
dir3=>"FHEM", },
|
|
|
|
"www/pgm2/.*" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"www/gplot/.*.gplot" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"www/images/dark/.*.png" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"www/images/default/.*" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"www/images/smallscreen/.*" => { type=>"fhem,", dir=>"www/pgm2"},
|
2012-12-29 17:21:04 +00:00
|
|
|
"docs/commandref(_..)?.html" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"docs/faq(_..)?.html" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"docs/HOWTO(_..)?.html" => { type=>"fhem,", dir=>"www/pgm2"},
|
2012-10-30 18:46:58 +00:00
|
|
|
"docs/fhem.*.png" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
"docs/.*.jpg" => { type=>"fhem,", dir=>"www/pgm2"},
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
# Can't make negative regexp to work, so do it with extra logic
|
|
|
|
my %skiplist2 = (
|
|
|
|
# "www/pgm2" => ".pm\$",
|
|
|
|
);
|
|
|
|
|
|
|
|
# Read in the file timestamps
|
|
|
|
my %filetime2;
|
|
|
|
my %filesize2;
|
|
|
|
my %filedir2;
|
|
|
|
my %filetype2;
|
|
|
|
foreach my $fspec (keys %filelist2) {
|
|
|
|
$fspec =~ m,^(.+)/([^/]+)$,;
|
|
|
|
my ($dir,$pattern) = ($1, $2);
|
|
|
|
my $tdir = $filelist2{$fspec}{$loop ? "dir3" : "dir"};
|
|
|
|
$tdir = $dir if(!$tdir);
|
|
|
|
opendir DH, $dir || die("Can't open $dir: $!\n");
|
|
|
|
foreach my $file (grep { /$pattern/ && -f "$dir/$_" } readdir(DH)) {
|
|
|
|
next if($skiplist2{$tdir} && $file =~ m/$skiplist2{$tdir}/);
|
|
|
|
my @st = stat("$dir/$file");
|
|
|
|
my @mt = localtime($st[9]);
|
|
|
|
$filetime2{"$tdir/$file"} = sprintf "%04d-%02d-%02d_%02d:%02d:%02d",
|
|
|
|
$mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0];
|
|
|
|
$filesize2{"$tdir/$file"} = $st[7];
|
|
|
|
$filedir2{"$tdir/$file"} = $dir;
|
|
|
|
$filetype2{"$tdir/$file"} = $filelist2{$fspec}{type};
|
|
|
|
}
|
|
|
|
closedir(DH);
|
2012-03-18 13:30:52 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
chdir("$homedir/fhem/$uploaddir2");
|
|
|
|
my %oldtime;
|
|
|
|
if(open FH, "filetimes.txt") {
|
|
|
|
while(my $l = <FH>) {
|
|
|
|
chomp($l);
|
|
|
|
my ($ts, $fs, $file) = split(" ", $l, 3);
|
|
|
|
$oldtime{"$file.txt"} = $ts if($file =~ m/fhem.pl/);
|
|
|
|
$oldtime{$file} = $ts;
|
|
|
|
}
|
|
|
|
close(FH);
|
2012-03-18 13:30:52 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
open FH, ">filetimes.txt" || die "Can't open filetimes.txt: $!\n";
|
2012-07-01 11:36:26 +00:00
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
my %controls = (fhem=>0);
|
2012-07-01 11:36:26 +00:00
|
|
|
foreach my $k (keys %controls) {
|
2012-10-30 18:46:58 +00:00
|
|
|
my $fname = "controls_$k.txt";
|
|
|
|
$controls{$k} = new IO::File ">$fname" || die "Can't open $fname: $!\n";
|
|
|
|
if(open(ADD, "../../fhemupdate.control.$k")) {
|
|
|
|
while(my $l = <ADD>) {
|
|
|
|
my $fh = $controls{$k};
|
|
|
|
print $fh $l;
|
|
|
|
}
|
|
|
|
close ADD;
|
|
|
|
}
|
2012-03-18 13:30:52 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
my $cnt;
|
|
|
|
foreach my $f (sort keys %filetime2) {
|
|
|
|
my $fn = $f;
|
|
|
|
$fn =~ s/.txt$// if($fn =~ m/.pl.txt$/);
|
|
|
|
print FH "$filetime2{$f} $filesize2{$f} $fn\n";
|
|
|
|
foreach my $k (keys %controls) {
|
2012-07-01 11:36:26 +00:00
|
|
|
my $fh = $controls{$k};
|
2012-10-30 18:46:58 +00:00
|
|
|
print $fh "UPD $filetime2{$f} $filesize2{$f} $fn\n"
|
|
|
|
}
|
|
|
|
my $newfname = $f;
|
|
|
|
if(!$oldtime{$f} || $oldtime{$f} ne $filetime2{$f}) {
|
|
|
|
$f =~ m,^(.*)/([^/]*)$,;
|
|
|
|
my ($tdir, $file) = ($1, $2);
|
|
|
|
system("mkdir -p $tdir") unless(-d $tdir);
|
|
|
|
system("cp ../$filedir2{$f}/$file $tdir/$file");
|
|
|
|
$cnt++;
|
2012-07-01 11:36:26 +00:00
|
|
|
}
|
2012-06-07 13:59:44 +00:00
|
|
|
}
|
2012-10-30 18:46:58 +00:00
|
|
|
close FH;
|
|
|
|
|
|
|
|
foreach my $k (keys %controls) {
|
|
|
|
close $controls{$k};
|
|
|
|
}
|
2012-06-07 13:59:44 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:46:58 +00:00
|
|
|
$ENV{RSYNC_RSH}="ssh";
|
|
|
|
chdir("$homedir/fhem");
|
|
|
|
|
|
|
|
if(0) {
|
|
|
|
my $fname="controls_fhem.txt";
|
|
|
|
`cp fhemupdate4/$fname fhemupdate`;
|
|
|
|
`cp fhemupdate4/$fname fhemupdate2/FHEM`;
|
|
|
|
`rm fhemupdate2/$fname`;
|
|
|
|
my @st = stat("fhemupdate4/$fname");
|
|
|
|
my @mt = localtime($st[9]);
|
|
|
|
my $ftime = sprintf "%04d-%02d-%02d_%02d:%02d:%02d",
|
|
|
|
$mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0];
|
|
|
|
my $fsize = $st[7];
|
|
|
|
system("echo $ftime $fsize $fname >> fhemupdate/filetimes.txt");
|
|
|
|
system("echo $ftime $fsize FHEM/$fname >> fhemupdate2/filetimes.txt");
|
2012-03-18 13:30:52 +00:00
|
|
|
}
|
2012-10-30 18:46:58 +00:00
|
|
|
|
|
|
|
my $rsyncopts="-a --delete --compress --verbose";
|
|
|
|
system("rsync $rsyncopts fhemupdate fhem.de:fhem");
|
|
|
|
system("rsync $rsyncopts fhemupdate2 fhem.de:fhem");
|
|
|
|
system("rsync $rsyncopts fhemupdate4/. fhem.de:fhem/fhemupdate4/svn");
|
2012-12-29 17:21:04 +00:00
|
|
|
system("scp docs/commandref.html docs/commandref_DE.html fhem.de:fhem");
|
|
|
|
system("scp CHANGED fhem.de:fhem");
|