-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfhemupdate.pl
118 lines (98 loc) · 2.73 KB
/
fhemupdate.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/perl
# Copies files from development and
# creates control file for FUIP
use IO::File;
use strict;
use warnings;
#First copy files
my $devdir = 'C:\Users\thorsten\Documents\fhem';
my $gitdir = 'C:\Users\thorsten\Documents\GitDesktop\FHEM-FUIP';
my @filelist1 = (
'FHEM\42_FUIP.pm',
'FHEM\lib\FUIP\*.pm',
'FHEM\lib\FUIP\css\*.*',
'FHEM\lib\FUIP\fonts\*.*',
'FHEM\lib\FUIP\html\*.*',
'FHEM\lib\FUIP\images\*.*',
'FHEM\lib\FUIP\doc\*.*',
'FHEM\lib\FUIP\view-images\*.*',
'FHEM\lib\FUIP\js\*.js',
'FHEM\lib\FUIP\View\*.pm',
'FHEM\lib\FUIP\jquery-ui\*.*',
'FHEM\lib\FUIP\jquery-ui\images\*.*'
);
foreach my $fspec (@filelist1) {
$fspec =~ m,^(.+)\\([^\\]+)$,;
my ($dir,$pattern) = ($1, $2);
my $devpath = "$devdir\\$fspec";
my $gitpath = "$gitdir\\$dir";
my $cmd = "copy $devpath $gitpath";
system($cmd);
};
#Now create command file
my @filelist2 = (
"FHEM/.*.pm",
"FHEM/lib/FUIP/.*.pm",
"FHEM/lib/FUIP/css/.*.css",
"FHEM/lib/FUIP/fonts/.*",
"FHEM/lib/FUIP/html/.*",
"FHEM/lib/FUIP/images/.*",
"FHEM/lib/FUIP/doc/.*",
"FHEM/lib/FUIP/view-images/.*",
"FHEM/lib/FUIP/js/.*.js",
"FHEM/lib/FUIP/View/.*.pm",
"FHEM/lib/FUIP/jquery-ui/.*",
"FHEM/lib/FUIP/jquery-ui/images/.*"
);
# Can't make negative regexp to work, so do it with extra logic
my %skiplist2 = ( );
# Read in the file timestamps
my %filetime2;
my %filesize2;
my %filedir2;
foreach my $fspec (@filelist2) {
$fspec =~ m,^(.+)/([^/]+)$,;
my ($dir,$pattern) = ($1, $2);
my $tdir = $dir;
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];
open(FH, "$dir/$file");
if($file =~ m/.*(png|jpg)$/) {
binmode FH;
};
my $data = join("", <FH>);
close(FH);
$filesize2{"$tdir/$file"} = length($data); # $st[7];
$filedir2{"$tdir/$file"} = $dir;
}
closedir(DH);
}
my %controls = (fuip=>0);
foreach my $k (keys %controls) {
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;
}
}
my $cnt;
foreach my $f (sort keys %filetime2) {
my $fn = $f;
$fn =~ s/.txt$// if($fn =~ m/.pl.txt$/);
foreach my $k (keys %controls) {
my $fh = $controls{$k};
print $fh "UPD $filetime2{$f} $filesize2{$f} $fn\n"
}
}
foreach my $k (keys %controls) {
close $controls{$k};
}