fhemupdate.pl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/usr/bin/perl
  2. ###############################
  3. # This is quite a big mess here.
  4. use IO::File;
  5. use strict;
  6. use warnings;
  7. # Server-Side script to check out the fhem SVN repository, and upload the
  8. # changed files to the server
  9. $ENV{CVS_RSH}="/usr/bin/ssh";
  10. print "\n\n";
  11. print localtime() . "\n";
  12. my $homedir="/home/rudi/fhemupdate";
  13. chdir("$homedir/culfw");
  14. system("svn update .");
  15. chdir("$homedir/fhem");
  16. system("svn update .");
  17. die "SVN failed, exiting\n" if($?);
  18. `../copyfiles.sh`;
  19. #################################
  20. # new Style
  21. chdir("$homedir/fhem");
  22. system("mkdir -p fhemupdate");
  23. my @filelist2 = (
  24. "./fhem.pl.txt",
  25. "./CHANGED",
  26. "./configDB.pm",
  27. "FHEM/.*.pm",
  28. "FHEM/.*.layout",
  29. "FHEM/FhemUtils/.*.pm",
  30. "FHEM/FhemUtils/update-.*",
  31. "FHEM/lib/.*.pm",
  32. "FHEM/lib/.*.xml",
  33. "FHEM/lib/.*.csv",
  34. "FHEM/firmware/.*",
  35. "FHEM/lib/SWAP/.*.xml",
  36. "FHEM/lib/SWAP/panStamp/.*",
  37. "FHEM/lib/SWAP/justme/.*",
  38. "FHEM/lib/Device/.*.pm",
  39. "FHEM/lib/Device/Firmata/.*.pm",
  40. "FHEM/lib/Device/MySensors/.*.pm",
  41. "FHEM/lib/MP3/.*.pm",
  42. "FHEM/lib/MP3/Tag/.*",
  43. "FHEM/lib/UPnP/.*",
  44. "contrib/commandref_join.pl.txt",
  45. "contrib/commandref_modular.pl.txt",
  46. "www/pgm2/.*",
  47. "www/pgm2/images/.*.png",
  48. "www/jscolor/.*",
  49. "www/codemirror/.*",
  50. "www/gplot/.*.gplot",
  51. "www/images/fhemSVG/.*.svg",
  52. "www/images/openautomation/.*.svg",
  53. "www/images/openautomation/.*.txt",
  54. "www/images/default/.*",
  55. "www/images/default/remotecontrol/.*",
  56. "docs/commandref.*.html",
  57. "docs/faq(_..)?.html",
  58. "docs/HOWTO(_..)?.html",
  59. "docs/fhem.*.png",
  60. "docs/.*.jpg",
  61. "docs/fhemdoc.js",
  62. "demolog/.*",
  63. "./fhem.cfg.demo",
  64. );
  65. # Can't make negative regexp to work, so do it with extra logic
  66. my %skiplist2 = (
  67. # "www/pgm2" => ".pm\$",
  68. );
  69. # Read in the file timestamps
  70. my %filetime2;
  71. my %filesize2;
  72. my %filedir2;
  73. foreach my $fspec (@filelist2) {
  74. $fspec =~ m,^(.+)/([^/]+)$,;
  75. my ($dir,$pattern) = ($1, $2);
  76. my $tdir = $dir;
  77. opendir DH, $dir || die("Can't open $dir: $!\n");
  78. foreach my $file (grep { /$pattern/ && -f "$dir/$_" } readdir(DH)) {
  79. next if($skiplist2{$tdir} && $file =~ m/$skiplist2{$tdir}/);
  80. my @st = stat("$dir/$file");
  81. my @mt = localtime($st[9]);
  82. $filetime2{"$tdir/$file"} = sprintf "%04d-%02d-%02d_%02d:%02d:%02d",
  83. $mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0];
  84. $filesize2{"$tdir/$file"} = $st[7];
  85. $filedir2{"$tdir/$file"} = $dir;
  86. }
  87. closedir(DH);
  88. }
  89. chdir("$homedir/fhem/fhemupdate");
  90. my %oldtime;
  91. my $fname = "controls_fhem.txt";
  92. if(open FH, $fname) {
  93. while(my $l = <FH>) {
  94. chomp($l);
  95. next if($l !~ m/^UPD ([^ ]*) ([^ ]*) (.*)$/);
  96. my ($ts, $fs, $file) = ($1, $2, $3);
  97. $oldtime{"$file.txt"} = $ts if($file =~ m/\.pl$/);
  98. $oldtime{$file} = $ts;
  99. }
  100. close(FH);
  101. }
  102. my $cfh = new IO::File ">$fname" || die "Can't open $fname: $!\n";
  103. `svn info ..` =~ m/Revision: (\d+)/m;
  104. print $cfh "REV $1\n";
  105. if(open(ADD, "../../fhemupdate.control.fhem")) {
  106. print $cfh join("",<ADD>);
  107. close ADD;
  108. }
  109. my $cnt;
  110. foreach my $f (sort keys %filetime2) {
  111. my $fn = $f;
  112. $fn =~ s/.txt$// if($fn =~ m/.pl.txt$/);
  113. print $cfh "UPD $filetime2{$f} $filesize2{$f} $fn\n";
  114. my $newfname = $f;
  115. if(!$oldtime{$f} || $oldtime{$f} ne $filetime2{$f}) {
  116. $f =~ m,^(.*)/([^/]*)$,;
  117. my ($tdir, $file) = ($1, $2);
  118. system("mkdir -p $tdir") unless(-d $tdir);
  119. system("cp ../$filedir2{$f}/$file $tdir/$file");
  120. $cnt++;
  121. }
  122. }
  123. close $cfh;
  124. $ENV{RSYNC_RSH}="ssh";
  125. chdir("$homedir/fhem");
  126. system("cp -p ../culfw/Devices/CUL/*.hex fhemupdate/FHEM");
  127. system("cp -p ../culfw/Devices/CUL/*.hex fhemupdate/FHEM/firmware");
  128. system("cp -p FHEM/firmware/*.hex fhemupdate/FHEM/firmware");
  129. my $rsyncopts="-a --delete --compress --verbose";
  130. system("rsync $rsyncopts fhemupdate/. fhem.de:fhem/fhemupdate/.");
  131. if(-f "commandref_changed") {
  132. system("scp docs/commandref.html docs/commandref_DE.html fhem.de:fhem");
  133. }
  134. system("scp CHANGED MAINTAINER.txt fhem.de:fhem");
  135. system("scp fhem.de:fhem/stats/data/fhem_statistics_db.sqlite ..");
  136. chdir("$homedir");
  137. system("grep -v '^REV' fhem/fhemupdate/controls_fhem.txt > controls_fhem_5.5.txt");
  138. system("scp controls_fhem_5.5.txt fhem.de:fhem/fhemupdate4/svn/controls_fhem.txt");
  139. system("sh stats/dostats.sh");
  140. system("sh mksvnlog.sh > SVNLOG");
  141. system("scp SVNLOG fhem.de:fhem");
  142. system("sourceforge/dorsync");