A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#!/usr/bin/perl
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10
11use strict;
12
13use File::Copy; # For move() and copy()
14use File::Find; # For find()
15use File::Path qw(mkpath rmtree); # For rmtree()
16use Cwd;
17use Cwd 'abs_path';
18use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
19
20my $ROOT="..";
21
22my $ziptool;
23my $output;
24my $verbose;
25my $install;
26my $exe;
27my $target;
28my $modelname;
29my $incfonts;
30my $target_id; # passed in, not currently used
31my $rbdir; # can be non-.rockbox for special builds
32my $app;
33my $mklinks;
34
35sub glob_mkdir {
36 my ($dir) = @_;
37 mkpath ($dir, $verbose, 0777);
38 return 1;
39}
40
41sub glob_install {
42 my ($_src, $dest, $opts) = @_;
43
44 unless ($opts) {
45 $opts = "-m 0664";
46 }
47
48 foreach my $src (glob($_src)) {
49 unless ( -d $src || !(-e $src)) {
50 system("install $opts \"$src\" \"$dest\"");
51 print "install $opts \"$src\" -> \"$dest\"\n" if $verbose;
52 }
53 }
54 return 1;
55}
56
57sub glob_copy {
58 my ($pattern, $destination) = @_;
59 print "glob_copy: $pattern -> $destination\n" if $verbose;
60 foreach my $path (glob($pattern)) {
61 copy($path, $destination);
62 }
63}
64
65sub glob_move {
66 my ($pattern, $destination) = @_;
67 print "glob_move: $pattern -> $destination\n" if $verbose;
68 foreach my $path (glob($pattern)) {
69 move($path, $destination);
70 }
71}
72
73sub glob_unlink {
74 my ($pattern) = @_;
75 print "glob_unlink: $pattern\n" if $verbose;
76 foreach my $path (glob($pattern)) {
77 unlink($path);
78 }
79}
80
81sub find_copyfile {
82 my ($pattern, $destination) = @_;
83 print "find_copyfile: $pattern -> $destination\n" if $verbose;
84 return sub {
85 my $path = $_;
86 my $source = getcwd();
87 if ($path =~ $pattern && filesize($path) > 0 && !($path =~ /$rbdir/)) {
88 if($mklinks) {
89 print "link $path $destination\n" if $verbose;
90 symlink($source.'/'.$path, $destination.'/'.$path);
91 } else {
92 print "cp $path $destination\n" if $verbose;
93 copy($path, $destination);
94 chmod(0755, $destination.'/'.$path);
95 }
96 }
97 }
98}
99
100sub find_installfile {
101 my ($pattern, $destination) = @_;
102 print "find_installfile: $pattern -> $destination\n" if $verbose;
103 return sub {
104 my $path = $_;
105 if ($path =~ $pattern) {
106 print "FIND_INSTALLFILE: $path\n";
107 glob_install($path, $destination);
108 }
109 }
110}
111
112
113sub make_install {
114 my ($src, $dest) = @_;
115
116 my $bindir = $dest;
117 my $libdir = $dest;
118 my $userdir = $dest;
119
120 my @plugins = ( "games", "apps", "demos", "viewers" );
121 my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" );
122 my @files = ();
123
124 if ($app) {
125 $bindir .= "/bin";
126 $libdir .= "/lib/rockbox";
127 $userdir .= "/share/rockbox";
128 } else {
129 # for non-app builds we expect the prefix to be the dir above .rockbox
130 $bindir .= "/$rbdir";
131 $libdir = $userdir = $bindir;
132 }
133 if ($dest =~ /\/dev\/null/) {
134 die "ERROR: No PREFIX given\n"
135 }
136
137 if ((!$app) && -e $bindir && -e $src && (abs_path($bindir) eq abs_path($src))) {
138 return 1;
139 }
140
141 # binary
142 unless ($exe eq "") {
143 unless (glob_mkdir($bindir)) {
144 return 0;
145 }
146 glob_install($exe, $bindir, "-m 0775");
147 }
148
149 # codecs
150 unless (glob_mkdir("$libdir/codecs")) {
151 return 0;
152 }
153 # Android has codecs installed as native libraries so they are not needed
154 # in the zip.
155 if ($modelname !~ /android/) {
156 glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755");
157 }
158
159 # plugins
160 unless (glob_mkdir("$libdir/rocks")) {
161 return 0;
162 }
163 foreach my $t (@plugins) {
164 unless (glob_mkdir("$libdir/rocks/$t")) {
165 return 0;
166 }
167 glob_install("$src/rocks/$t/*", "$libdir/rocks/$t", "-m 0755");
168 }
169
170 if(-e "$src/rocks/games/sgt_puzzles") {
171 unless (glob_mkdir("$libdir/rocks/games/sgt_puzzles")) {
172 return 0;
173 }
174 glob_install("$src/rocks/games/sgt_puzzles/*", "$libdir/rocks/games/sgt_puzzles", "-m 0755");
175 }
176
177 # rocks/viewers/lua
178 unless (glob_mkdir("$libdir/rocks/viewers/lua")) {
179 return 0;
180 }
181 glob_install("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua");
182
183 #lua include scripts
184 if(-e "$ROOT/apps/plugins/lua/include_lua") {
185 unless (glob_mkdir("$libdir/rocks/viewers/lua")) {
186 return 0;
187 }
188 glob_install("$ROOT/apps/plugins/lua/include_lua/*.lua", "$libdir/rocks/viewers/lua");
189 #glob_mkdir("$temp_dir/rocks/viewers/lua");
190 #glob_copy("$ROOT/apps/plugins/lua/include_lua/*.lua", "$temp_dir/rocks/viewers/lua/");
191 }
192
193 #lua example scripts
194 if(-e "$ROOT/apps/plugins/lua_scripts") {
195 unless (glob_mkdir("$libdir/rocks/demos/lua_scripts")) {
196 return 0;
197 }
198 glob_install("$ROOT/apps/plugins/lua_scripts/*.lua", "$libdir/rocks/demos/lua_scripts");
199 #glob_mkdir("$temp_dir/rocks/demos/lua_scripts");
200 #glob_copy("$ROOT/apps/plugins/lua_scripts/*.lua", "$temp_dir/rocks/demos/lua_scripts/");
201 }
202
203 #lua picross puzzles
204 if(-e "$ROOT/apps/plugins/picross") {
205 unless (glob_mkdir("$libdir/rocks/games/.picross")) {
206 return 0;
207 }
208 glob_install("$ROOT/apps/plugins/picross/*.picross", "$libdir/rocks/games/.picross");
209 }
210
211 # all the rest directories
212 foreach my $t (@userstuff) {
213 unless (glob_mkdir("$userdir/$t")) {
214 return 0;
215 }
216 glob_install("$src/$t/*", "$userdir/$t");
217 }
218
219 # wps/ subfolders and bitmaps
220 opendir(DIR, $src . "/wps");
221 @files = readdir(DIR);
222 closedir(DIR);
223
224 foreach my $_dir (@files) {
225 my $dir = "wps/" . $_dir;
226 if ( -d "$src/$dir" && $_dir !~ /\.\.?/) {
227 unless (glob_mkdir("$userdir/$dir")) {
228 return 0;
229 }
230 glob_install("$src/$dir/*", "$userdir/$dir");
231 }
232 }
233
234 # rest of the files, excluding the binary
235 opendir(DIR,$src);
236 @files = readdir(DIR);
237 closedir(DIR);
238
239 foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignore|sh)/,@files)) {
240 glob_install("$src/$file", "$userdir/");
241 }
242 return 1;
243}
244
245# Get options
246GetOptions ( 'r|root=s' => \$ROOT,
247 'z|ziptool:s' => \$ziptool,
248 'm|modelname=s' => \$modelname, # The model name as used in ARCHOS in the root makefile
249 'i|id=s' => \$target_id, # The target id name as used in TARGET_ID in the root makefile
250 'o|output:s' => \$output,
251 'f|fonts=s' => \$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
252 'v|verbose' => \$verbose,
253 'install=s' => \$install, # install destination
254 'rbdir:s' => \$rbdir, # If we want to put in a different directory
255 'l|link' => \$mklinks, # If we want to create links instead of copying files
256 'a|app:s' => \$app, # Is this an Application build?
257 );
258
259# GetOptions() doesn't remove the params from @ARGV if their value was ""
260# Thus we use the ":" for those for which we use a default value in case of ""
261# and assign the default value afterwards
262if ($ziptool eq '') {
263 $ziptool = "zip -r9";
264}
265if ($output eq '') {
266 $output = "rockbox.zip"
267}
268if ($rbdir eq '') {
269 $rbdir = ".rockbox";
270}
271
272# Now @ARGV shuold be free of any left-overs GetOptions left
273($target, $exe) = @ARGV;
274
275my $firmdir="$ROOT/firmware";
276my $appsdir="$ROOT/apps";
277my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
278
279my $cppdef = $target;
280
281sub gettargetinfo {
282 open(GCC, ">gcctemp");
283 # Get the LCD screen depth and graphical status
284 print GCC <<STOP
285\#include "config.h"
286Bitmap: yes
287Depth: LCD_DEPTH
288LCD Width: LCD_WIDTH
289LCD Height: LCD_HEIGHT
290Icon Width: CONFIG_DEFAULT_ICON_WIDTH
291Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
292#ifdef HAVE_REMOTE_LCD
293Remote Depth: LCD_REMOTE_DEPTH
294Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
295Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
296#else
297Remote Depth: 0
298#endif
299#ifdef HAVE_RECORDING
300Recording: yes
301#endif
302STOP
303;
304 close(GCC);
305
306 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
307
308 # print STDERR "CMD $c\n";
309
310 open(TARGET, "$c|");
311
312 my ($bitmap, $width, $height, $depth, $icon_h, $icon_w);
313 my ($remote_depth, $remote_icon_h, $remote_icon_w);
314 my ($recording);
315 my $icon_count = 1;
316 while(<TARGET>) {
317 # print STDERR "DATA: $_";
318 if($_ =~ /^Bitmap: (.*)/) {
319 $bitmap = $1;
320 }
321 elsif($_ =~ /^Depth: (\d*)/) {
322 $depth = $1;
323 }
324 elsif($_ =~ /^LCD Width: (\d*)/) {
325 $width = $1;
326 }
327 elsif($_ =~ /^LCD Height: (\d*)/) {
328 $height = $1;
329 }
330 elsif($_ =~ /^Icon Width: (\d*)/) {
331 $icon_w = $1;
332 }
333 elsif($_ =~ /^Icon Height: (\d*)/) {
334 $icon_h = $1;
335 }
336 elsif($_ =~ /^Remote Depth: (\d*)/) {
337 $remote_depth = $1;
338 }
339 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
340 $remote_icon_w = $1;
341 }
342 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
343 $remote_icon_h = $1;
344 }
345 if($_ =~ /^Recording: (.*)/) {
346 $recording = $1;
347 }
348 }
349 close(TARGET);
350 unlink("gcctemp");
351
352 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
353 $remote_depth, $remote_icon_w, $remote_icon_h);
354}
355
356sub filesize {
357 my ($filename)=@_;
358 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
359 $atime,$mtime,$ctime,$blksize,$blocks)
360 = stat($filename);
361 return $size;
362}
363
364
365sub buildzip {
366 my ($image, $fonts)=@_;
367 my $libdir = $install;
368 my $temp_dir = ".rockbox";
369
370 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
371
372 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
373 $remote_depth, $remote_icon_w, $remote_icon_h) =
374 &gettargetinfo();
375
376 # print "Bitmap: $bitmap\nDepth: $depth\n";
377
378 # remove old traces
379 rmtree($temp_dir);
380
381 glob_mkdir($temp_dir);
382
383 if(!$bitmap) {
384 # always disable fonts on non-bitmap targets
385 $fonts = 0;
386 }
387 if($fonts) {
388 glob_mkdir("$temp_dir/fonts");
389 chdir "$temp_dir/fonts";
390 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
391 print($cmd."\n") if $verbose;
392 system($cmd);
393 copy("$ROOT/fonts/COPYING", "COPYING-fonts.txt");
394 chdir("../../");
395
396 if($fonts < 2) {
397 # fonts-only package, return
398 return;
399 }
400 }
401
402 # create the file so the database indexer skips this folder
403 open(IGNORE, ">$temp_dir/database.ignore") || die "can't open database.ignore";
404 close(IGNORE);
405 # create the file so the talkclip generation skips this folder
406 open(IGNORE, ">$temp_dir/talkclips.ignore") || die "can't open talkclips.ignore";
407 close(IGNORE);
408 # create the file so bookmark generation skips this folder
409 open(IGNORE, ">$temp_dir/bookmark.ignore") || die "can't open bookmark.ignore";
410 close(IGNORE);
411
412 # the samsung ypr0 has a loader script that's needed in the zip
413 if ($modelname =~ /samsungypr[01]/) {
414 glob_copy("$ROOT/utils/ypr0tools/rockbox.sh", "$temp_dir/");
415 }
416 # add .nomedia on Android
417 # in the zip.
418 if ($modelname =~ /android/) {
419 open(NOMEDIA, ">$temp_dir/.nomedia") || die "can't open .nomedia";
420 close(NOMEDIA);
421 }
422 # copy wifi firmware
423 if ($modelname =~ /sansaconnect/) {
424 glob_mkdir("$temp_dir/libertas");
425 glob_copy("$ROOT/firmware/drivers/libertas/firmware/*", "$temp_dir/libertas/");
426 }
427 # add hbmenu shortcut's icon and 3dsx executable
428 if ($modelname =~ /ctru/) {
429 glob_copy("icon.icn", "$temp_dir/");
430 glob_copy("rockbox.3dsx", "$temp_dir/");
431 }
432
433 glob_mkdir("$temp_dir/langs");
434 glob_mkdir("$temp_dir/rocks");
435 glob_mkdir("$temp_dir/rocks/games");
436 glob_mkdir("$temp_dir/rocks/apps");
437 glob_mkdir("$temp_dir/rocks/demos");
438 glob_mkdir("$temp_dir/rocks/viewers");
439
440 if ($recording) {
441 glob_mkdir("$temp_dir/recpresets");
442 }
443
444 glob_mkdir("$temp_dir/eqs");
445 glob_copy("$ROOT/lib/rbcodec/dsp/eqs/*.cfg", "$temp_dir/eqs/"); # equalizer presets
446
447 glob_mkdir("$temp_dir/wps");
448 glob_mkdir("$temp_dir/icons");
449 glob_mkdir("$temp_dir/themes");
450 glob_mkdir("$temp_dir/codepages");
451
452 if($bitmap) {
453 system("$ROOT/tools/codepages");
454 }
455 else {
456 system("$ROOT/tools/codepages -m");
457 }
458
459 glob_move('*.cp', "$temp_dir/codepages/");
460
461 if($bitmap && $depth > 1) {
462 glob_mkdir("$temp_dir/backdrops");
463 }
464
465 glob_mkdir("$temp_dir/codecs");
466
467 # Android has codecs installed as native libraries so they are not needed
468 # in the zip.
469 if ($modelname !~ /android/) {
470 find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'lib/rbcodec/codecs');
471 }
472
473 # remove directory again if no codec was copied
474 rmdir("$temp_dir/codecs");
475
476 find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$temp_dir/rocks/")), 'apps/plugins');
477
478 #lua include scripts
479 if(-e "$ROOT/apps/plugins/lua/include_lua") {
480 glob_mkdir("$temp_dir/rocks/viewers/lua");
481 glob_copy("$ROOT/apps/plugins/lua/include_lua/*.lua", "$temp_dir/rocks/viewers/lua/");
482 }
483
484 #lua example scripts
485 if(-e "$ROOT/apps/plugins/lua_scripts") {
486 glob_mkdir("$temp_dir/rocks/demos/lua_scripts");
487 glob_copy("$ROOT/apps/plugins/lua_scripts/*.lua", "$temp_dir/rocks/demos/lua_scripts/");
488 }
489
490 #lua picross puzzles
491 if(-e "$ROOT/apps/plugins/picross") {
492 glob_mkdir("$temp_dir/rocks/games/.picross");
493 glob_copy("$ROOT/apps/plugins/picross/*.picross", "$temp_dir/rocks/games/.picross/");
494 }
495
496 # exclude entries for the image file types not supported by the imageviewer for the target.
497 my $viewers = "$ROOT/apps/plugins/viewers.config";
498 my $c="cat $viewers | gcc $cppdef -I. -I$firmdir/export -E -P -include config.h -";
499
500 open VIEWERS, "$c|" or die "can't open viewers.config";
501 my @viewers = <VIEWERS>;
502 close VIEWERS;
503
504 open VIEWERS, ">$temp_dir/viewers.config" or
505 die "can't create $temp_dir/viewers.config";
506
507 foreach my $line (@viewers) {
508 if ($line =~ /([^,]*),([^,]*),/) {
509 my ($ext, $plugin)=($1, $2);
510 my $r = "${plugin}.rock";
511 my $oname;
512
513 my $dir = $r;
514 my $name;
515
516 # strip off the last slash and file name part
517 $dir =~ s/(.*)\/(.*)/$1/;
518 # store the file name part
519 $name = $2;
520
521 # get .ovl name (file part only)
522 $oname = $name;
523 $oname =~ s/\.rock$/.ovl/;
524
525 # print STDERR "$ext $plugin $dir $name $r\n";
526
527 if(-e "$temp_dir/rocks/$name") {
528 if($dir ne "rocks") {
529 # target is not 'rocks' but the plugins are always in that
530 # dir at first!
531 move("$temp_dir/rocks/$name", "$temp_dir/rocks/$r");
532 }
533 print VIEWERS $line;
534 }
535 elsif(-e "$temp_dir/rocks/$r") {
536 # in case the same plugin works for multiple extensions, it
537 # was already moved to the viewers dir
538 print VIEWERS $line;
539 }
540
541 if(-e "$temp_dir/rocks/$oname") {
542 # if there's an "overlay" file for the .rock, move that as
543 # well
544 move("$temp_dir/rocks/$oname", "$temp_dir/rocks/$dir");
545 }
546 }
547 }
548 close VIEWERS;
549
550 open CATEGORIES, "$ROOT/apps/plugins/CATEGORIES" or
551 die "can't open CATEGORIES";
552 my @rock_targetdirs = <CATEGORIES>;
553 close CATEGORIES;
554 foreach my $line (@rock_targetdirs) {
555 if ($line =~ /([^,]*),(.*)/) {
556 my ($plugin, $dir)=($1, $2);
557 if($dir eq 'games' and substr(${plugin}, 0, 4) eq "sgt-") {
558 glob_mkdir("$temp_dir/rocks/$dir/sgt_puzzles");
559 move("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/sgt_puzzles/${plugin}.rock");
560 }
561 else {
562 move("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/${plugin}.rock");
563 }
564 if(-e "$temp_dir/rocks/${plugin}.ovl") {
565 # if there's an "overlay" file for the .rock, move that as
566 # well
567 move("$temp_dir/rocks/${plugin}.ovl", "$temp_dir/rocks/$dir");
568 }
569 if(-e "$temp_dir/rocks/${plugin}.lua") {
570 # if this is a lua script, move it to the appropriate dir
571 move("$temp_dir/rocks/${plugin}.lua", "$temp_dir/rocks/$dir/");
572 }
573 }
574 }
575
576 glob_unlink("$temp_dir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
577
578 copy("$ROOT/apps/tagnavi.config", "$temp_dir/");
579 copy("$ROOT/apps/plugins/disktidy.config", "$temp_dir/rocks/apps/");
580
581 if(-e "$temp_dir/rocks/viewers/open_plugins.rock") {
582 my $cwd = getcwd();
583 copy("$cwd/apps/plugins/open_plugins.opx", "$temp_dir/rocks/apps/open_plugins.opx") or
584 print STDERR "Copy failed: $cwd/apps/plugins/open_plugins.opx $!\n";
585 }
586
587 if($bitmap) {
588 copy("$ROOT/apps/plugins/sokoban.levels", "$temp_dir/rocks/games/sokoban.levels"); # sokoban levels
589 copy("$ROOT/apps/plugins/snake2.levels", "$temp_dir/rocks/games/snake2.levels"); # snake2 levels
590 copy("$ROOT/apps/plugins/rockbox-fonts.config", "$temp_dir/rocks/viewers/");
591 # picross files
592 copy("$ROOT/apps/plugins/picross_default.picross", "$temp_dir/rocks/games/picross_default.picross");
593 copy("$ROOT/apps/plugins/bitmaps/native/picross_numbers.bmp",
594 "$temp_dir/rocks/games/picross_numbers.bmp");
595 }
596
597 if(-e "$temp_dir/rocks/demos/pictureflow.rock") {
598 copy("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
599 "$temp_dir/rocks/demos/pictureflow_emptyslide.bmp");
600 my ($pf_logo);
601 if ($width < 200) {
602 $pf_logo = "pictureflow_logo.100x18x16.bmp";
603 } else {
604 $pf_logo = "pictureflow_logo.193x34x16.bmp";
605 }
606 copy("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
607 "$temp_dir/rocks/demos/pictureflow_splash.bmp");
608
609 }
610
611 if($image) {
612 # image is blank when this is a simulator
613 if( filesize("rockbox.ucl") > 1000 ) {
614 copy("rockbox.ucl", "$temp_dir/rockbox.ucl"); # UCL for flashing
615 }
616 if( filesize("rombox.ucl") > 1000) {
617 copy("rombox.ucl", "$temp_dir/rombox.ucl"); # UCL for flashing
618 }
619
620 # Check for rombox.target
621 if ($image=~/(.*)\.(\w+)$/)
622 {
623 my $romfile = "rombox.$2";
624 if (filesize($romfile) > 1000)
625 {
626 copy($romfile, "$temp_dir/$romfile");
627 }
628 }
629 }
630
631 glob_mkdir("$temp_dir/docs");
632 for(("COPYING",
633 "LICENSES",
634 "KNOWN_ISSUES"
635 )) {
636 copy("$ROOT/docs/$_", "$temp_dir/docs/$_.txt");
637 }
638 if ($fonts) {
639 copy("$ROOT/docs/profontdoc.txt", "$temp_dir/docs/profontdoc.txt");
640 }
641 for(("sample.colours",
642 "sample.icons"
643 )) {
644 copy("$ROOT/docs/$_", "$temp_dir/docs/$_");
645 }
646
647 # Now do the WPS dance
648 if(-d "$ROOT/wps") {
649 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
650 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
651 $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
652 print "wpsbuild: $wps_build_cmd\n" if $verbose;
653 system("$wps_build_cmd");
654 print "wps_build_cmd: done\n" if $verbose;
655 }
656 else {
657 print STDERR "No wps module present, can't do the WPS magic!\n";
658 }
659
660 # until buildwps.pl is fixed, manually copy the classic_statusbar theme across
661 mkdir "$temp_dir/wps/classic_statusbar", 0777;
662 glob_copy("$ROOT/wps/classic_statusbar/*.bmp", "$temp_dir/wps/classic_statusbar");
663 if ($depth == 16) {
664 copy("$ROOT/wps/classic_statusbar.sbs", "$temp_dir/wps");
665 } elsif ($depth > 1) {
666 copy("$ROOT/wps/classic_statusbar.grey.sbs", "$temp_dir/wps/classic_statusbar.sbs");
667 } else {
668 copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.sbs");
669 }
670 if ($remote_depth != $depth) {
671 copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
672 } else {
673 copy("$temp_dir/wps/classic_statusbar.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
674 }
675 copy("$temp_dir/wps/rockbox_none.sbs", "$temp_dir/wps/rockbox_none.rsbs");
676
677 # and the info file
678 copy("rockbox-info.txt", "$temp_dir/rockbox-info.txt");
679
680 # copy the already built lng files
681 glob_copy('apps/lang/*.lng', "$temp_dir/langs/");
682 glob_copy('apps/lang/*.zip', "$temp_dir/langs/");
683 # Copy over the Invalid Language fallback stuff
684 glob_copy("$ROOT/apps/lang/Invalid*.talk", "$temp_dir/langs/");
685
686 # Copy over any generated voice/talk clips
687 glob_copy('Invalid*.talk', "$temp_dir/langs/");
688 glob_copy('*.lng.talk', "$temp_dir/langs/");
689 glob_copy('*.voice', "$temp_dir/langs/");
690
691 # copy the .lua files
692 glob_mkdir("$temp_dir/rocks/viewers/lua/");
693 glob_copy('apps/plugins/lua/*.lua', "$temp_dir/rocks/viewers/lua/");
694}
695
696my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
697 localtime(time);
698
699$mon+=1;
700$year+=1900;
701
702#$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
703#$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
704
705# made once for all targets
706sub runone {
707 my ($target, $fonts)=@_;
708
709 # Strip the leading / from $rbdir unless we are installing an application
710 # build - the layout is different (no .rockbox, but bin/lib/share)
711 unless ($app && $install) {
712 $rbdir = substr($rbdir, 1);
713 }
714
715 # build a full install .rockbox ($rbdir) directory
716 buildzip($target, $fonts);
717
718 unlink($output);
719
720 if($fonts == 1) {
721 # Don't include image file in fonts-only package
722 undef $target;
723 }
724 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
725 # On some targets, the image goes into .rockbox.
726 copy("$target", ".rockbox/$target");
727 undef $target;
728 }
729
730 if($install) {
731 if($mklinks) {
732 my $cwd = getcwd();
733 symlink("$cwd/.rockbox", "$install/.rockbox");
734 print "link .rockbox $install\n" if $verbose;
735 } else {
736 make_install(".rockbox", $install) or die "MKDIRFAILED\n";
737 rmtree(".rockbox");
738 print "rm .rockbox\n" if $verbose;
739 }
740 }
741 else {
742 unless (".rockbox" eq $rbdir) {
743 mkpath($rbdir);
744 rmtree($rbdir);
745 move(".rockbox", $rbdir);
746 print "mv .rockbox $rbdir\n" if $verbose;
747 }
748
749 # add hbmenu shortcut and cia file to zip file
750 if ($modelname =~ /ctru/) {
751 move("rockbox.cia", "3ds");
752 copy("$ROOT/packaging/ctru/rockbox.xml", "3ds");
753
754 system("$ziptool -u $output 3ds/rockbox.xml $target >/dev/null");
755 print "$ziptool $output $ROOT/packaging/ctru/rockbox.xml $target >/dev/null\n" if $verbose;
756 system("$ziptool -u $output 3ds/rockbox.cia $target >/dev/null");
757 print "$ziptool $output rockbox.cia $target >/dev/null\n" if $verbose;
758 }
759
760 system("$ziptool $output $rbdir $target >/dev/null");
761 print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose;
762 rmtree("$rbdir");
763 print "rm $rbdir\n" if $verbose;
764 }
765};
766
767if(!$exe) {
768 # not specified, guess!
769 if($target =~ /iriver/i) {
770 $exe = "rockbox.iriver";
771 }
772}
773elsif(($exe =~ /rockboxui/)) {
774 # simulator, exclude the exe file
775 $exe = "";
776}
777elsif($exe eq "librockbox.so") {
778 # android, exclude the binary
779 $exe="";
780}
781
782runone($exe, $incfonts);