1#!/usr/bin/env bash 2 3############################################################################### 4# 5# Copyright (C) 2009-2013 Nintendo. All rights reserved. 6# 7# These coded instructions, statements, and computer programs contain 8# proprietary information of Nintendo of America Inc. and/or Nintendo 9# Company Ltd., and are protected by Federal copyright law. They may 10# not be disclosed to third parties or copied or duplicated in any form, 11# in whole or in part, without the prior written consent of Nintendo. 12# 13############################################################################### 14 15############################################################################### 16# dir check 17############################################################################### 18dir_check () 19{ 20 local DIR="$1" 21 local CLEAN_UP="$2" 22 23 if [ -e "$DIR" ] 24 then 25 if [ ! -d "$DIR" ] 26 then 27 echo "$(basename $0) failed: $DIR is not a directory." 28 return 1 29 fi 30 if [ "$CLEAN_UP" -eq 1 ] 31 then 32 rm -Rf "$DIR" 33 mkdir "$DIR" 34 fi 35 else 36 mkdir "$DIR" 37 fi 38 39 return 0 40} 41 42############################################################################### 43# print usage help message 44############################################################################### 45usage () 46{ 47 cat <<EOF 48 49 $(basename $0) - Extract master archive file into full-padded disc master image 50 51 Usage: $(basename $0) <optional args> 52 53 options: 54 -i <path> : Master archive file to extract. 55 -o <path> : Output file name without extension. 56 Extension '.wumad' is automatically added. 57 If omitted, use RPX file name with the extension .wumad 58 at the current work dir. 59 -w <path> : Temporary directory for mastering. 60 If omitted, create temporary directory at the current work dir. 61EOF 62} 63 64############################################################################### 65# main 66############################################################################### 67 68# Environment settings 69 70MAKEDISCIMAGE="$CAFE_ROOT/system/bin/tool/mastering/makediscimage.exe" 71 72MASTER_ARCHIVE_FILE="" 73OUTPUT_FILE_NOEXT="" 74VERBOSE=1 75 76while getopts ":i:w:o:v" opt; do 77 case $opt in 78 i ) MASTER_ARCHIVE_FILE="`cygpath -a $OPTARG`" ;; 79 w ) TEMP_WORK_DIR="`cygpath -a $OPTARG`" ;; 80 o ) OUTPUT_FILE_NOEXT="`cygpath -a $OPTARG`" ;; 81 v ) VERBOSE=1 ;; 82 \? ) usage 83 exit 1 ;; 84 esac 85done 86 87if [ ! -f "$MASTER_ARCHIVE_FILE" ] 88then 89 echo "$(basename $0) failed: master archive file is not found." 90 usage 91 exit 2 92fi 93 94if [ ! ${MASTER_ARCHIVE_FILE:(-6)} == ".wumad" ] 95then 96 echo "$(basename $0) failed: Please specify master archive file with -i option." 97 usage 98 exit 3 99fi 100 101if [ -z "$OUTPUT_FILE_NOEXT" ] 102then 103 # Use file name only in order to output at current work directory 104 OUTPUT_FILE_NOEXT=`basename "${MASTER_ARCHIVE_FILE%.*}"` 105fi 106 107if [ -z "$TEMP_WORK_DIR" ] 108then 109 TEMP_WORK_DIR="`basename "${OUTPUT_FILE_NOEXT%.*}"`_tmp" 110else 111 if [ -e "$TEMP_WORK_DIR" ] 112 then 113 TEMP_WORK_SUBDIR="`basename "${OUTPUT_FILE_NOEXT%.*}"`_tmp" 114 TEMP_WORK_DIR="$TEMP_WORK_DIR/$TEMP_WORK_SUBDIR" 115 fi 116fi 117dir_check "$TEMP_WORK_DIR" 1 118rval=$? 119if [ $rval -ne 0 ] 120then 121 exit 7 122fi 123 124# Echo settings (if -v specified) 125if [ "$VERBOSE" -eq 1 ] 126then 127 echo "======== $(basename $0) parameters ========" 128 echo "Output : $OUTPUT_FILE_NOEXT.wum" 129 echo "Master Archive : $MASTER_ARCHIVE_FILE" 130 echo "Temp dir : $TEMP_WORK_DIR" 131 echo "" 132fi 133 134MAKEMASTER_WORK_DIR=`cygpath -w -a "$TEMP_WORK_DIR"` 135MAKEMASTER_INPUT=`cygpath -w -a "$MASTER_ARCHIVE_FILE"` 136MAKEMASTER_OUTPUT=`cygpath -w -a "$OUTPUT_FILE_NOEXT"` 137 138"$MAKEDISCIMAGE" -v -nc "-wd=$MAKEMASTER_WORK_DIR" "$MAKEMASTER_INPUT" "$MAKEMASTER_OUTPUT.wum" 139 140rm -Rf "$TEMP_WORK_DIR" 141