d'oh! remove non-binary added binary files
[Rockbox.git] / tools / buildzip.pl
bloba7c8fb64bcecc5d526351cded06381e2bd263ec6
1 #!/usr/bin/perl
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
11 $ROOT="..";
15 my $ziptool="zip";
16 my $output="rockbox.zip";
17 my $verbose;
18 my $exe;
19 my $target;
21 while(1) {
22 if($ARGV[0] eq "-r") {
23 $ROOT=$ARGV[1];
24 shift @ARGV;
25 shift @ARGV;
28 elsif($ARGV[0] eq "-z") {
29 $ziptool=$ARGV[1];
30 shift @ARGV;
31 shift @ARGV;
34 elsif($ARGV[0] eq "-o") {
35 $output=$ARGV[1];
36 shift @ARGV;
37 shift @ARGV;
40 elsif($ARGV[0] eq "-v") {
41 $verbose =1;
42 shift @ARGV;
44 else {
45 $target = $ARGV[0];
46 $exe = $ARGV[1];
47 last;
52 my $firmdir="$ROOT/firmware";
54 my $cppdef = $target;
57 sub filesize {
58 my ($filename)=@_;
59 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
60 $atime,$mtime,$ctime,$blksize,$blocks)
61 = stat($filename);
62 return $size;
65 sub buildlangs {
66 my ($outputlang)=@_;
67 my $dir = "$ROOT/apps/lang";
68 opendir(DIR, $dir);
69 my @files = grep { /\.lang$/ } readdir(DIR);
70 closedir(DIR);
72 for(@files) {
73 my $output = $_;
74 $output =~ s/(.*)\.lang/$1.lng/;
75 print "lang $_\n" if($verbose);
76 system ("$ROOT/tools/binlang $dir/english.lang $dir/$_ $outputlang/$output >/dev/null 2>&1");
80 sub buildzip {
81 my ($zip, $image, $notplayer)=@_;
83 # remove old traces
84 `rm -rf .rockbox`;
86 mkdir ".rockbox", 0777;
87 mkdir ".rockbox/langs", 0777;
88 mkdir ".rockbox/rocks", 0777;
89 if($notplayer) {
90 mkdir ".rockbox/codepages", 0777;
91 mkdir ".rockbox/codecs", 0777;
92 mkdir ".rockbox/wps", 0777;
93 mkdir ".rockbox/themes", 0777;
94 mkdir ".rockbox/backdrops", 0777;
95 mkdir ".rockbox/eqs", 0777;
97 my $c = 'find apps -name "*.codec" ! -empty -exec cp {} .rockbox/codecs/ \; 2>/dev/null';
98 `$c`;
100 system("$ROOT/tools/codepages");
101 my $c = 'find . -name "*.cp" ! -empty -exec mv {} .rockbox/codepages/ \; >/dev/null 2>&1';
102 `$c`;
104 my @call = `find .rockbox/codecs -type f 2>/dev/null`;
105 if(!$call[0]) {
106 # no codec was copied, remove directory again
107 rmdir(".rockbox/codecs");
112 $c= 'find apps "(" -name "*.rock" -o -name "*.ovl" ")" ! -empty -exec cp {} .rockbox/rocks/ \;';
113 print `$c`;
115 open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
116 die "can't open viewers.config";
117 @viewers = <VIEWERS>;
118 close VIEWERS;
120 open VIEWERS, ">.rockbox/viewers.config" or
121 die "can't create .rockbox/viewers.config";
122 mkdir ".rockbox/viewers", 0777;
123 foreach my $line (@viewers) {
124 if ($line =~ /([^,]*),([^,]*),/) {
125 my ($ext, $plugin)=($1, $2);
126 my $r = "${plugin}.rock";
127 my $oname;
129 my $dir = $r;
130 my $name;
132 # strip off the last slash and file name part
133 $dir =~ s/(.*)\/(.*)/$1/;
134 # store the file name part
135 $name = $2;
137 # get .ovl name (file part only)
138 $oname = $name;
139 $oname =~ s/\.rock$/.ovl/;
141 # print STDERR "$ext $plugin $dir $name $r\n";
143 if(-e ".rockbox/rocks/$name") {
144 if($dir ne "rocks") {
145 # target is not 'rocks' but the plugins are always in that
146 # dir at first!
147 `mv .rockbox/rocks/$name .rockbox/$r`;
149 print VIEWERS $line;
151 elsif(-e ".rockbox/$r") {
152 # in case the same plugin works for multiple extensions, it
153 # was already moved to the viewers dir
154 print VIEWERS $line;
157 if(-e ".rockbox/rocks/$oname") {
158 # if there's an "overlay" file for the .rock, move that as
159 # well
160 `mv .rockbox/rocks/$oname .rockbox/$dir`;
164 close VIEWERS;
166 if($notplayer) {
167 `cp $ROOT/apps/plugins/sokoban.levels .rockbox/rocks/`; # sokoban levels
168 `cp $ROOT/apps/plugins/snake2.levels .rockbox/rocks/`; # snake2 levels
170 mkdir ".rockbox/fonts", 0777;
172 opendir(DIR, "$ROOT/fonts") || die "can't open dir fonts";
173 my @fonts = grep { /\.bdf$/ && -f "$ROOT/fonts/$_" } readdir(DIR);
174 closedir DIR;
176 for(@fonts) {
177 my $f = $_;
179 print "FONT: $f\n" if($verbose);
180 my $o = $f;
181 $o =~ s/\.bdf/\.fnt/;
182 my $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$o\" \"$ROOT/fonts/$f\" >/dev/null 2>&1";
183 print "CMD: $cmd\n" if($verbose);
184 `$cmd`;
190 if($image) {
191 # image is blank when this is a simulator
192 if( filesize("rockbox.ucl") > 1000 ) {
193 `cp rockbox.ucl .rockbox/`; # UCL for flashing
195 if( filesize("rombox.ucl") > 1000) {
196 `cp rombox.ucl .rockbox/`; # UCL for flashing
200 mkdir ".rockbox/docs", 0777;
201 for(("COPYING",
202 "LICENSES",
203 )) {
204 `cp $ROOT/docs/$_ .rockbox/docs/$_.txt`;
207 # Now do the WPS dance
208 if(-d "$ROOT/wps") {
209 system("perl $ROOT/wps/wpsbuild.pl -r $ROOT $ROOT/wps/WPSLIST $target");
211 else {
212 print STDERR "No wps module present, can't do the WPS magic!\n";
215 # now copy the file made for reading on the unit:
216 #if($notplayer) {
217 # `cp $webroot/docs/Help-JBR.txt .rockbox/docs/`;
219 #else {
220 # `cp $webroot/docs/Help-Stu.txt .rockbox/docs/`;
223 buildlangs(".rockbox/langs");
225 `rm -f $zip`;
226 `find .rockbox | xargs $ziptool $zip >/dev/null`;
228 if($image) {
229 `$ziptool $zip $image`;
232 # remove the .rockbox afterwards
233 `rm -rf .rockbox`;
236 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
237 localtime(time);
239 $mon+=1;
240 $year+=1900;
242 $date=sprintf("%04d%02d%02d", $year,$mon, $mday);
243 $shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
245 # made once for all targets
246 sub runone {
247 my ($type, $target)=@_;
249 # build a full install zip file
250 buildzip($output, $target,
251 ($type eq "player")?0:1);
254 if(!$exe) {
255 # not specified, guess!
256 if($target =~ /(recorder|ondio)/i) {
257 $exe = "ajbrec.ajz";
259 elsif($target =~ /iriver/i) {
260 $exe = "rockbox.iriver";
262 elsif($target =~ /gmini/i) {
263 $exe = "rockbox.gmini";
265 else {
266 $exe = "archos.mod";
269 elsif($exe =~ /rockboxui/) {
270 # simulator, exclude the exe file
271 $exe = "";
274 if($target =~ /player/i) {
275 runone("player", $exe);
277 else {
278 runone("recorder", $exe);