delay load init()
[comingnext] / build.pl
1 #!/usr/bin/perl
2
3 my $version = "1.32";
4
5 use warnings;
6 use strict;
7 use File::Copy;
8 use File::Find;
9 use File::Path;
10 use Archive::Zip qw( :ERROR_CODES );
11
12 # cleanup
13 unlink <*.wgz>;
14 unlink <*.zip>;
15 rmtree("ComingNextB");
16 rmtree("ComingNextC");
17
18 # update version info
19 sed("comingNext/index.html", 'var version = \"(.*?)\";', 'var version = \"'.$version.'\";');
20 sed("comingNext/Info.plist", '<key>DisplayName<\/key>(\s*?)<string>ComingNext (.*?)<\/string>', '<key>DisplayName<\/key>$1<string>ComingNext '.$version.'<\/string>');
21 sed("comingNext/Info.plist", '<key>Version<\/key>(\s*?)<string>(.*?)<\/string>', '<key>Version<\/key>$1<string>'.$version.'<\/string>');
22
23 # add additional widget
24 copyrecursive("comingNext", "comingNextB");
25 sed("comingNextB/index.html", 'var panelNum = 0;', 'var panelNum = 1;');
26 sed("comingNextB/Info.plist", '<key>DisplayName<\/key>(\s*?)<string>ComingNext (.*?)<\/string>', '<key>DisplayName<\/key>$1<string>ComingNext B $2<\/string>');
27 sed("comingNextB/Info.plist", '<key>Identifier<\/key>(\s*?)<string>(.*?)<\/string>', '<key>Identifier<\/key>$1<string>$2b<\/string>');
28
29 # add additional widget
30 copyrecursive("comingNext", "comingNextC");
31 sed("comingNextC/index.html", 'var panelNum = 0;', 'var panelNum = 2;');
32 sed("comingNextC/Info.plist", '<key>DisplayName<\/key>(\s*?)<string>ComingNext (.*?)<\/string>', '<key>DisplayName<\/key>$1<string>ComingNext C $2<\/string>');
33 sed("comingNextC/Info.plist", '<key>Identifier<\/key>(\s*?)<string>(.*?)<\/string>', '<key>Identifier<\/key>$1<string>$2c<\/string>');
34
35 # package release
36 my $zip = Archive::Zip->new();
37 $zip->addTree("ComingNext", "ComingNext");
38 $zip->writeToFileNamed("comingNext.wgz");
39
40 $zip = Archive::Zip->new();
41 $zip->addTree("ComingNextB", "ComingNextB");
42 $zip->writeToFileNamed("comingNextB.wgz");
43
44 $zip = Archive::Zip->new();
45 $zip->addTree("ComingNextC", "ComingNextC");
46 $zip->writeToFileNamed("comingNextC.wgz");
47
48 $zip = Archive::Zip->new();
49 $zip->addFile("comingNext.wgz");
50 $zip->addFile("comingNextB.wgz");
51 $zip->addFile("comingNextC.wgz");
52 $zip->addFile("Readme.txt");
53 $zip->addFile("License.txt");
54 $zip->addFile("ComingNext_SkinFetcher_v1.3.sisx");
55 $zip->writeToFileNamed("comingNext_v$version.zip");
56
57 #########################################
58
59 my $copy_source;
60 my $copy_target;
61 sub copyrecursive {
62 my ($source, $target) = @_;
63 $copy_source = $source;
64 $copy_target = $target;
65 find({ wanted => \&copy_files, follow => 1, no_chdir => 1 }, $copy_source );
66 }
67 sub copy_files {
68 my $targetdir = $File::Find::dir;
69 $targetdir =~ s/^$copy_source/$copy_target/o;
70 mkpath( $targetdir ) if not -e $targetdir;
71 my $targetfile = $File::Find::name;
72 $targetfile =~ s/^$copy_source/$copy_target/o;
73 copy($File::Find::name, $targetfile);
74 }
75
76 #########################################
77
78 sub sed {
79 my ($filename, $search, $replace) = @_;
80 system("perl -p -i.bak -e \"s/$search/$replace/;\" $filename");
81 unlink <$filename.bak>;
82 }