mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Rockbox as an application: add get_user_file_path().
For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox). This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local. On the DAPs it's a no-op, returing /.rockbox directly. Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2e7d92fef7
commit
9c0b2479f7
41 changed files with 620 additions and 248 deletions
|
@ -14,6 +14,7 @@ use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DT
|
|||
my $ROOT="..";
|
||||
my $verbose;
|
||||
my $rbdir=".rockbox";
|
||||
my $tempdir=".rockbox";
|
||||
my $wpslist;
|
||||
my $target;
|
||||
my $modelname;
|
||||
|
@ -23,6 +24,7 @@ GetOptions ( 'r|root=s' => \$ROOT,
|
|||
'm|modelname=s' => \$modelname,
|
||||
'v|verbose' => \$verbose,
|
||||
'rbdir=s' => \$rbdir, # If we want to put in a different directory
|
||||
'tempdir=s' => \$tempdir, # override .rockbox temporary dir
|
||||
);
|
||||
|
||||
($wpslist, $target) = @ARGV;
|
||||
|
@ -72,7 +74,7 @@ my $has_remote;
|
|||
if(!$wpslist) {
|
||||
print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
|
||||
"Run this script in the root of the target build, and it will put all the\n",
|
||||
"stuff in $rbdir/wps/\n";
|
||||
"stuff in $tempdir/wps/\n and build the cfg according to $rbdir";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -135,15 +137,15 @@ sub mkdirs
|
|||
{
|
||||
my $wpsdir = $wps;
|
||||
$wpsdir =~ s/\.(r|)wps//;
|
||||
mkdir "$rbdir/wps", 0777;
|
||||
mkdir "$rbdir/themes", 0777;
|
||||
mkdir "$tempdir/wps", 0777;
|
||||
mkdir "$tempdir/themes", 0777;
|
||||
|
||||
if( -d "$rbdir/wps/$wpsdir") {
|
||||
if( -d "$tempdir/wps/$wpsdir") {
|
||||
#print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
mkdir "$rbdir/wps/$wpsdir", 0777;
|
||||
mkdir "$tempdir/wps/$wpsdir", 0777;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +155,7 @@ sub copybackdrop
|
|||
if ($backdrop ne '') {
|
||||
my $dst = $backdrop;
|
||||
$dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
|
||||
my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
|
||||
my $cmd = "cp $ROOT/$backdrop $tempdir/$dst";
|
||||
`$cmd`;
|
||||
}
|
||||
}
|
||||
|
@ -164,19 +166,19 @@ sub copythemefont
|
|||
my $o = $_[0];
|
||||
|
||||
$o =~ s/\.fnt/\.bdf/;
|
||||
mkdir "$rbdir/fonts";
|
||||
my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ";
|
||||
mkdir "$tempdir/fonts";
|
||||
my $cmd ="$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ";
|
||||
`$cmd`;
|
||||
}
|
||||
|
||||
sub copythemeicon
|
||||
{
|
||||
#copy the icon specified by the theme
|
||||
|
||||
if ($iconset ne '') {
|
||||
$iconset =~ s/.rockbox/$rbdir/;
|
||||
$iconset =~ /\/(.*icons\/(.*))/i;
|
||||
`cp $ROOT/icons/$2 $1`;
|
||||
my $tempicon = $tempdir . "/" . $iconset;
|
||||
$iconset = $rbdir . "/" . $iconset;
|
||||
$tempicon =~ /\/.*icons\/(.*)/i;
|
||||
`cp $ROOT/icons/$1 $tempicon`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,9 +187,10 @@ sub copythemeviewericon
|
|||
#copy the viewer icon specified by the theme
|
||||
|
||||
if ($viewericon ne '') {
|
||||
$viewericon =~ s/.rockbox/$rbdir/;
|
||||
$viewericon =~ /\/(.*icons\/(.*))/i;
|
||||
`cp $ROOT/icons/$2 $1`;
|
||||
my $tempviewericon = $tempdir . "/" . $viewericon;
|
||||
$viewericon = $rbdir . "/" . $viewericon;
|
||||
$tempviewericon =~ /\/.*icons\/(.*)/i;
|
||||
`cp $ROOT/icons/$1 $tempviewericon`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,20 +212,20 @@ sub copywps
|
|||
# system("cp $dir/$wps .rockbox/wps/");
|
||||
# check for <name>.WIDTHxHEIGHTxDEPTH.sbs
|
||||
if (-e "$dir/$__sb") {
|
||||
system("cp $dir/$__sb $rbdir/wps/$sbs");
|
||||
system("cp $dir/$__sb $tempdir/wps/$sbs");
|
||||
}
|
||||
# check for <name>.WIDTHxHEIGHTxDEPTH.<model>.sbs and overwrite the
|
||||
# previous sb if needed
|
||||
$__sb = $sbs_prefix . "." . $req_size . "." . $modelname . ".sbs";
|
||||
if (-e "$dir/$__sb") {
|
||||
system("cp $dir/$__sb $rbdir/wps/$sbs");
|
||||
system("cp $dir/$__sb $tempdir/wps/$sbs");
|
||||
}
|
||||
|
||||
if (-e "$dir/$req_t_wps" ) {
|
||||
system("cp $dir/$req_t_wps $rbdir/wps/$wps");
|
||||
system("cp $dir/$req_t_wps $tempdir/wps/$wps");
|
||||
|
||||
} elsif (-e "$dir/$req_g_wps") {
|
||||
system("cp $dir/$req_g_wps $rbdir/wps/$wps");
|
||||
system("cp $dir/$req_g_wps $tempdir/wps/$wps");
|
||||
|
||||
open(WPSFILE, "$dir/$req_g_wps");
|
||||
while (<WPSFILE>) {
|
||||
|
@ -233,12 +236,12 @@ sub copywps
|
|||
if ($#filelist >= 0) {
|
||||
if (-e "$dir/$wps_prefix/$req_size") {
|
||||
foreach $file (@filelist) {
|
||||
system("cp $dir/$wps_prefix/$req_size/$file $rbdir/wps/$wps_prefix/");
|
||||
system("cp $dir/$wps_prefix/$req_size/$file $tempdir/wps/$wps_prefix/");
|
||||
}
|
||||
}
|
||||
elsif (-e "$dir/$wps_prefix") {
|
||||
foreach $file (@filelist) {
|
||||
system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
|
||||
system("cp $dir/$wps_prefix/$file $tempdir/wps/$wps_prefix/");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -265,35 +268,35 @@ sub buildcfg {
|
|||
\# $cfg generated by wpsbuild.pl
|
||||
\# $wps is made by $author
|
||||
\#
|
||||
wps: /$rbdir/wps/$wps
|
||||
wps: $rbdir/wps/$wps
|
||||
MOO
|
||||
;
|
||||
if(defined($sbs)) {
|
||||
if ($sbs eq '') {
|
||||
push @out, "sbs: -\n";
|
||||
} else {
|
||||
push @out, "sbs: /$rbdir/wps/$sbs\n";
|
||||
push @out, "sbs: $rbdir/wps/$sbs\n";
|
||||
}
|
||||
}
|
||||
if(defined($rsbs) && $has_remote) {
|
||||
if ($rsbs eq '') {
|
||||
push @out, "rsbs: -\n";
|
||||
} else {
|
||||
push @out, "rsbs: /$rbdir/wps/$rsbs\n";
|
||||
push @out, "rsbs: $rbdir/wps/$rsbs\n";
|
||||
}
|
||||
}
|
||||
if($font) {
|
||||
if ($font eq '') {
|
||||
push @out, "font: -\n";
|
||||
} else {
|
||||
push @out, "font: /$rbdir/fonts/$font\n";
|
||||
push @out, "font: $rbdir/fonts/$font\n";
|
||||
}
|
||||
}
|
||||
if(defined($remotefont) && $has_remote) {
|
||||
if ($remotefont eq '') {
|
||||
push @out, "remote font: -\n";
|
||||
} else {
|
||||
push @out, "remote font: /$rbdir/fonts/$remotefont\n";
|
||||
push @out, "remote font: $rbdir/fonts/$remotefont\n";
|
||||
}
|
||||
}
|
||||
if($fgcolor && $main_depth > 2) {
|
||||
|
@ -314,7 +317,7 @@ MOO
|
|||
} else {
|
||||
# clip resolution from filename
|
||||
$backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
|
||||
push @out, "backdrop: /$rbdir/$backdrop\n";
|
||||
push @out, "backdrop: $rbdir/$backdrop\n";
|
||||
}
|
||||
}
|
||||
if($lineselectstart && $main_depth > 2) {
|
||||
|
@ -354,7 +357,7 @@ MOO
|
|||
if ($rwps eq '') {
|
||||
push @out, "rwps: -\n";
|
||||
} else {
|
||||
push @out, "rwps: /$rbdir/wps/$rwps\n";
|
||||
push @out, "rwps: $rbdir/wps/$rwps\n";
|
||||
}
|
||||
}
|
||||
if(defined($listviewport)) {
|
||||
|
@ -371,11 +374,11 @@ MOO
|
|||
push @out, "remote ui viewport: $listviewport\n";
|
||||
}
|
||||
}
|
||||
if(-f "$rbdir/wps/$cfg") {
|
||||
if(-f "$tempdir/wps/$cfg") {
|
||||
print STDERR "wpsbuild warning: wps/$cfg already exists!\n";
|
||||
}
|
||||
else {
|
||||
open(CFG, ">$rbdir/themes/$cfg");
|
||||
open(CFG, ">$tempdir/themes/$cfg");
|
||||
print CFG @out;
|
||||
close(CFG);
|
||||
}
|
||||
|
@ -401,6 +404,12 @@ while(<WPS>) {
|
|||
# skip comment
|
||||
next;
|
||||
}
|
||||
|
||||
# prefix $rbdir with / if needed (needed for the theme.cfg)
|
||||
unless ($rbdir =~ /\/.*/) {
|
||||
$rbdir = "/" . $rbdir;
|
||||
}
|
||||
|
||||
if($l =~ /^ *<(r|)wps>/i) {
|
||||
$isrwps = $1;
|
||||
$within = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue