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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
#!/usr/bin/perl
$ROOT="..";
if($ARGV[0] eq "-r") {
$ROOT=$ARGV[1];
shift @ARGV;
shift @ARGV;
}
my $verbose;
if($ARGV[0] eq "-v") {
$verbose =1;
shift @ARGV;
}
sub filesize {
my ($filename)=@_;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
return $size;
}
sub buildlangs {
my ($outputlang)=@_;
my $dir = "$ROOT/apps/lang";
opendir(DIR, $dir);
my @files = grep { /\.lang$/ } readdir(DIR);
closedir(DIR);
for(@files) {
my $output = $_;
$output =~ s/(.*)\.lang/$1.lng/;
print "lang $_\n" if($verbose);
system ("$ROOT/tools/binlang $dir/english.lang $dir/$_ $outputlang/$output >/dev/null 2>&1");
}
}
sub buildzip {
my ($zip, $image, $notplayer)=@_;
# remove old traces
`rm -rf .rockbox`;
mkdir ".rockbox", 0777;
mkdir ".rockbox/langs", 0777;
mkdir ".rockbox/rocks", 0777;
mkdir ".rockbox/codecs", 0777;
`find apps -name "*.codec" ! -empty | xargs --replace=foo cp foo .rockbox/codecs/`;
`find apps -name "*.rock" -o -name "*.ovl" ! -empty ! -name "codec*.rock" | xargs --replace=foo cp foo .rockbox/rocks/`;
open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
die "can't open viewers.config";
@viewers = <VIEWERS>;
close VIEWERS;
open VIEWERS, ">.rockbox/viewers.config" or
die "can't create .rockbox/viewers.config";
mkdir ".rockbox/viewers", 0777;
for (@viewers) {
if (/,(.+).rock,/) {
my $r = "$1.rock";
my $o = "$1.ovl";
if(-e ".rockbox/rocks/$r") {
`mv .rockbox/rocks/$r .rockbox/viewers`;
print VIEWERS $_;
}
elsif(-e ".rockbox/viewers/$r") {
# in case the same plugin works for multiple extensions, it
# was already moved to the viewers dir
print VIEWERS $_;
}
if(-e ".rockbox/rocks/$o") {
# if there's an "overlay" file for the .rock, move that as
# well
`mv .rockbox/rocks/$o .rockbox/viewers`;
}
}
}
close VIEWERS;
if($notplayer) {
`cp $ROOT/apps/plugins/sokoban.levels .rockbox/rocks/`; # sokoban levels
`cp $ROOT/apps/plugins/snake2.levels .rockbox/rocks/`; # snake2 levels
mkdir ".rockbox/fonts", 0777;
opendir(DIR, "$ROOT/fonts") || die "can't open dir fonts";
my @fonts = grep { /\.bdf$/ && -f "$ROOT/fonts/$_" } readdir(DIR);
closedir DIR;
my $maxfont;
open(HEADER, "<$ROOT/firmware/export/font.h");
while(<HEADER>) {
if(/^\#define MAX_FONT_SIZE[ \t]*(\d+)/) {
$maxfont = $1;
}
}
close(HEADER);
die "no decent max font size" if ($maxfont < 2000);
for(@fonts) {
my $f = $_;
print "FONT: $f\n" if($verbose);
my $o = $f;
$o =~ s/\.bdf/\.fnt/;
my $cmd ="$ROOT/tools/convbdf -s 32 -l 255 -f -o \".rockbox/fonts/$o\" \"$ROOT/fonts/$f\" >/dev/null 2>&1";
print "CMD: $cmd\n" if($verbose);
`$cmd`;
# no need to add fonts we cannot load anyway
my $fontsize = filesize(".rockbox/fonts/$o");
if($fontsize > $maxfont) {
unlink(".rockbox/fonts/$o");
}
}
}
if($image) {
# image is blank when this is a simulator
if( filesize("rockbox.ucl") > 1000 ) {
`cp rockbox.ucl .rockbox/`; # UCL for flashing
}
if( filesize("rombox.ucl") > 1000) {
`cp rombox.ucl .rockbox/`; # UCL for flashing
}
}
mkdir ".rockbox/docs", 0777;
for(("BATTERY-FAQ",
"CUSTOM_CFG_FORMAT",
"CUSTOM_WPS_FORMAT",
"FAQ",
"NODO",
"TECH")) {
`cp $ROOT/docs/$_ .rockbox/docs/$_.txt`;
}
# now copy the file made for reading on the unit:
#if($notplayer) {
# `cp $webroot/docs/Help-JBR.txt .rockbox/docs/`;
#}
#else {
# `cp $webroot/docs/Help-Stu.txt .rockbox/docs/`;
#}
buildlangs(".rockbox/langs");
`rm -f $zip`;
`find .rockbox | zip $zip -@ >/dev/null`;
if($image) {
`zip $zip $image`;
}
# remove the .rockbox afterwards
`rm -rf .rockbox`;
}
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$mon+=1;
$year+=1900;
$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
# made once for all targets
sub runone {
my ($type, $target)=@_;
# build a full install zip file
buildzip("rockbox.zip", $target,
($type eq "player")?0:1);
};
my $target = $ARGV[0];
my $exe = $ARGV[1];
if(!$exe) {
# not specified, guess!
if($target =~ /(recorder|ondio)/i) {
$exe = "ajbrec.ajz";
}
elsif($target =~ /iriver/i) {
$exe = "rockbox.iriver";
}
elsif($target =~ /gmini/i) {
$exe = "rockbox.gmini";
}
else {
$exe = "archos.mod";
}
}
elsif($exe =~ /rockboxui/) {
# simulator, exclude the exe file
$exe = "";
}
if($target =~ /player/i) {
runone("player", $exe);
}
else {
runone("recorder", $exe);
}
|