Also build and keep elfs zip file for the release.
[maemo-rb.git] / tools / buildzip.pl
blob6d25a01f8f27cb7c0ef793844779dd9f54f1f0fa
1 #!/usr/bin/perl
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
11 use strict;
13 use File::Copy; # For move() and copy()
14 use File::Find; # For find()
15 use File::Path qw(mkpath rmtree); # For rmtree()
16 use Cwd;
17 use Cwd 'abs_path';
18 use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
20 my $ROOT="..";
22 my $ziptool;
23 my $output;
24 my $verbose;
25 my $install;
26 my $exe;
27 my $target;
28 my $modelname;
29 my $incfonts;
30 my $target_id; # passed in, not currently used
31 my $rbdir; # can be non-.rockbox for special builds
32 my $app;
33 my $mklinks;
35 sub glob_mkdir {
36 my ($dir) = @_;
37 mkpath ($dir, $verbose, 0777);
38 return 1;
41 sub glob_install {
42 my ($_src, $dest, $opts) = @_;
44 unless ($opts) {
45 $opts = "-m 0664";
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;
54 return 1;
57 sub 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);
65 sub 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);
73 sub glob_unlink {
74 my ($pattern) = @_;
75 print "glob_unlink: $pattern\n" if $verbose;
76 foreach my $path (glob($pattern)) {
77 unlink($path);
81 sub 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);
100 sub 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);
113 sub make_install {
114 my ($src, $dest) = @_;
116 my $bindir = $dest;
117 my $libdir = $dest;
118 my $userdir = $dest;
120 my @plugins = ( "games", "apps", "demos", "viewers" );
121 my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" );
122 my @files = ();
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;
133 if ($dest =~ /\/dev\/null/) {
134 die "ERROR: No PREFIX given\n"
137 if ((!$app) && -e $bindir && -e $src && (abs_path($bindir) eq abs_path($src))) {
138 return 1;
141 # binary
142 unless ($exe eq "") {
143 unless (glob_mkdir($bindir)) {
144 return 0;
146 glob_install($exe, $bindir, "-m 0775");
149 # codecs
150 unless (glob_mkdir("$libdir/codecs")) {
151 return 0;
153 glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755");
155 # plugins
156 unless (glob_mkdir("$libdir/rocks")) {
157 return 0;
159 foreach my $t (@plugins) {
160 unless (glob_mkdir("$libdir/rocks/$t")) {
161 return 0;
163 glob_install("$src/rocks/$t/*", "$libdir/rocks/$t", "-m 0755");
166 # rocks/viewers/lua
167 unless (glob_mkdir("$libdir/rocks/viewers/lua")) {
168 return 0;
170 glob_install("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua");
172 # all the rest directories
173 foreach my $t (@userstuff) {
174 unless (glob_mkdir("$userdir/$t")) {
175 return 0;
177 glob_install("$src/$t/*", "$userdir/$t");
180 # wps/ subfolders and bitmaps
181 opendir(DIR, $src . "/wps");
182 @files = readdir(DIR);
183 closedir(DIR);
185 foreach my $_dir (@files) {
186 my $dir = "wps/" . $_dir;
187 if ( -d "$src/$dir" && $_dir !~ /\.\.?/) {
188 unless (glob_mkdir("$userdir/$dir")) {
189 return 0;
191 glob_install("$src/$dir/*", "$userdir/$dir");
195 # rest of the files, excluding the binary
196 opendir(DIR,$src);
197 @files = readdir(DIR);
198 closedir(DIR);
200 foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignnore)/,@files)) {
201 glob_install("$src/$file", "$userdir/");
203 return 1;
206 # Get options
207 GetOptions ( 'r|root=s' => \$ROOT,
208 'z|ziptool:s' => \$ziptool,
209 'm|modelname=s' => \$modelname, # The model name as used in ARCHOS in the root makefile
210 'i|id=s' => \$target_id, # The target id name as used in TARGET_ID in the root makefile
211 'o|output:s' => \$output,
212 'f|fonts=s' => \$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
213 'v|verbose' => \$verbose,
214 'install=s' => \$install, # install destination
215 'rbdir:s' => \$rbdir, # If we want to put in a different directory
216 'l|link' => \$mklinks, # If we want to create links instead of copying files
219 # GetOptions() doesn't remove the params from @ARGV if their value was ""
220 # Thus we use the ":" for those for which we use a default value in case of ""
221 # and assign the default value afterwards
222 if ($ziptool eq '') {
223 $ziptool = "zip -r9";
225 if ($output eq '') {
226 $output = "rockbox.zip"
228 if ($rbdir eq '') {
229 $rbdir = ".rockbox";
232 # Now @ARGV shuold be free of any left-overs GetOptions left
233 ($target, $exe) = @ARGV;
235 my $firmdir="$ROOT/firmware";
236 my $appsdir="$ROOT/apps";
237 my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
239 my $cppdef = $target;
241 sub gettargetinfo {
242 open(GCC, ">gcctemp");
243 # Get the LCD screen depth and graphical status
244 print GCC <<STOP
245 \#include "config.h"
246 #ifdef HAVE_LCD_BITMAP
247 Bitmap: yes
248 Depth: LCD_DEPTH
249 LCD Width: LCD_WIDTH
250 LCD Height: LCD_HEIGHT
251 Icon Width: CONFIG_DEFAULT_ICON_WIDTH
252 Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
253 #endif
254 Codec: CONFIG_CODEC
255 #ifdef HAVE_REMOTE_LCD
256 Remote Depth: LCD_REMOTE_DEPTH
257 Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
258 Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
259 #else
260 Remote Depth: 0
261 #endif
262 #ifdef HAVE_RECORDING
263 Recording: yes
264 #endif
265 STOP
267 close(GCC);
269 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
271 # print STDERR "CMD $c\n";
273 open(TARGET, "$c|");
275 my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w);
276 my ($remote_depth, $remote_icon_h, $remote_icon_w);
277 my ($recording);
278 my $icon_count = 1;
279 while(<TARGET>) {
280 # print STDERR "DATA: $_";
281 if($_ =~ /^Bitmap: (.*)/) {
282 $bitmap = $1;
284 elsif($_ =~ /^Depth: (\d*)/) {
285 $depth = $1;
287 elsif($_ =~ /^LCD Width: (\d*)/) {
288 $width = $1;
290 elsif($_ =~ /^LCD Height: (\d*)/) {
291 $height = $1;
293 elsif($_ =~ /^Icon Width: (\d*)/) {
294 $icon_w = $1;
296 elsif($_ =~ /^Icon Height: (\d*)/) {
297 $icon_h = $1;
299 elsif($_ =~ /^Codec: (\d*)/) {
300 # SWCODEC is 1, the others are HWCODEC
301 $swcodec = ($1 == 1);
303 elsif($_ =~ /^Remote Depth: (\d*)/) {
304 $remote_depth = $1;
306 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
307 $remote_icon_w = $1;
309 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
310 $remote_icon_h = $1;
312 if($_ =~ /^Recording: (.*)/) {
313 $recording = $1;
316 close(TARGET);
317 unlink("gcctemp");
319 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
320 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h);
323 sub filesize {
324 my ($filename)=@_;
325 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
326 $atime,$mtime,$ctime,$blksize,$blocks)
327 = stat($filename);
328 return $size;
331 sub create_failsafefiles {
332 my ($dir, $remote_depth) = @_;
333 my $text = "# Dummy file to allow Rockbox to reset to the default skin config.
334 # Do not edit this file. It's never actually loaded by Rockbox.";
335 open (FOO, ">$dir/wps/rockbox_failsafe.wps");
336 print FOO $text;
337 close(FOO);
338 open (FOO, ">$dir/wps/rockbox_failsafe.sbs");
339 print FOO $text;
340 close(FOO);
341 open (FOO, ">$dir/wps/rockbox_failsafe.fms");
342 print FOO $text;
343 close(FOO);
344 if ($remote_depth) {
345 open (FOO, ">$dir/wps/rockbox_failsafe.rwps");
346 print FOO $text;
347 close(FOO);
348 open (FOO, ">$dir/wps/rockbox_failsafe.rsbs");
349 print FOO $text;
350 close(FOO);
351 open (FOO, ">$dir/wps/rockbox_failsafe.rfms");
352 print FOO $text;
353 close(FOO);
355 open (FOO, ">$dir/themes/rockbox_failsafe.cfg");
356 print FOO <<STOP
357 # This config has been autogenerated to reload the failsafe setup
358 wps: $dir/wps/rockbox_failsafe.wps
359 sbs: $dir/wps/rockbox_failsafe.sbs
360 fms: $dir/wps/rockbox_failsafe.fms
361 STOP
363 if ($remote_depth) {
364 print FOO <<STOP
365 rwps: $dir/wps/rockbox_failsafe.rwps
366 rsbs: $dir/wps/rockbox_failsafe.rsbs
367 rfms: $dir/wps/rockbox_failsafe.rfms
368 STOP
371 print FOO <<STOP
372 statusbar: top
373 font: 08-Schumacher-Clean.fnt
374 foreground color: 000000
375 background color: B6C6E5
376 selector type: bar (inverse)
377 STOP
379 close(FOO);
382 sub buildzip {
383 my ($image, $fonts)=@_;
384 my $libdir = $install;
385 my $temp_dir = ".rockbox";
387 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
389 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
390 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) =
391 &gettargetinfo();
393 # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n";
395 # remove old traces
396 rmtree($temp_dir);
398 glob_mkdir($temp_dir);
400 if(!$bitmap) {
401 # always disable fonts on non-bitmap targets
402 $fonts = 0;
404 if($fonts) {
405 glob_mkdir("$temp_dir/fonts");
406 chdir "$temp_dir/fonts";
407 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
408 print($cmd."\n") if $verbose;
409 system($cmd);
410 chdir("../../");
412 if($fonts < 2) {
413 # fonts-only package, return
414 return;
418 # create the file so the database does not try indexing a folder
419 open(IGNORE, ">$temp_dir/database.ignore") || die "can't open database.ignore";
420 close(IGNORE);
422 glob_mkdir("$temp_dir/langs");
423 glob_mkdir("$temp_dir/rocks");
424 glob_mkdir("$temp_dir/rocks/games");
425 glob_mkdir("$temp_dir/rocks/apps");
426 glob_mkdir("$temp_dir/rocks/demos");
427 glob_mkdir("$temp_dir/rocks/viewers");
429 if ($recording) {
430 glob_mkdir("$temp_dir/recpresets");
433 if($swcodec) {
434 glob_mkdir("$temp_dir/eqs");
436 glob_copy("$ROOT/apps/eqs/*.cfg", "$temp_dir/eqs/"); # equalizer presets
439 glob_mkdir("$temp_dir/wps");
440 glob_mkdir("$temp_dir/themes");
441 if ($bitmap) {
442 open(THEME, ">$temp_dir/themes/rockbox_default_icons.cfg");
443 print THEME <<STOP
444 # this config file was auto-generated to make it
445 # easy to reset the icons back to default
446 iconset: -
447 # taken from apps/gui/icon.c
448 viewers iconset: /$rbdir/icons/viewers.bmp
449 remote iconset: -
450 # taken from apps/gui/icon.c
451 remote viewers iconset: /$rbdir/icons/remote_viewers.bmp
453 STOP
455 close(THEME);
458 glob_mkdir("$temp_dir/codepages");
460 if($bitmap) {
461 system("$ROOT/tools/codepages");
463 else {
464 system("$ROOT/tools/codepages -m");
467 glob_move('*.cp', "$temp_dir/codepages/");
469 if($bitmap && $depth > 1) {
470 glob_mkdir("$temp_dir/backdrops");
473 glob_mkdir("$temp_dir/codecs");
475 find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'apps/codecs');
477 # remove directory again if no codec was copied
478 rmdir("$temp_dir/codecs");
480 find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$temp_dir/rocks/")), 'apps/plugins');
482 # exclude entries for the image file types not supported by the imageviewer for the target.
483 my $viewers = "$ROOT/apps/plugins/viewers.config";
484 my $c="cat $viewers | gcc $cppdef -I. -I$firmdir/export -E -P -include config.h -";
486 open VIEWERS, "$c|" or die "can't open viewers.config";
487 my @viewers = <VIEWERS>;
488 close VIEWERS;
490 open VIEWERS, ">$temp_dir/viewers.config" or
491 die "can't create $temp_dir/viewers.config";
493 foreach my $line (@viewers) {
494 if ($line =~ /([^,]*),([^,]*),/) {
495 my ($ext, $plugin)=($1, $2);
496 my $r = "${plugin}.rock";
497 my $oname;
499 my $dir = $r;
500 my $name;
502 # strip off the last slash and file name part
503 $dir =~ s/(.*)\/(.*)/$1/;
504 # store the file name part
505 $name = $2;
507 # get .ovl name (file part only)
508 $oname = $name;
509 $oname =~ s/\.rock$/.ovl/;
511 # print STDERR "$ext $plugin $dir $name $r\n";
513 if(-e "$temp_dir/rocks/$name") {
514 if($dir ne "rocks") {
515 # target is not 'rocks' but the plugins are always in that
516 # dir at first!
517 move("$temp_dir/rocks/$name", "$temp_dir/rocks/$r");
519 print VIEWERS $line;
521 elsif(-e "$temp_dir/rocks/$r") {
522 # in case the same plugin works for multiple extensions, it
523 # was already moved to the viewers dir
524 print VIEWERS $line;
527 if(-e "$temp_dir/rocks/$oname") {
528 # if there's an "overlay" file for the .rock, move that as
529 # well
530 move("$temp_dir/rocks/$oname", "$temp_dir/rocks/$dir");
534 close VIEWERS;
536 open CATEGORIES, "$ROOT/apps/plugins/CATEGORIES" or
537 die "can't open CATEGORIES";
538 my @rock_targetdirs = <CATEGORIES>;
539 close CATEGORIES;
540 foreach my $line (@rock_targetdirs) {
541 if ($line =~ /([^,]*),(.*)/) {
542 my ($plugin, $dir)=($1, $2);
543 move("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/${plugin}.rock");
544 if(-e "$temp_dir/rocks/${plugin}.ovl") {
545 # if there's an "overlay" file for the .rock, move that as
546 # well
547 move("$temp_dir/rocks/${plugin}.ovl", "$temp_dir/rocks/$dir");
549 if(-e "$temp_dir/rocks/${plugin}.lua") {
550 # if this is a lua script, move it to the appropriate dir
551 move("$temp_dir/rocks/${plugin}.lua", "$temp_dir/rocks/$dir/");
556 glob_unlink("$temp_dir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
558 if ($bitmap) {
559 glob_mkdir("$temp_dir/icons");
560 copy("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$temp_dir/icons/viewers.bmp");
561 if ($remote_depth) {
562 copy("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$temp_dir/icons/remote_viewers.bmp");
566 copy("$ROOT/apps/tagnavi.config", "$temp_dir/");
567 copy("$ROOT/apps/plugins/disktidy.config", "$temp_dir/rocks/apps/");
569 if($bitmap) {
570 copy("$ROOT/apps/plugins/sokoban.levels", "$temp_dir/rocks/games/sokoban.levels"); # sokoban levels
571 copy("$ROOT/apps/plugins/snake2.levels", "$temp_dir/rocks/games/snake2.levels"); # snake2 levels
572 copy("$ROOT/apps/plugins/rockbox-fonts.config", "$temp_dir/rocks/viewers/");
575 if(-e "$temp_dir/rocks/demos/pictureflow.rock") {
576 copy("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
577 "$temp_dir/rocks/demos/pictureflow_emptyslide.bmp");
578 my ($pf_logo);
579 if ($width < 200) {
580 $pf_logo = "pictureflow_logo.100x18x16.bmp";
581 } else {
582 $pf_logo = "pictureflow_logo.193x34x16.bmp";
584 copy("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
585 "$temp_dir/rocks/demos/pictureflow_splash.bmp");
588 create_failsafefiles($temp_dir, $remote_depth);
590 if($image) {
591 # image is blank when this is a simulator
592 if( filesize("rockbox.ucl") > 1000 ) {
593 copy("rockbox.ucl", "$temp_dir/rockbox.ucl"); # UCL for flashing
595 if( filesize("rombox.ucl") > 1000) {
596 copy("rombox.ucl", "$temp_dir/rombox.ucl"); # UCL for flashing
599 # Check for rombox.target
600 if ($image=~/(.*)\.(\w+)$/)
602 my $romfile = "rombox.$2";
603 if (filesize($romfile) > 1000)
605 copy($romfile, "$temp_dir/$romfile");
610 glob_mkdir("$temp_dir/docs");
611 for(("COPYING",
612 "LICENSES",
613 "KNOWN_ISSUES"
614 )) {
615 copy("$ROOT/docs/$_", "$temp_dir/docs/$_.txt");
617 if ($fonts) {
618 copy("$ROOT/docs/profontdoc.txt", "$temp_dir/docs/profontdoc.txt");
620 for(("sample.colours",
621 "sample.icons"
622 )) {
623 copy("$ROOT/docs/$_", "$temp_dir/docs/$_");
626 # Now do the WPS dance
627 if(-d "$ROOT/wps") {
628 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
629 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
630 $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
631 print "wpsbuild: $wps_build_cmd\n" if $verbose;
632 system("$wps_build_cmd");
633 print "wps_build_cmd: done\n" if $verbose;
635 else {
636 print STDERR "No wps module present, can't do the WPS magic!\n";
639 # until buildwps.pl is fixed, manually copy the classic_statusbar theme across
640 mkdir "$temp_dir/wps/classic_statusbar", 0777;
641 glob_copy("$ROOT/wps/classic_statusbar/*.bmp", "$temp_dir/wps/classic_statusbar");
642 if ($swcodec) {
643 if ($depth == 16) {
644 copy("$ROOT/wps/classic_statusbar.sbs", "$temp_dir/wps");
645 } elsif ($depth > 1) {
646 copy("$ROOT/wps/classic_statusbar.grey.sbs", "$temp_dir/wps/classic_statusbar.sbs");
647 } else {
648 copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.sbs");
650 } else {
651 copy("$ROOT/wps/classic_statusbar.112x64x1.sbs", "$temp_dir/wps/classic_statusbar.sbs");
653 if ($remote_depth != $depth) {
654 copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
655 } else {
656 copy("$temp_dir/wps/classic_statusbar.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
658 copy("$temp_dir/wps/rockbox_none.sbs", "$temp_dir/wps/rockbox_none.rsbs");
660 # and the info file
661 copy("rockbox-info.txt", "$temp_dir/rockbox-info.txt");
663 # copy the already built lng files
664 glob_copy('apps/lang/*lng', "$temp_dir/langs/");
666 # copy the .lua files
667 glob_mkdir("$temp_dir/rocks/viewers/lua/");
668 glob_copy('apps/plugins/lua/*.lua', "$temp_dir/rocks/viewers/lua/");
671 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
672 localtime(time);
674 $mon+=1;
675 $year+=1900;
677 #$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
678 #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
680 # made once for all targets
681 sub runone {
682 my ($target, $fonts)=@_;
684 # in the app the the layout is different (no .rockbox, but bin/lib/share)
685 $app = ($modelname eq "application");
686 unless ($app) {
687 #rbdir starts with '/', strip it
688 $rbdir = substr($rbdir, 1);
691 # build a full install .rockbox ($rbdir) directory
692 buildzip($target, $fonts);
694 unlink($output);
696 if($fonts == 1) {
697 # Don't include image file in fonts-only package
698 undef $target;
700 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
701 # On some targets, the image goes into .rockbox.
702 copy("$target", ".rockbox/$target");
703 undef $target;
706 if($install) {
707 if($mklinks) {
708 my $cwd = getcwd();
709 symlink("$cwd/.rockbox", "$install/.rockbox");
710 print "link .rockbox $install\n" if $verbose;
711 } else {
712 make_install(".rockbox", $install) or die "MKDIRFAILED\n";
713 rmtree(".rockbox");
714 print "rm .rockbox\n" if $verbose;
717 else {
718 unless (".rockbox" eq $rbdir) {
719 mkpath($rbdir);
720 rmtree($rbdir);
721 move(".rockbox", $rbdir);
722 print "mv .rockbox $rbdir\n" if $verbose;
724 system("$ziptool $output $rbdir $target >/dev/null");
725 print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose;
726 rmtree("$rbdir");
727 print "rm $rbdir\n" if $verbose;
731 if(!$exe) {
732 # not specified, guess!
733 if($target =~ /(recorder|ondio)/i) {
734 $exe = "ajbrec.ajz";
736 elsif($target =~ /iriver/i) {
737 $exe = "rockbox.iriver";
739 else {
740 $exe = "archos.mod";
743 elsif(($exe =~ /rockboxui/)) {
744 # simulator, exclude the exe file
745 $exe = "";
747 elsif($exe eq "librockbox.so") {
748 # android, exclude the binary
749 $exe="";
752 runone($exe, $incfonts);