forked from len0rd/rockbox
Fix up buildzip.pl
Now it can install RaaA properly into /usr/local/{bin,lib,share} (incompatible with RaaA in svn, because it needs fixing to work with these dirs).
make install for sim and target builds is also cleaned up a bit.
Additionally, use the install tool for install make targets, it has some advantages over cp.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27407 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f1ff3e0d5e
commit
35ac40712b
1 changed files with 170 additions and 45 deletions
|
|
@ -12,7 +12,7 @@ use strict;
|
||||||
|
|
||||||
use File::Copy; # For move() and copy()
|
use File::Copy; # For move() and copy()
|
||||||
use File::Find; # For find()
|
use File::Find; # For find()
|
||||||
use File::Path; # For rmtree()
|
use File::Path qw(mkpath rmtree); # For rmtree()
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
|
use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
|
||||||
|
|
||||||
|
|
@ -28,8 +28,30 @@ my $modelname;
|
||||||
my $incfonts;
|
my $incfonts;
|
||||||
my $target_id; # passed in, not currently used
|
my $target_id; # passed in, not currently used
|
||||||
my $rbdir=".rockbox"; # can be changed for special builds
|
my $rbdir=".rockbox"; # can be changed for special builds
|
||||||
|
my $app;
|
||||||
|
|
||||||
|
|
||||||
|
sub glob_mkdir {
|
||||||
|
my ($dir) = @_;
|
||||||
|
mkpath ($dir, $verbose, 0777);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub glob_install {
|
||||||
|
my ($_src, $dest, $opts) = @_;
|
||||||
|
|
||||||
|
unless ($opts) {
|
||||||
|
$opts = "-m 0664";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $src (glob($_src)) {
|
||||||
|
unless ( -d $src || !(-e $src)) {
|
||||||
|
system("install $opts \"$src\" \"$dest\"");
|
||||||
|
print "install $opts \"$src\" -> \"$dest\"\n" if $verbose;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sub glob_copy {
|
sub glob_copy {
|
||||||
my ($pattern, $destination) = @_;
|
my ($pattern, $destination) = @_;
|
||||||
|
|
@ -62,11 +84,118 @@ sub find_copyfile {
|
||||||
my $path = $_;
|
my $path = $_;
|
||||||
if ($path =~ $pattern && filesize($path) > 0 && !($path =~ /$rbdir/)) {
|
if ($path =~ $pattern && filesize($path) > 0 && !($path =~ /$rbdir/)) {
|
||||||
copy($path, $destination);
|
copy($path, $destination);
|
||||||
|
print "cp $path $destination\n" if $verbose;
|
||||||
chmod(0755, $destination.'/'.$path);
|
chmod(0755, $destination.'/'.$path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub find_installfile {
|
||||||
|
my ($pattern, $destination) = @_;
|
||||||
|
print "find_installfile: $pattern -> $destination\n" if $verbose;
|
||||||
|
return sub {
|
||||||
|
my $path = $_;
|
||||||
|
if ($path =~ $pattern) {
|
||||||
|
print "FIND_INSTALLFILE: $path\n";
|
||||||
|
glob_install($path, $destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub make_install {
|
||||||
|
my ($src, $dest) = @_;
|
||||||
|
|
||||||
|
my $bindir = $dest;
|
||||||
|
my $libdir = $dest;
|
||||||
|
my $userdir = $dest;
|
||||||
|
|
||||||
|
my @plugins = ( "games", "apps", "demos", "viewers" );
|
||||||
|
my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" );
|
||||||
|
my @files = ();
|
||||||
|
|
||||||
|
if ($app) {
|
||||||
|
$bindir .= "/bin";
|
||||||
|
$libdir .= "/lib/rockbox";
|
||||||
|
$userdir .= "/share/rockbox";
|
||||||
|
} else {
|
||||||
|
# for non-app builds we expect the prefix to be the dir above .rockbox
|
||||||
|
$bindir .= "/.rockbox";
|
||||||
|
$libdir = $userdir = $bindir;
|
||||||
|
}
|
||||||
|
if ($dest =~ /\/dev\/null/) {
|
||||||
|
die "ERROR: No PREFIX given\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!$app) && $src && (abs_path($dest) eq abs_path($src))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# binary
|
||||||
|
unless ($exe eq "") {
|
||||||
|
unless (glob_mkdir($bindir)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install($exe, $bindir, "-m 0775");
|
||||||
|
}
|
||||||
|
|
||||||
|
# codecs
|
||||||
|
unless (glob_mkdir("$libdir/codecs")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install("$src/codecs/*", "$libdir/codecs");
|
||||||
|
|
||||||
|
# plugins
|
||||||
|
unless (glob_mkdir("$libdir/rocks")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
foreach my $t (@plugins) {
|
||||||
|
unless (glob_mkdir("$libdir/rocks/$t")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install("$src/rocks/$t/*", "$libdir/rocks/$t");
|
||||||
|
}
|
||||||
|
|
||||||
|
# rocks/viewers/lua
|
||||||
|
unless (glob_mkdir("$libdir/rocks/viewers/lua")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua");
|
||||||
|
|
||||||
|
# all the rest directories
|
||||||
|
foreach my $t (@userstuff) {
|
||||||
|
unless (glob_mkdir("$userdir/$t")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install("$src/$t/*", "$userdir/$t");
|
||||||
|
}
|
||||||
|
|
||||||
|
# wps/ subfolders and bitmaps
|
||||||
|
opendir(DIR, $src . "/wps");
|
||||||
|
@files = readdir(DIR);
|
||||||
|
closedir(DIR);
|
||||||
|
|
||||||
|
foreach my $_dir (@files) {
|
||||||
|
my $dir = "wps/" . $_dir;
|
||||||
|
if ( -d "$src/$dir" && $_dir !~ /\.\.?/) {
|
||||||
|
unless (glob_mkdir("$userdir/$dir")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
glob_install("$src/$dir/*", "$userdir/$dir");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# rest of the files, excluding the binary
|
||||||
|
opendir(DIR,$src);
|
||||||
|
@files = readdir(DIR);
|
||||||
|
closedir(DIR);
|
||||||
|
|
||||||
|
foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignnore)/,@files)) {
|
||||||
|
glob_install("$src/$file", "$userdir/");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
# Get options
|
# Get options
|
||||||
GetOptions ( 'r|root=s' => \$ROOT,
|
GetOptions ( 'r|root=s' => \$ROOT,
|
||||||
'z|ziptool=s' => \$ziptool,
|
'z|ziptool=s' => \$ziptool,
|
||||||
|
|
@ -179,6 +308,8 @@ sub filesize {
|
||||||
|
|
||||||
sub buildzip {
|
sub buildzip {
|
||||||
my ($image, $fonts)=@_;
|
my ($image, $fonts)=@_;
|
||||||
|
my $libdir = $install;
|
||||||
|
my $rbdir = ".rockbox";
|
||||||
|
|
||||||
print "buildzip: image=$image fonts=$fonts\n" if $verbose;
|
print "buildzip: image=$image fonts=$fonts\n" if $verbose;
|
||||||
|
|
||||||
|
|
@ -191,14 +322,14 @@ sub buildzip {
|
||||||
# remove old traces
|
# remove old traces
|
||||||
rmtree($rbdir);
|
rmtree($rbdir);
|
||||||
|
|
||||||
mkdir $rbdir, 0777;
|
glob_mkdir($rbdir);
|
||||||
|
|
||||||
if(!$bitmap) {
|
if(!$bitmap) {
|
||||||
# always disable fonts on non-bitmap targets
|
# always disable fonts on non-bitmap targets
|
||||||
$fonts = 0;
|
$fonts = 0;
|
||||||
}
|
}
|
||||||
if($fonts) {
|
if($fonts) {
|
||||||
mkdir "$rbdir/fonts", 0777;
|
glob_mkdir("$rbdir/fonts");
|
||||||
chdir "$rbdir/fonts";
|
chdir "$rbdir/fonts";
|
||||||
my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
|
my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
|
||||||
print($cmd."\n") if $verbose;
|
print($cmd."\n") if $verbose;
|
||||||
|
|
@ -215,25 +346,25 @@ sub buildzip {
|
||||||
open(IGNORE, ">$rbdir/database.ignore") || die "can't open database.ignore";
|
open(IGNORE, ">$rbdir/database.ignore") || die "can't open database.ignore";
|
||||||
close(IGNORE);
|
close(IGNORE);
|
||||||
|
|
||||||
mkdir "$rbdir/langs", 0777;
|
glob_mkdir("$rbdir/langs");
|
||||||
mkdir "$rbdir/rocks", 0777;
|
glob_mkdir("$rbdir/rocks");
|
||||||
mkdir "$rbdir/rocks/games", 0777;
|
glob_mkdir("$rbdir/rocks/games");
|
||||||
mkdir "$rbdir/rocks/apps", 0777;
|
glob_mkdir("$rbdir/rocks/apps");
|
||||||
mkdir "$rbdir/rocks/demos", 0777;
|
glob_mkdir("$rbdir/rocks/demos");
|
||||||
mkdir "$rbdir/rocks/viewers", 0777;
|
glob_mkdir("$rbdir/rocks/viewers");
|
||||||
|
|
||||||
if ($recording) {
|
if ($recording) {
|
||||||
mkdir "$rbdir/recpresets", 0777;
|
glob_mkdir("$rbdir/recpresets");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($swcodec) {
|
if($swcodec) {
|
||||||
mkdir "$rbdir/eqs", 0777;
|
glob_mkdir("$rbdir/eqs");
|
||||||
|
|
||||||
glob_copy("$ROOT/apps/eqs/*.cfg", "$rbdir/eqs/"); # equalizer presets
|
glob_copy("$ROOT/apps/eqs/*.cfg", "$rbdir/eqs/"); # equalizer presets
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir "$rbdir/wps", 0777;
|
glob_mkdir("$rbdir/wps");
|
||||||
mkdir "$rbdir/themes", 0777;
|
glob_mkdir("$rbdir/themes");
|
||||||
if ($bitmap) {
|
if ($bitmap) {
|
||||||
open(THEME, ">$rbdir/themes/rockbox_default_icons.cfg");
|
open(THEME, ">$rbdir/themes/rockbox_default_icons.cfg");
|
||||||
print THEME <<STOP
|
print THEME <<STOP
|
||||||
|
|
@ -251,7 +382,7 @@ STOP
|
||||||
close(THEME);
|
close(THEME);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir "$rbdir/codepages", 0777;
|
glob_mkdir("$rbdir/codepages");
|
||||||
|
|
||||||
if($bitmap) {
|
if($bitmap) {
|
||||||
system("$ROOT/tools/codepages");
|
system("$ROOT/tools/codepages");
|
||||||
|
|
@ -262,18 +393,17 @@ STOP
|
||||||
|
|
||||||
glob_move('*.cp', "$rbdir/codepages/");
|
glob_move('*.cp', "$rbdir/codepages/");
|
||||||
|
|
||||||
if($bitmap) {
|
if($bitmap && $depth > 1) {
|
||||||
mkdir "$rbdir/codecs", 0777;
|
glob_mkdir("$rbdir/backdrops");
|
||||||
if($depth > 1) {
|
|
||||||
mkdir "$rbdir/backdrops", 0777;
|
|
||||||
}
|
|
||||||
|
|
||||||
find(find_copyfile(qr/.*\.codec/, abs_path("$rbdir/codecs/")), 'apps/codecs');
|
|
||||||
|
|
||||||
# remove directory again if no codec was copied
|
|
||||||
rmdir("$rbdir/codecs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glob_mkdir("$rbdir/codecs");
|
||||||
|
|
||||||
|
find(find_copyfile(qr/.*\.codec/, abs_path("$rbdir/codecs/")), 'apps/codecs');
|
||||||
|
|
||||||
|
# remove directory again if no codec was copied
|
||||||
|
rmdir("$rbdir/codecs");
|
||||||
|
|
||||||
find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$rbdir/rocks/")), 'apps/plugins');
|
find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$rbdir/rocks/")), 'apps/plugins');
|
||||||
|
|
||||||
open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
|
open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
|
||||||
|
|
@ -350,7 +480,7 @@ STOP
|
||||||
glob_unlink("$rbdir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
|
glob_unlink("$rbdir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
|
||||||
|
|
||||||
if ($bitmap) {
|
if ($bitmap) {
|
||||||
mkdir "$rbdir/icons", 0777;
|
glob_mkdir("$rbdir/icons");
|
||||||
copy("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$rbdir/icons/viewers.bmp");
|
copy("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$rbdir/icons/viewers.bmp");
|
||||||
if ($remote_depth) {
|
if ($remote_depth) {
|
||||||
copy("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$rbdir/icons/remote_viewers.bmp");
|
copy("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$rbdir/icons/remote_viewers.bmp");
|
||||||
|
|
@ -400,7 +530,7 @@ STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir "$rbdir/docs", 0777;
|
glob_mkdir("$rbdir/docs");
|
||||||
for(("COPYING",
|
for(("COPYING",
|
||||||
"LICENSES",
|
"LICENSES",
|
||||||
"KNOWN_ISSUES"
|
"KNOWN_ISSUES"
|
||||||
|
|
@ -458,7 +588,7 @@ STOP
|
||||||
glob_copy('apps/lang/*lng', "$rbdir/langs/");
|
glob_copy('apps/lang/*lng', "$rbdir/langs/");
|
||||||
|
|
||||||
# copy the .lua files
|
# copy the .lua files
|
||||||
mkdir "$rbdir/rocks/viewers/lua/", 0777;
|
glob_mkdir("$rbdir/rocks/viewers/lua/");
|
||||||
glob_copy('apps/plugins/lua/*.lua', "$rbdir/rocks/viewers/lua/");
|
glob_copy('apps/plugins/lua/*.lua', "$rbdir/rocks/viewers/lua/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -475,6 +605,8 @@ $year+=1900;
|
||||||
sub runone {
|
sub runone {
|
||||||
my ($target, $fonts)=@_;
|
my ($target, $fonts)=@_;
|
||||||
|
|
||||||
|
$app = ($modelname eq "application");
|
||||||
|
|
||||||
# build a full install .rockbox ($rbdir) directory
|
# build a full install .rockbox ($rbdir) directory
|
||||||
buildzip($target, $fonts);
|
buildzip($target, $fonts);
|
||||||
|
|
||||||
|
|
@ -491,30 +623,23 @@ sub runone {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
print "$ziptool $output $rbdir $target >/dev/null\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $samedir = 0; # is the destination dir equal to source dir ?
|
my $samedir = 1; # is the destination dir equal to source dir ?
|
||||||
|
|
||||||
if($install) {
|
if($install) {
|
||||||
if ($install =~ /\/dev\/null/) {
|
make_install(".rockbox", $install) or die "MKDIRFAILED\n";
|
||||||
die "ERROR: No PREFIX given\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
$samedir = abs_path("$install/$rbdir") eq abs_path($rbdir);
|
|
||||||
|
|
||||||
if (!$samedir) {
|
|
||||||
system("mkdir -p \"$install\" && cp -r $rbdir \"$install/\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
unless (".rockbox" eq $rbdir) {
|
||||||
|
move(".rockbox", $rbdir);
|
||||||
|
print "mv .rockbox $rbdir\n" if $verbose;
|
||||||
|
}
|
||||||
system("$ziptool $output $rbdir $target >/dev/null");
|
system("$ziptool $output $rbdir $target >/dev/null");
|
||||||
|
print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose;
|
||||||
}
|
}
|
||||||
|
rmtree(".rockbox");
|
||||||
# remove the $rbdir afterwards
|
print "rm .rockbox\n" if $verbose;
|
||||||
if (!$samedir) {
|
|
||||||
rmtree($rbdir);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!$exe) {
|
if(!$exe) {
|
||||||
|
|
@ -529,7 +654,7 @@ if(!$exe) {
|
||||||
$exe = "archos.mod";
|
$exe = "archos.mod";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif($exe =~ /rockboxui/) {
|
elsif(($exe =~ /rockboxui/)) {
|
||||||
# simulator, exclude the exe file
|
# simulator, exclude the exe file
|
||||||
$exe = "";
|
$exe = "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue