- Add -i (--repo_in), -o (--repo_out), -j (--jobs) and -c (--compressor) options,
- Add initial info print out, - slight code cleanup.
This commit is contained in:
		
							parent
							
								
									209ce90b81
								
							
						
					
					
						commit
						33c4b9a7c0
					
				
							
								
								
									
										295
									
								
								nds2rm
									
									
									
									
									
								
							
							
						
						
									
										295
									
								
								nds2rm
									
									
									
									
									
								
							| @ -5,9 +5,9 @@ | |||||||
| # (C) 2009 Arnaud G. Gibert | # (C) 2009 Arnaud G. Gibert | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
| # $RCSfile: nds2rm,v $ | # $RCSfile: nds2rm,v $ | ||||||
| # $Revision: 1.13 $ | # $Revision: 1.14 $ | ||||||
| # $Name:  $ | # $Name:  $ | ||||||
| # $Date: 2009/04/11 21:12:28 $ | # $Date: 2009/04/11 22:57:02 $ | ||||||
| # $Author: agibert $ | # $Author: agibert $ | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| @ -31,33 +31,6 @@ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # User Config |  | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- |  | ||||||
| 
 |  | ||||||
| # Path Config |  | ||||||
| #NDS_REPOSITORY_IN=/opt/public/nds |  | ||||||
| NDS_REPOSITORY_IN=/opt/public/nds.new |  | ||||||
| #NDS_REPOSITORY_IN=/opt/public/nds.new/nds.old |  | ||||||
| #NDS_REPOSITORY_IN=/opt/public/nds.new/nds.new |  | ||||||
| NDS_REPOSITORY_OUT=/opt/public/nds.new |  | ||||||
| #NDS_REPOSITORY_OUT=/opt/public/nds.new/nds.new |  | ||||||
| NDS_ROMS_IN=${NDS_REPOSITORY_IN}/roms |  | ||||||
| NDS_ROMS_OUT=${NDS_REPOSITORY_OUT}/roms |  | ||||||
| NDS_XML=${NDS_REPOSITORY_IN}/misc/dsrom.xml |  | ||||||
| 
 |  | ||||||
| # Job Parallelisation |  | ||||||
| JOB_NB=8 |  | ||||||
| 
 |  | ||||||
| # Compressor (zip, rar or 7z) |  | ||||||
| #COMPRESSOR=zip |  | ||||||
| #COMPRESSOR=rar |  | ||||||
| COMPRESSOR=7z |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| # System Constants | # System Constants | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| @ -65,30 +38,9 @@ STATS_FILE="stats.txt" | |||||||
| 
 | 
 | ||||||
| TMP_DIR=$(mktemp -d) | TMP_DIR=$(mktemp -d) | ||||||
| 
 | 
 | ||||||
| case "${COMPRESSOR}" |  | ||||||
| in |  | ||||||
|     (zip) |  | ||||||
|         CSFX=zip |  | ||||||
|     ;; |  | ||||||
| 
 |  | ||||||
|     (rar) |  | ||||||
|         CSFX=rar |  | ||||||
|     ;; |  | ||||||
| 
 |  | ||||||
|     (7z) |  | ||||||
|         CSFX=7z |  | ||||||
|     ;; |  | ||||||
| 
 |  | ||||||
|     (*) |  | ||||||
|         echo "Error: unsuported compressor: ${COMPRESSOR} !" |  | ||||||
| 	exit 1 |  | ||||||
|     ;; |  | ||||||
| esac |  | ||||||
| 
 |  | ||||||
| NDS_VERSION="$Name:  $" | NDS_VERSION="$Name:  $" | ||||||
| 
 | 
 | ||||||
| RNFH_REGEX=".... - .* \(.*:.*\) \[..\] \{........} <....>[-]*[0-9]*\.${CSFX}$" | # Region Table | ||||||
| 
 |  | ||||||
|       reg_tab[0]="E";   # Europe  |       reg_tab[0]="E";   # Europe  | ||||||
|       reg_tab[1]="U";   # USA  |       reg_tab[1]="U";   # USA  | ||||||
|       reg_tab[2]="G";   # Germany  |       reg_tab[2]="G";   # Germany  | ||||||
| @ -119,6 +71,7 @@ RNFH_REGEX=".... - .* \(.*:.*\) \[..\] \{........} <....>[-]*[0-9]*\.${CSFX}$" | |||||||
|      reg_tab[27]="R";   # Russia  |      reg_tab[27]="R";   # Russia  | ||||||
|      reg_tab[28]="Gr";  # Greece  |      reg_tab[28]="Gr";  # Greece  | ||||||
| 
 | 
 | ||||||
|  | # Language Table | ||||||
|      lang_tab[1]="Fr";  # French |      lang_tab[1]="Fr";  # French | ||||||
|      lang_tab[2]="En";  # English |      lang_tab[2]="En";  # English | ||||||
|      lang_tab[4]="Zh";  # Chinese |      lang_tab[4]="Zh";  # Chinese | ||||||
| @ -162,19 +115,30 @@ function version_print() | |||||||
| 
 | 
 | ||||||
| function help_print() | function help_print() | ||||||
| { | { | ||||||
|     echo "-C|--correct:   output repository will be corrected" |     echo "Path options:" | ||||||
|     echo "-T|--test:      input repository will be tested (default)" |     echo "-i | --repo_in  <path>:   input  repository path                  (default: ${nds_repository_in})" | ||||||
|     echo "-D|--dsrom:     dsrom.lst will be dumped" |     echo "-o | --repo_out <path>:   output repository path                  (default: ${nds_repository_out})" | ||||||
|     echo "-h|--help:      print this help and exit" |     echo "" | ||||||
|     echo "-V|--version:   print the version and exit" |     echo "Mode selection" | ||||||
|     echo "-r|--rebuild:   don't trust archive file name (test & correct mode)" |     echo "-C | --correct:           corect output repository" | ||||||
|     echo "                rebuild archives (correct mode)" |     echo "-T | --test:              test input repository                   (default mode)" | ||||||
|     echo "-m|--max <id>:  maximum rom id to load from dat file" |     echo "-D | --dsrom:             dsrom.lst will be dumped" | ||||||
|     echo "-n|--renum:     try to renumber archives" |     echo "-h | --help:              print this help and exit" | ||||||
|     echo "   --list_ok:   list roms with ok status" |     echo "-V | --version:           print the version and exit" | ||||||
|     echo "   --list_ko:   list roms with ko status" |     echo "" | ||||||
|     echo "   --list_miss: list missing roms" |     echo "Global options" | ||||||
|     echo "-v|--verbose:   switch on verbosity" |     echo "-m | --max <id>:          maximum rom id to load from dat file    (default: ${max_idx})" | ||||||
|  |     echo "-v | --verbose:           switch on verbosity" | ||||||
|  |     echo "-c | --compressor <c>:    set archive compressor (zip, rar or 7z) (default: ${compressor})" | ||||||
|  |     echo "" | ||||||
|  |     echo "Test and Correct Mode options:" | ||||||
|  |     echo "-j | --jobs <jobs>:       nuber of parallel jobs to run           (default: ${job_nb})" | ||||||
|  |     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:           list roms with ok status" | ||||||
|  |     echo "     --list_ko:           list roms with ko status" | ||||||
|  |     echo "     --list_miss:         list missing roms" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -186,17 +150,21 @@ function help_print() | |||||||
| 
 | 
 | ||||||
| function args_parse() | function args_parse() | ||||||
| { | { | ||||||
|        mode="test" |      nds_repository_in="/opt/public/nds" | ||||||
|     rebuild="no" |     nds_repository_out="/opt/public/nds" | ||||||
|       renum="no" |                   mode="test" | ||||||
|         lok="no" |                verbose="no" | ||||||
|         lko="no" |                max_idx=9999 | ||||||
|       lmiss="no" | 	    compressor="7z" | ||||||
|     verbose="no" |                 job_nb=1 | ||||||
|     max_idx=9999 |                rebuild="no" | ||||||
|  |                  renum="no" | ||||||
|  |                    lok="no" | ||||||
|  |                    lko="no" | ||||||
|  |                  lmiss="no" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     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' -- "$@") |     tmp_args=$(getopt -o i:o:CTDhVm:vc:j:rn --long repo_in,repo_out,correct,test,dsrom,help,version,max:,verbose,compressor:,jobs:,rebuild,renum,list_ok,list_ko,list_miss -n 'nds_simple_rom_mng' -- "$@") | ||||||
| 
 | 
 | ||||||
|     if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi |     if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi | ||||||
| 
 | 
 | ||||||
| @ -205,19 +173,32 @@ function args_parse() | |||||||
| 
 | 
 | ||||||
|     while true ; do |     while true ; do | ||||||
| 	case "$1" in | 	case "$1" in | ||||||
| 	    -C|--correct)      mode="correct";                shift;; | 	    # Path options | ||||||
|             -T|--test)         mode="test";                   shift;; |             -i|--repo_in)    shift;  nds_repository_in="$1";                     shift;; | ||||||
|             -D|--dsrom)        mode="dsrom";                  shift;; |             -o|--repo_out)   shift; nds_repository_out="$1";                     shift;; | ||||||
| 	    -h|--help)         mode="exit";    help_print;    shift;; | 
 | ||||||
| 	    -V|--version)      mode="exit";    version_print; shift;; | 	    # Mode switches | ||||||
|             -r|--rebuild)   rebuild="yes";                    shift;; | 	    -C|--correct)                         mode="correct";                shift;; | ||||||
|             -m|--max)       shift; max_idx="$1";              shift;; |             -T|--test)                            mode="test";                   shift;; | ||||||
|             -n|--renum)       renum="yes";                    shift;; |             -D|--dsrom)                           mode="dsrom";                  shift;; | ||||||
|                --list_ok)       lok="yes";                    shift;; | 	    -h|--help)                            mode="exit";    help_print;    shift;; | ||||||
|                --list_ko)       lko="yes";                    shift;; | 	    -V|--version)                         mode="exit";    version_print; shift;; | ||||||
|                --list_miss)   lmiss="yes";                    shift;; | 
 | ||||||
|             -v|--verbose)   verbose="yes";                    shift;; | 	    # Global options | ||||||
| 	    --)                                               shift;  break;; |             -m|--max)        shift;            max_idx="$1";                     shift;; | ||||||
|  |             -v|--verbose)                      verbose="yes";                    shift;; | ||||||
|  |             -c|--compressor) shift;         compressor="$1";                     shift;; | ||||||
|  | 	     | ||||||
|  | 	    # T & C options | ||||||
|  |             -j|--jobs)       shift;             job_nb="$1";                     shift;; | ||||||
|  |             -r|--rebuild)                      rebuild="yes";                    shift;; | ||||||
|  |             -n|--renum)                          renum="yes";                    shift;; | ||||||
|  |                --list_ok)                          lok="yes";                    shift;; | ||||||
|  |                --list_ko)                          lko="yes";                    shift;; | ||||||
|  |                --list_miss)                      lmiss="yes";                    shift;; | ||||||
|  | 	     | ||||||
|  | 	    #    | ||||||
|  | 	    --)                                                                  shift;  break;; | ||||||
| 	    *) echo "args_parse internal error [$1] !"; exit 1;; | 	    *) echo "args_parse internal error [$1] !"; exit 1;; | ||||||
| 	esac | 	esac | ||||||
|     done |     done | ||||||
| @ -227,6 +208,56 @@ function args_parse() | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | # Setup Environment | ||||||
|  | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | function env_setup() | ||||||
|  | { | ||||||
|  |     if [[ ${nds_repository_in} == ${nds_repository_out} ]] | ||||||
|  |     then | ||||||
|  | 	in_place=yes | ||||||
|  |     else | ||||||
|  | 	in_place=no | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  |     # Path Config | ||||||
|  |      nds_roms_in=${nds_repository_in}/roms | ||||||
|  |     nds_roms_out=${nds_repository_out}/roms | ||||||
|  |          nds_xml=${nds_repository_in}/misc/dsrom.xml | ||||||
|  | 
 | ||||||
|  |     if [[ ! -f ${nds_xml} ]] | ||||||
|  |     then | ||||||
|  | 	echo "error: dsrom.xml not found !" 1>&2 | ||||||
|  | 	exit 1 | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  |     case "${compressor}" | ||||||
|  |     in | ||||||
|  |         (zip) | ||||||
|  |             csfx=zip | ||||||
|  |         ;; | ||||||
|  | 
 | ||||||
|  |         (rar) | ||||||
|  |             csfx=rar | ||||||
|  |         ;; | ||||||
|  | 
 | ||||||
|  |         (7z) | ||||||
|  |             csfx=7z | ||||||
|  |         ;; | ||||||
|  | 
 | ||||||
|  |         (*) | ||||||
|  |             echo "Error: unsuported compressor: ${compressor} !" | ||||||
|  | 	    exit 1 | ||||||
|  |         ;; | ||||||
|  |     esac | ||||||
|  | 
 | ||||||
|  |     rnfh_regex=".... - .* \(.*:.*\) \[..\] \{........} <....>[-]*[0-9]*\.${csfx}$" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| # Print Counter | # Print Counter | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| @ -368,7 +399,7 @@ function xml_load() | |||||||
| 	      ;; | 	      ;; | ||||||
| 	  esac | 	  esac | ||||||
|       fi |       fi | ||||||
|     done < ${NDS_XML} |     done < ${nds_xml} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -382,7 +413,7 @@ function job_init() | |||||||
| { | { | ||||||
|     job_id=0 |     job_id=0 | ||||||
| 
 | 
 | ||||||
|     while [[ ${job_id} -lt ${JOB_NB} ]] |     while [[ ${job_id} -lt ${job_nb} ]] | ||||||
|     do |     do | ||||||
|       job_pid[${job_id}]="0" |       job_pid[${job_id}]="0" | ||||||
|       job_dir[${job_id}]="${TMP_DIR}/nds2rom-$$-${job_id}" |       job_dir[${job_id}]="${TMP_DIR}/nds2rom-$$-${job_id}" | ||||||
| @ -405,7 +436,7 @@ function job_deinit() | |||||||
| { | { | ||||||
|     job_id=0 |     job_id=0 | ||||||
| 
 | 
 | ||||||
|     while [[ ${job_id} -lt ${JOB_NB} ]] |     while [[ ${job_id} -lt ${job_nb} ]] | ||||||
|     do |     do | ||||||
|       rm -R "${job_dir[${job_id}]}" |       rm -R "${job_dir[${job_id}]}" | ||||||
| 
 | 
 | ||||||
| @ -424,7 +455,7 @@ function job_switch() | |||||||
| { | { | ||||||
|     job_id=$((${job_id} + 1)) |     job_id=$((${job_id} + 1)) | ||||||
| 
 | 
 | ||||||
|     if [[ ${job_id} -ge ${JOB_NB} ]] |     if [[ ${job_id} -ge ${job_nb} ]] | ||||||
|     then |     then | ||||||
| 	job_id=0 | 	job_id=0 | ||||||
|     fi |     fi | ||||||
| @ -660,33 +691,33 @@ function arc_build() | |||||||
|         then |         then | ||||||
| 	    print_verbose "removing ${file}" | 	    print_verbose "removing ${file}" | ||||||
| 
 | 
 | ||||||
| 	    \rm -f  "${NDS_ROMS_IN}/${file}" | 	    \rm -f  "${nds_roms_in}/${file}" | ||||||
| 	fi | 	fi | ||||||
| 
 | 
 | ||||||
| 	case "${COMPRESSOR}" | 	case "${compressor}" | ||||||
| 	in | 	in | ||||||
| 	    (zip) | 	    (zip) | ||||||
| 	        print_verbose "zipping ${rom} into ${file_name}" | 	        print_verbose "zipping ${rom} into ${file_name}" | ||||||
| 
 | 
 | ||||||
| 		zip -m9 "${NDS_ROMS_OUT}/${file_name}" "${rom}"  >/dev/null 2>&1 | 		zip -m9 "${nds_roms_out}/${file_name}" "${rom}"  >/dev/null 2>&1 | ||||||
|             ;; |             ;; | ||||||
| 
 | 
 | ||||||
| 	    (rar) | 	    (rar) | ||||||
| 	        print_verbose "raring ${rom} into ${file_name}" | 	        print_verbose "raring ${rom} into ${file_name}" | ||||||
| 
 | 
 | ||||||
| 		rar m -m5 "${NDS_ROMS_OUT}/${file_name}" "${rom}"  >/dev/null 2>&1 | 		rar m -m5 "${nds_roms_out}/${file_name}" "${rom}"  >/dev/null 2>&1 | ||||||
|             ;; |             ;; | ||||||
| 
 | 
 | ||||||
| 	    (7z) | 	    (7z) | ||||||
| 	        print_verbose "7zipping ${rom} into ${file_name}" | 	        print_verbose "7zipping ${rom} into ${file_name}" | ||||||
| 
 | 
 | ||||||
| 		7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -bd "${NDS_ROMS_OUT}/${file_name}" "${rom}" >/dev/null 2>&1 | 		7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -bd "${nds_roms_out}/${file_name}" "${rom}" >/dev/null 2>&1 | ||||||
| 		\rm -f "${rom}" | 		\rm -f "${rom}" | ||||||
| 	    ;; | 	    ;; | ||||||
| 
 | 
 | ||||||
| 		 | 		 | ||||||
| 	    (*) | 	    (*) | ||||||
| 	        echo "arc_build internal error [$COMPRESSOR] !" 1>&2 | 	        echo "arc_build internal error [$compressor] !" 1>&2 | ||||||
| 		exit 1 | 		exit 1 | ||||||
| 	    ;; | 	    ;; | ||||||
| 	esac | 	esac | ||||||
| @ -720,11 +751,11 @@ function arc_rename() | |||||||
|             then |             then | ||||||
| 		print_verbose "moving ${file} to ${file_name}" | 		print_verbose "moving ${file} to ${file_name}" | ||||||
| 
 | 
 | ||||||
| 		mv "${NDS_ROMS_IN}/${file}" "${NDS_ROMS_OUT}/${file_name}" | 		mv "${nds_roms_in}/${file}" "${nds_roms_out}/${file_name}" | ||||||
| 	    else | 	    else | ||||||
| 		print_verbose "copying ${file} to ${file_name}" | 		print_verbose "copying ${file} to ${file_name}" | ||||||
| 
 | 
 | ||||||
| 		cp "${NDS_ROMS_IN}/${file}" "${NDS_ROMS_OUT}/${file_name}" | 		cp "${nds_roms_in}/${file}" "${nds_roms_out}/${file_name}" | ||||||
| 	    fi | 	    fi | ||||||
| #	fi | #	fi | ||||||
|     fi |     fi | ||||||
| @ -770,25 +801,25 @@ function rom_extract() | |||||||
|         (*.nds) |         (*.nds) | ||||||
| 	    print_verbose "copying ${file} to ${rom}" | 	    print_verbose "copying ${file} to ${rom}" | ||||||
| 
 | 
 | ||||||
| 	    cp       "${NDS_ROMS_IN}/${file}"   "${rom}" | 	    cp       "${nds_roms_in}/${file}"   "${rom}" | ||||||
| 	;; | 	;; | ||||||
| 
 | 
 | ||||||
| 	(*.rar) | 	(*.rar) | ||||||
| 	    print_verbose "extracting ${rom} from ${file}" | 	    print_verbose "extracting ${rom} from ${file}" | ||||||
| 
 | 
 | ||||||
| 	    unrar p -inul "${NDS_ROMS_IN}/${file}" > "${rom}" | 	    unrar p -inul "${nds_roms_in}/${file}" > "${rom}" | ||||||
| 	;; | 	;; | ||||||
| 
 | 
 | ||||||
| 	(*.7z) | 	(*.7z) | ||||||
| 	    print_verbose "extracting ${rom} from ${file}" | 	    print_verbose "extracting ${rom} from ${file}" | ||||||
| 
 | 
 | ||||||
| 	    7z x -so "${NDS_ROMS_IN}/${file}" > "${rom}" 2>/dev/null | 	    7z x -so "${nds_roms_in}/${file}" > "${rom}" 2>/dev/null | ||||||
| 	;; | 	;; | ||||||
| 
 | 
 | ||||||
| 	(*.zip) | 	(*.zip) | ||||||
| 	    print_verbose "extracting ${rom} from ${file}" | 	    print_verbose "extracting ${rom} from ${file}" | ||||||
| 
 | 
 | ||||||
|  	    unzip -p "${NDS_ROMS_IN}/${file}" > "${rom}" |  	    unzip -p "${nds_roms_in}/${file}" > "${rom}" | ||||||
| 	;; | 	;; | ||||||
| 		 | 		 | ||||||
| 	(*) | 	(*) | ||||||
| @ -812,11 +843,11 @@ function tmp_mv() | |||||||
|        IFS=' ' |        IFS=' ' | ||||||
|     mv_cnt=0 |     mv_cnt=0 | ||||||
|     |     | ||||||
|     for file_src in ${NDS_ROMS_OUT}/*.tmp |     for file_src in ${nds_roms_out}/*.tmp | ||||||
|     do |     do | ||||||
|       if [[ "${file_src}" != "${NDS_ROMS_OUT}/*.tmp" ]] |       if [[ "${file_src}" != "${nds_roms_out}/*.tmp" ]] | ||||||
|       then |       then | ||||||
| 	  file_trg=${file_src/.${CSFX}.tmp/.${CSFX}} | 	  file_trg=${file_src/.${csfx}.tmp/.${csfx}} | ||||||
| 
 | 
 | ||||||
| 	  print_verbose "move ${file_src} to ${file_trg}" | 	  print_verbose "move ${file_src} to ${file_trg}" | ||||||
| 
 | 
 | ||||||
| @ -846,7 +877,7 @@ function arc_ident() | |||||||
| 
 | 
 | ||||||
|     # Type of archive ? |     # Type of archive ? | ||||||
| 
 | 
 | ||||||
|     if [[ ${file} =~ ${RNFH_REGEX} ]] |     if [[ ${file} =~ ${rnfh_regex} ]] | ||||||
|     then |     then | ||||||
| 	eval ${arc_type_ptr}="rx3" | 	eval ${arc_type_ptr}="rx3" | ||||||
|     else  |     else  | ||||||
| @ -1051,7 +1082,7 @@ function arc_mng() | |||||||
| 
 | 
 | ||||||
|     tmp_file=$(mktemp) |     tmp_file=$(mktemp) | ||||||
| 
 | 
 | ||||||
|     ls ${NDS_ROMS_IN} > ${tmp_file} |     ls ${nds_roms_in} > ${tmp_file} | ||||||
| 
 | 
 | ||||||
|     while read file |     while read file | ||||||
|     do |     do | ||||||
| @ -1116,7 +1147,7 @@ function suffix_mng() | |||||||
| 
 | 
 | ||||||
|     tmp_file=$(mktemp) |     tmp_file=$(mktemp) | ||||||
| 
 | 
 | ||||||
|     ls ${NDS_ROMS_OUT} > ${tmp_file} |     ls ${nds_roms_out} > ${tmp_file} | ||||||
| 
 | 
 | ||||||
|     while read file |     while read file | ||||||
|     do |     do | ||||||
| @ -1144,7 +1175,7 @@ function suffix_mng() | |||||||
| 	         idx_old=${idx} | 	         idx_old=${idx} | ||||||
|               status_old=${status} |               status_old=${status} | ||||||
| 	          dup_id=0 | 	          dup_id=0 | ||||||
| 	       file_name="${file/) \[*/}) [${status}] {${crc}} <${fp}>.${CSFX}" | 	       file_name="${file/) \[*/}) [${status}] {${crc}} <${fp}>.${csfx}" | ||||||
| 
 | 
 | ||||||
|                   dat_fp[${idx}]="${fp}" |                   dat_fp[${idx}]="${fp}" | ||||||
| 	      dat_status[${idx}]="${status}" | 	      dat_status[${idx}]="${status}" | ||||||
| @ -1157,7 +1188,7 @@ function suffix_mng() | |||||||
| 	      # Duplicate rom | 	      # Duplicate rom | ||||||
| 
 | 
 | ||||||
| 	         dup_id=$((${dup_id} + 1)) | 	         dup_id=$((${dup_id} + 1)) | ||||||
| 	      file_name="${file/) \[*/}) [${status}] {${crc}} <${fp}>-${dup_id}.${CSFX}" | 	      file_name="${file/) \[*/}) [${status}] {${crc}} <${fp}>-${dup_id}.${csfx}" | ||||||
| 
 | 
 | ||||||
| 	        dup_cnt=$((${dup_cnt} + 1)) | 	        dup_cnt=$((${dup_cnt} + 1)) | ||||||
| 
 | 
 | ||||||
| @ -1170,7 +1201,7 @@ function suffix_mng() | |||||||
| 	  fi | 	  fi | ||||||
| 
 | 
 | ||||||
| 	  print_verbose "moving ${file} to ${file_name}" | 	  print_verbose "moving ${file} to ${file_name}" | ||||||
| 	  arc_mv "${NDS_ROMS_OUT}/${file_name}" "${NDS_ROMS_OUT}/${file}" "${mode}" | 	  arc_mv "${nds_roms_out}/${file_name}" "${nds_roms_out}/${file}" "${mode}" | ||||||
|       fi |       fi | ||||||
| 
 | 
 | ||||||
|       found_cnt=$((${found_cnt} + 1)) |       found_cnt=$((${found_cnt} + 1)) | ||||||
| @ -1365,7 +1396,7 @@ function fp_scan() | |||||||
| 
 | 
 | ||||||
|     tmp_file=$(mktemp) |     tmp_file=$(mktemp) | ||||||
| 
 | 
 | ||||||
|     ls ${NDS_ROMS_IN} > ${tmp_file} |     ls ${nds_roms_in} > ${tmp_file} | ||||||
| 
 | 
 | ||||||
|     while read file |     while read file | ||||||
|     do |     do | ||||||
| @ -1388,7 +1419,7 @@ function fp_scan() | |||||||
| 
 | 
 | ||||||
|       # Type of archive ? |       # Type of archive ? | ||||||
| 
 | 
 | ||||||
|       if [[ ${file} =~ ${RNFH_REGEX} ]] |       if [[ ${file} =~ ${rnfh_regex} ]] | ||||||
|       then |       then | ||||||
| 	      fp=${file/*\} \</}; fp=${fp/\>*/} | 	      fp=${file/*\} \</}; fp=${fp/\>*/} | ||||||
| 	  status=${file/* \[/}; status=${status/\] \{*/} | 	  status=${file/* \[/}; status=${status/\] \{*/} | ||||||
| @ -1440,9 +1471,9 @@ function test_correct_mode() | |||||||
| { | { | ||||||
|     if [[ ${in_place} == "yes" ]] |     if [[ ${in_place} == "yes" ]] | ||||||
|     then |     then | ||||||
| 	file_suffix=".${CSFX}.tmp" | 	file_suffix=".${csfx}.tmp" | ||||||
|     else |     else | ||||||
| 	file_suffix=".${CSFX}" | 	file_suffix=".${csfx}" | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     # Remove .tmp suffix |     # Remove .tmp suffix | ||||||
| @ -1492,16 +1523,6 @@ function test_correct_mode() | |||||||
| 
 | 
 | ||||||
| cd ${TMP_DIR} | cd ${TMP_DIR} | ||||||
| 
 | 
 | ||||||
| # Initialise stats variables |  | ||||||
| 
 |  | ||||||
| #     ok_cnt=0 |  | ||||||
| #     ko_cnt=0 |  | ||||||
| #  found_cnt=0 |  | ||||||
| #missing_cnt=0 |  | ||||||
| #  renum_cnt=0 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| shopt -s extglob | shopt -s extglob | ||||||
| 
 | 
 | ||||||
| args_parse "$@" | args_parse "$@" | ||||||
| @ -1511,24 +1532,24 @@ then | |||||||
|     exit 0 |     exit 0 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [[ ${NDS_REPOSITORY_IN} == ${NDS_REPOSITORY_OUT} ]] | env_setup | ||||||
| then |  | ||||||
|     in_place=yes |  | ||||||
| else |  | ||||||
|     in_place=no |  | ||||||
| fi |  | ||||||
| 
 | 
 | ||||||
| if [[ ! -f ${NDS_XML} ]] | case "${mode}" | ||||||
| then | in | ||||||
|     echo "error: dsrom.xml not found !" 1>&2 |     (dsrom): | ||||||
|     exit 1 |         echo "mode: [${mode}]   repository: [${nds_repository_in}]   max idx: (${max_idx})   compressor: [${compressor}]" 1>&2 | ||||||
| fi |     ;; | ||||||
|  | 
 | ||||||
|  |     (test|correct): | ||||||
|  |         echo "mode: [${mode}]   repository in: [${nds_repository_in}]   repository out: [${nds_repository_out}]" 1>&2 | ||||||
|  | 	echo "max idx: (${max_idx})   compressor: [${compressor}]   rebuild: [${rebuild}]   renum: [${renum}]   jobs: (${job_nb})" 1>&2 | ||||||
|  |     ;; | ||||||
|  | esac | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #----------------------------------------------------------------------------------------------------------------------------------- | #----------------------------------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| #dat_load |  | ||||||
| xml_load | xml_load | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user