1 #!/bin/bash 2 #==================================================================================================== 3 # 4 # Script Name: DMTConv 5 # 6 # General Description: This script converts DMT from .zip to .dmts formats and visa versa. 7 # 8 #==================================================================================================== 9 # Copyright (C) 2014 The Android Open Source Project 10 # 11 # Licensed under the Apache License, Version 2.0 (the "License"); 12 # you may not use this file except in compliance with the License. 13 # You may obtain a copy of the License at 14 # 15 # http://www.apache.org/licenses/LICENSE-2.0 16 # 17 # Unless required by applicable law or agreed to in writing, software 18 # distributed under the License is distributed on an "AS IS" BASIS, 19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 # See the License for the specific language governing permissions and 21 # limitations under the License. 22 #==================================================================================================== 23 usage () { 24 echo "" 25 echo "=========================================================================================" 26 echo "" 27 echo "Usage: " 28 echo " DMTConv [-verbose] <fileFrom> <fileTo>" 29 echo "" 30 echo "Where:" 31 echo " <fileFrom> DMT source in the .zip or .dmts format, required parm" 32 echo " <fileTo> DMT target in the .zip or .dmts format, required parm" 33 echo " -verbose enable verbose output, optional parm" 34 echo "" 35 echo "==========================================================================================" 36 echo "" 37 } 38 39 errorExit() { 40 echo "" 41 echo "$1" 42 usage 43 exit 1 44 } 45 46 47 # validate parameters 48 if [ "$#" -eq 2 ] 49 then 50 DMT1="$1" 51 DMT2="$2" 52 elif [ "$#" -eq 3 ] 53 then 54 VERBOSE="$1" 55 DMT1="$2" 56 DMT2="$3" 57 else 58 usage 59 exit 1 60 fi 61 62 # validate input files format 63 echo "$DMT1" | egrep "(.zip\$)|(.ZIP\$)|(.dmts\$)|(.DMTS\$)" >/dev/null || errorExit "Parameter <fileFrom> has wrong format" 64 echo "$DMT2" | egrep "(.zip\$)|(.ZIP\$)|(.dmts\$)|(.DMTS\$)" >/dev/null || errorExit "Parameter <fileTo> has wrong format" 65 66 67 # Do some checking on our environment - we need JAVA_HOME present 68 if [ -z "$JAVA_HOME" ] 69 then 70 echo "Environment variable JAVA_HOME needs to be set first!" 71 exit 1 72 fi 73 74 75 # check if the parms files are exist and readable 76 if [ ! -r $DMT1 ] 77 then 78 echo "Cannot find <fileFrom> with path: $DMT1" 79 exit 1 80 fi 81 82 83 #Call the com.mot.dm.tool.DMTSTool to perform conversion 84 85 echo "Begin conversion..." 86 87 $JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool $VERBOSE -conversion $DMT1 $DMT2 88 89 if [ $? -ne 1 ] 90 then 91 echo "Error occured ..." 92 exit 1 93 fi 94 95 96 97 98