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