- Add max rom id option support,

- Change duplicate rom naming: now the first OK and KO roms are not marked duplicate,
- Improve and fix statistics.
This commit is contained in:
agibert 2009-03-29 23:46:42 +00:00
parent dcc023872f
commit 17864a7329

74
nds2rm
View File

@ -5,9 +5,9 @@
# (C) 2009 Arnaud G. Gibert
#-----------------------------------------------------------------------------------------------------------------------------------
# $RCSfile: nds2rm,v $
# $Revision: 1.7 $
# $Revision: 1.8 $
# $Name: $
# $Date: 2009/03/26 09:16:35 $
# $Date: 2009/03/29 23:46:42 $
# $Author: agibert $
#-----------------------------------------------------------------------------------------------------------------------------------
@ -79,12 +79,13 @@ function help_print()
echo "-D|--dsrom: dsrom.lst will be dumped"
echo "-h|--help: print this help and exit"
echo "-V|--version: print the version and exit"
echo "-r|--rebuild: don't trust archive file name (test & correct mode), "
echo "-r|--rebuild: don't trust archive file name (test & correct mode)"
echo " rebuild archives (correct mode)"
echo "-n|--renum: try to renumber archives,"
echo " --list_ok:"
echo " --list_ko:"
echo " --list_miss:"
echo "-m|--max <id>: maximum rom id to load from dat file"
echo "-n|--renum: try to renumber archives"
echo " --list_ok: list roms with ok status"
echo " --list_ko: list roms with ko status"
echo " --list_miss: list missing roms"
echo "-v|--verbose: switch on verbosity"
}
@ -97,7 +98,6 @@ function help_print()
function args_parse()
{
mode="test"
rebuild="no"
renum="no"
@ -105,8 +105,10 @@ function args_parse()
lko="no"
lmiss="no"
verbose="no"
max_idx=9999
tmp_args=$(getopt -o CTDhVrnv --long correct,test,dsrom,help,version,rebuild,renum,list_ok,list_ko,list_miss,verbose -n 'nds_rom_mng' -- "$@")
tmp_args=$(getopt -o CTDhVrm:nv --long correct,test,dsrom,help,version,rebuild,max:,renum,list_ok,list_ko,list_miss,verbose -n 'nds_rom_mng' -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
@ -121,6 +123,7 @@ function args_parse()
-h|--help) mode="exit"; help_print; shift;;
-V|--version) mode="exit"; version_print; shift;;
-r|--rebuild) rebuild="yes"; shift;;
-m|--max) shift; max_idx="$1"; shift;;
-n|--renum) renum="yes"; shift;;
--list_ok) lok="yes"; shift;;
--list_ko) lko="yes"; shift;;
@ -143,6 +146,7 @@ function dat_load()
{
echo "loading dsrom.dat..."
loaded_cnt=0
IFS=';'
while read line
@ -175,6 +179,12 @@ function dat_load()
dat_dup[${idx}]="0"
loaded_cnt=$((${loaded_cnt} + 1))
if [[ ${loaded_cnt} -ge ${max_idx} ]]
then
echo "max rom id reached: skipping loading !"
break;
fi
fi
done < ${NDS_DAT}
}
@ -349,8 +359,8 @@ function mask_get()
function dsrom_dump()
{
i=1
while [[ ${i} -le ${loaded_cnt} ]]
do
if [[ ${dat_status[${i}]} != "?" ]]
@ -660,6 +670,12 @@ function arc_proceed()
id=$1
idx=${id/*(0)/}
if [[ ${idx} -gt ${loaded_cnt} ]]
then
echo "max rom id reached: skipping processing !"
break;
fi
# Get info from dat
title=${dat_title[${idx}]}
@ -884,7 +900,10 @@ function suffix_mng()
ok_cnt=0
ko_cnt=0
dup_cnt=0
ignored_cnt=0
idx_old=0
status_old=""
tmp_file=$(mktemp)
@ -897,15 +916,20 @@ function suffix_mng()
id=$1
idx=${id/*(0)/}
if [[ ${idx} -gt ${loaded_cnt} ]]
then
ignored_cnt=$((${ignored_cnt} + 1))
else
status=${file/* \[/}; status=${status/\] \{*/}
crc=${file/*\] \{/}; crc=${crc/\} \<*/}
fp=${file/*\} \</}; fp=${fp/\>-*/}
dat_dup[${idx}]="${dup_id}"
if [[ ${idx} != ${idx_old} ]]
if [[ ( ${idx} != ${idx_old} ) || ( "${status}" != "${status_old}" ) ]]
then
idx_old=${idx}
status_old=${status}
dup_id=0
file_name="${file/) \[*/}) [${status}] {${crc}} <${fp}>.zip"
@ -927,6 +951,7 @@ function suffix_mng()
print_verbose "moving ${file} to ${file_name}"
arc_mv "${NDS_ROMS_OUT}/${file_name}" "${NDS_ROMS_OUT}/${file}" "${mode}"
fi
found_cnt=$((${found_cnt} + 1))
printf "found: %4d" ${found_cnt}
@ -1012,6 +1037,9 @@ function stats_proceed()
cs_ko_cnt=0
ks_ok_cnt=0
ks_ko_cnt=0
proceeded_cnt=0
missing_cnt=0
while read file
do
@ -1026,8 +1054,20 @@ function stats_proceed()
\rm -f "${STATS_FILE}"
found_cnt=$((${ok_cnt} + ${ko_cnt}))
missing_cnt=$((${loaded_cnt} - ${found_cnt}))
found_cnt=$((${ok_cnt} + ${ko_cnt} + ${dup_cnt} + ${ignored_cnt}))
proceeded_cnt=$((${found_cnt} - ${ignored_cnt}))
i=1
while [[ ${i} -le ${loaded_cnt} ]]
do
if [[ ${dat_status[${i}]} == "?" ]]
then
missing_cnt=$((${missing_cnt} + 1))
fi
i=$(( ${i} + 1 ))
done
}
@ -1053,6 +1093,8 @@ function stats_print()
echo
printf "%4d roms are in dsrom.dat\n" ${loaded_cnt}
printf "%4d roms are found\n" ${found_cnt}
printf "%4d roms are ignored\n" ${ignored_cnt}
printf "%4d roms are proceeded\n" ${proceeded_cnt}
printf "%4d roms are renumbered\n" ${renum_cnt}
printf "%4d roms are duplicated\n" ${dup_cnt}
printf "%4d roms are missing\n" ${missing_cnt}
@ -1080,6 +1122,11 @@ function dsrom_mode()
id=$1
idx=${id/*(0)/}
if [[ ${idx} -gt ${loaded_cnt} ]]
then
break;
fi
# Get info from dat
title=${dat_title[${idx}]}
@ -1169,7 +1216,6 @@ cd ${TMP_DIR}
# Initialise stats variables
loaded_cnt=0
ok_cnt=0
ko_cnt=0
found_cnt=0