#!/usr/bin/env bash ############################################################################### # # Copyright (C) 2009-2013 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # ############################################################################### ############################################################################### # dir check ############################################################################### dir_check () { local DIR="$1" local CLEAN_UP="$2" if [ -e "$DIR" ] then if [ ! -d "$DIR" ] then echo "$(basename $0) failed: $DIR is not a directory." return 1 fi if [ "$CLEAN_UP" -eq 1 ] then rm -Rf "$DIR" mkdir "$DIR" fi else mkdir "$DIR" fi return 0 } ############################################################################### # print usage help message ############################################################################### usage () { cat < options: -i : Master archive file to extract. -o : Output file name without extension. Extension '.wumad' is automatically added. If omitted, use RPX file name with the extension .wumad at the current work dir. -w : Temporary directory for mastering. If omitted, create temporary directory at the current work dir. EOF } ############################################################################### # main ############################################################################### # Environment settings MAKEDISCIMAGE="$CAFE_ROOT/system/bin/tool/mastering/makediscimage.exe" MASTER_ARCHIVE_FILE="" OUTPUT_FILE_NOEXT="" VERBOSE=1 while getopts ":i:w:o:v" opt; do case $opt in i ) MASTER_ARCHIVE_FILE="`cygpath -a $OPTARG`" ;; w ) TEMP_WORK_DIR="`cygpath -a $OPTARG`" ;; o ) OUTPUT_FILE_NOEXT="`cygpath -a $OPTARG`" ;; v ) VERBOSE=1 ;; \? ) usage exit 1 ;; esac done if [ ! -f "$MASTER_ARCHIVE_FILE" ] then echo "$(basename $0) failed: master archive file is not found." usage exit 2 fi if [ ! ${MASTER_ARCHIVE_FILE:(-6)} == ".wumad" ] then echo "$(basename $0) failed: Please specify master archive file with -i option." usage exit 3 fi if [ -z "$OUTPUT_FILE_NOEXT" ] then # Use file name only in order to output at current work directory OUTPUT_FILE_NOEXT=`basename "${MASTER_ARCHIVE_FILE%.*}"` fi if [ -z "$TEMP_WORK_DIR" ] then TEMP_WORK_DIR="`basename "${OUTPUT_FILE_NOEXT%.*}"`_tmp" else if [ -e "$TEMP_WORK_DIR" ] then TEMP_WORK_SUBDIR="`basename "${OUTPUT_FILE_NOEXT%.*}"`_tmp" TEMP_WORK_DIR="$TEMP_WORK_DIR/$TEMP_WORK_SUBDIR" fi fi dir_check "$TEMP_WORK_DIR" 1 rval=$? if [ $rval -ne 0 ] then exit 7 fi # Echo settings (if -v specified) if [ "$VERBOSE" -eq 1 ] then echo "======== $(basename $0) parameters ========" echo "Output : $OUTPUT_FILE_NOEXT.wum" echo "Master Archive : $MASTER_ARCHIVE_FILE" echo "Temp dir : $TEMP_WORK_DIR" echo "" fi MAKEMASTER_WORK_DIR=`cygpath -w -a "$TEMP_WORK_DIR"` MAKEMASTER_INPUT=`cygpath -w -a "$MASTER_ARCHIVE_FILE"` MAKEMASTER_OUTPUT=`cygpath -w -a "$OUTPUT_FILE_NOEXT"` "$MAKEDISCIMAGE" -v -nc "-wd=$MAKEMASTER_WORK_DIR" "$MAKEMASTER_INPUT" "$MAKEMASTER_OUTPUT.wum" rm -Rf "$TEMP_WORK_DIR"