aqua server より ROM を自動取得するためのスクリプトを追加(稲葉@環制)

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2448 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2008-09-08 14:42:34 +00:00
parent d2cc2d32fb
commit f70a9e8fd3
3 changed files with 311 additions and 0 deletions

View File

@ -0,0 +1,55 @@
#!/bin/sh
#! bash -f
#---- commands
LS='/bin/ls'
ECHO='/bin/echo'
HEAD='/bin/head'
FIND='/bin/find'
COPY='/bin/cp'
DATE='/bin/date'
XARGS='/bin/xargs'
MKDIR='/bin/mkdir'
CHDIR='cd'
#---- values
aqua_server='//10.116.1.5'
debug_dir="${aqua_server}/TWL_debug/sysmenu/rom/debug_rom"
redroms="${debug_dir}/sd.roms.template*"
clsbase="${debug_dir}/CLS_base"
datedir=`${DATE} +%Y%m%d`
regions='jp usa euro aus'
#---- call pickup_tad.pl
${ECHO} "===== getting latest apps files ====="
perl ./pickup_tad.pl
#---- gets the latest sd.roms.template roms
#redrom_dir=`${LS} -d --full-time ${redroms} | sort -k 7,10 | tail -n 1`
redrom_dir=`${LS} -dt ${redroms} | ${HEAD} -n 1`
${ECHO} -e "===== getting sd.roms.template* rom files ====="
${ECHO} -e "sd.roms.template dir : ${redrom_dir}"
${ECHO} -e "copy *.(tad|dat|nand) file -> ${datedir} dir\n"
${FIND} ${redrom_dir} -regextype posix-egrep -regex ".*.(tad|dat|nand)" | ${XARGS} ${COPY} -fut ${datedir} > /dev/null
#---- gets the cls base roms
${ECHO} -e "===== getting sd.roms.template* rom files ====="
${ECHO} -e "CLS_base dir : ${clsbase}"
${ECHO} -e "copy *.tad file -> ${datedir} dir"
${FIND} ${clsbase} -name "*.tad" | ${XARGS} ${COPY} -fut ${datedir} > /dev/null
#---- call mkcls.py
${ECHO} -e "===== create forcls dirs ====="
${MKDIR} ${datedir}_forcls
${CHDIR} ${datedir}_forcls
${FIND} ../${datedir} -name "*.tad" -exec ../mkcls.py {} \;
${ECHO} -e "===== copy *.nand *.dat files -> (jp|usa|euro|aus) dirs =====\n"
for region in ${regions}
do
${MKDIR} ${region}
${COPY} ../${datedir}/*.nand ${region}
${COPY} ../${datedir}/*.dat ${region}
done
${COPY} ../cls.sh ./

View File

@ -0,0 +1,146 @@
#!/usr/bin/perl -w -I/usr/local/bin
use File::Copy;
use File::Copy::Recursive qw(fcopy rcopy dircopy);
use Class::Struct;
use POSIX 'strftime';
use File::Find;
require "util.pl";
my @apps = ("download_play",
"full_browser",
"nintendo_spot",
"photo",
"pictchat",
"shop",
"sound",
"sysmenu");
my $flgDate = 0;
my $i;
my $date_dir = "";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $str_today = sprintf("%04d%02d%02d", $year+1900, $mon+1, $mday);
my $flghelp = 0;
my $err;
my @list_tad;
for ($i = 0; $i < $#ARGV+1; $i++) {
my $opt = $ARGV[$i];
if ( $opt eq "-d" ) {
$flgDate = 1;
unless ( $#ARGV <= $i ) {
#$date_dir = $aqua_dir."/SD_".$ARGV[$i+1];
$str_today = $ARGV[$i+1];
$err = [ 1, "Not date (\"$date_dir\") !!"] if ( $date_dir !~ /[0-9]{8}/ );
$i++;
} else {
$err = [1,"No argument after -d !!"];
}
} elsif ( $opt eq "-h" ) {
&show_help;
exit 0;
} else {
print "Unknown option: $opt\n";
&show_help;
exit 1;
}
do {
print "*** Error *** : $err->[1]";
exit 1;
} if ( $err->[0] );
}
# each application directory
foreach $app ( @apps )
{
my $dir_date;
#$dir_app = sprintf('//Aqua/TWL_debug/%s/rom/tad', $app);
$dir_app = sprintf('//10.116.1.5/TWL_debug/%s/rom/tad', $app);
$dir_app_date = &search_date_dir($dir_app);
print "* $dir_app\n - $dir_app_date\n\n";
find( sub
{
do {
push @list_tad, $File::Find::name }if (/\.tad$/);
}, $dir_app_date
);
#foreach ( @list_tad ) { print " * $_\n"; }
}
#print "Date: $date_dir\n";
# Actually not today
mkdir($str_today);
# copy to the local date directory
foreach ( @list_tad ) {
print("$_\n");
copy($_, $str_today);
}
#
exit 0;
#-----------------------------------------------------------------------
# name : show_help
# function :
#-----------------------------------------------------------------------
sub show_help
{
print <<__MSG_HELP__;
Usage:
\$ perl pickup_tad.pl [-d yyyymmdd]
__MSG_HELP__
}
#-----------------------------------------------------------------------
# name : search_date_dir
# function :
#-----------------------------------------------------------------------
sub search_date_dir
{
my $root_dir;
my $date_dir;
my $prefix = ($#_<1) ? "" : $_[1];
my $full_prefix;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon += 1;
$root_dir = ( $#_ < 0 ) ? "." : $_[0];
$full_prefix = $root_dir."/".$prefix;
$date_dir = $full_prefix.sprintf("%04d%02d%02d", $year, $mon, $mday);
# search directory on going back date
while ( $year >= 2000 ) {
if ( -e "$date_dir" and -d "$date_dir") {
return "$date_dir";
} else {
$mday -= 1;
$date_dir = $full_prefix.sprintf("%04d%02d%02d", $year, $mon, $mday);
}
do {
$mday = 31; # constant
$mon -= 1;
unless ( $mon ) {
$mon = 12;
$year -= 1;
}
} unless ( $mday ) ;
}
print "*** Error *** : Can't find the date directory !!\n";
return 0;
}
__END__

View File

@ -0,0 +1,110 @@
package util;
#-----------------------------------------------------------------------
# name : get_title_version
# function : get the title version from the specified tad file
#-----------------------------------------------------------------------
sub get_title_version {
my $titleVersion = 0 ;
my $cmdPython = "/usr/bin/python.exe";
my $scrpPython = "/usr/local/bin/mkcls.py";
$tad = $_[0];
open(PY, "$cmdPython $scrpPython $tad | ") or die "$!";
$titleVersion = $1 if ( <PY> =~ /([0-9]{1,})/) ;
close(PY);
$titleVersion;
}
#-----------------------------------------------------------------------
# name : get_nlist
# function : get the list of the specified directory except "." and ".."
#-----------------------------------------------------------------------
sub get_nlist {
my $dirname = ( $#_ < 0) ? "." : $_[0];
my @list;
unless ( opendir(DIR, "$dirname") ) {
print "Can't open directory: $dirname\n";
return "";
}
foreach $node ( readdir(DIR) ) {
push(@list, $node) unless ( $node =~ /^\.{1,2}$/ );
}
closedir(DIR);
@list;
}
#-----------------------------------------------------------------------
# name : fecheck
# function : check the specified file existence (Error if no file)
#-----------------------------------------------------------------------
sub fecheck {
my $filename = $_[0];
unless ( -e $filename ) {
print <<ERROR_NO_FILE;
[ # Error] No such file : $filename
ERROR_NO_FILE
return 0;
}
1;
}
#-----------------------------------------------------------------------
# name : fwcheck
# function : check the specified file existence (Warning if no file)
#-----------------------------------------------------------------------
sub fwcheck {
my $filename = $_[0];
unless ( -e $filename ) {
print <<WARN_NO_FILE;
[ = Warn ] No such file : $filename
WARN_NO_FILE
return 0;
}
1;
}
sub get_filebody {
my ($filename_body) = @_;
$filename_body = $1 if ( $filename_body =~ /(.{1,})\.[^.]{1,}$/);
$filename_body;
}
sub get_fileext {
my ($filename_ext) = @_;
$filename_ext = $1 if ( $filename_ext =~ /.{1,}\.([^.]{1,})$/);
$filename_ext;
}
#-----------------------------------------------------------------------
# name : cnv_str2hex
# function : check the specified file existence (Warning if no file)
#-----------------------------------------------------------------------
sub cnv_str2hex {
my $instr = $_[0];
my $outstr = "" ;
my $i;
my $len = ($#_<1) ? 1 : $_[1];
#print (substr($instr, 0, 1));
#print (substr($instr, 1, 1));
for ( $i=0; $i<$len; $i++) {
$outstr .= chr ( (hex(substr($_[0], $i*2, 1))<<4)
| (hex(substr($_[0], $i*2+1, 1)) ) );
#print $outstr."\n";
}
return $outstr;
}
return 1;
__END__