remove display-leftovers and remove the memory size question for iRiver
[kugel-rb.git] / tools / buildzip.pl
blob817d063f4de2527677473f8aca86a95871f11cd7
1 #!/usr/bin/perl
3 $ROOT="..";
5 if($ARGV[0] eq "-r") {
6 $ROOT=$ARGV[1];
7 shift @ARGV;
8 shift @ARGV;
11 my $verbose;
12 if($ARGV[0] eq "-v") {
13 $verbose =1;
14 shift @ARGV;
18 sub filesize {
19 my ($filename)=@_;
20 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
21 $atime,$mtime,$ctime,$blksize,$blocks)
22 = stat($filename);
23 return $size;
26 sub buildlangs {
27 my ($outputlang)=@_;
28 my $dir = "$ROOT/apps/lang";
29 opendir(DIR, $dir);
30 my @files = grep { /\.lang$/ } readdir(DIR);
31 closedir(DIR);
33 for(@files) {
34 my $output = $_;
35 $output =~ s/(.*)\.lang/$1.lng/;
36 print "lang $_\n" if($verbose);
37 system ("$ROOT/tools/binlang $dir/english.lang $dir/$_ $outputlang/$output >/dev/null 2>&1");
41 sub buildzip {
42 my ($zip, $image, $notplayer)=@_;
44 # remove old traces
45 `rm -rf .rockbox`;
47 mkdir ".rockbox", 0777;
48 mkdir ".rockbox/langs", 0777;
49 mkdir ".rockbox/rocks", 0777;
50 `find . -name "*.rock" ! -empty | xargs --replace=foo cp foo .rockbox/rocks/`;
52 open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
53 die "can't open viewers.config";
54 @viewers = <VIEWERS>;
55 close VIEWERS;
57 open VIEWERS, ">.rockbox/viewers.config" or
58 die "can't create .rockbox/viewers.config";
59 mkdir ".rockbox/viewers";
60 for (@viewers) {
61 if (/,(.+),/) {
62 if(-e ".rockbox/rocks/$1") {
63 `mv .rockbox/rocks/$1 .rockbox/viewers`;
64 print VIEWERS $_;
68 close VIEWERS;
70 if($notplayer) {
71 `cp $ROOT/apps/plugins/sokoban.levels .rockbox/`; # sokoban levels
72 `cp $ROOT/apps/plugins/snake2.levels .rockbox/`; # snake2 levels
74 mkdir ".rockbox/fonts", 0777;
76 opendir(DIR, "$ROOT/fonts") || die "can't open dir fonts";
77 my @fonts = grep { /\.bdf$/ && -f "$ROOT/fonts/$_" } readdir(DIR);
78 closedir DIR;
80 my $maxfont;
81 open(HEADER, "<$ROOT/firmware/export/font.h");
82 while(<HEADER>) {
83 if(/^\#define MAX_FONT_SIZE[ \t]*(\d+)/) {
84 $maxfont = $1;
87 close(HEADER);
88 die "no decent max font size" if ($maxfont < 2000);
90 for(@fonts) {
91 my $f = $_;
93 print "FONT: $f\n" if($verbose);
94 my $o = $f;
95 $o =~ s/\.bdf/\.fnt/;
96 my $cmd ="$ROOT/tools/convbdf -s 32 -l 255 -f -o \".rockbox/fonts/$o\" \"$ROOT/fonts/$f\" >/dev/null 2>&1";
97 print "CMD: $cmd\n" if($verbose);
98 `$cmd`;
100 # no need to add fonts we cannot load anyway
101 my $fontsize = filesize(".rockbox/fonts/$o");
102 if($fontsize > $maxfont) {
103 unlink(".rockbox/fonts/$o");
107 if($image) {
108 # image is blank when this is a simulator
109 if( filesize("rockbox.ucl") > 1000 ) {
110 `cp rockbox.ucl .rockbox/`; # UCL for flashing
112 if( filesize("rombox.ucl") > 1000) {
113 `cp rombox.ucl .rockbox/`; # UCL for flashing
118 mkdir ".rockbox/docs", 0777;
119 for(("BATTERY-FAQ",
120 "CUSTOM_CFG_FORMAT",
121 "CUSTOM_WPS_FORMAT",
122 "FAQ",
123 "NODO",
124 "TECH")) {
125 `cp $ROOT/docs/$_ .rockbox/docs/$_.txt`;
128 # now copy the file made for reading on the unit:
129 #if($notplayer) {
130 # `cp $webroot/docs/Help-JBR.txt .rockbox/docs/`;
132 #else {
133 # `cp $webroot/docs/Help-Stu.txt .rockbox/docs/`;
136 buildlangs(".rockbox/langs");
138 `find .rockbox | zip $zip -@ >/dev/null`;
140 if($image) {
141 `zip $zip $image`;
144 # remove the .rockbox afterwards
145 `rm -rf .rockbox`;
148 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
149 localtime(time);
151 $mon+=1;
152 $year+=1900;
154 $date=sprintf("%04d%02d%02d", $year,$mon, $mday);
155 $shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
157 # made once for all targets
158 sub runone {
159 my ($type, $target)=@_;
161 # build a full install zip file
162 buildzip("rockbox.zip", $target,
163 ($type eq "player")?0:1);
166 my $target = $ARGV[0];
168 my $exe = "";
170 if($target !~ /sim/i) {
171 # not a simulator
172 if($target =~ /(recorder|ondio)/i) {
173 $exe = "ajbrec.ajz";
175 else {
176 $exe = "archos.mod";
180 if($target =~ /player/i) {
181 runone("player", $exe);
183 else {
184 runone("recorder", $exe);