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#==================================================================================================== 24usage () { 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 40if [ "$#" -eq 2 ] 41then 42 DMT1="$1" 43 DMT2="$2" 44elif [ "$#" -eq 3 ] 45then 46 VERBOSE="$1" 47 DMT1="$2" 48 DMT2="$3" 49else 50 usage 51 exit 1 52fi 53 54# Do some checking on our environment - we need JAVA_HOME present 55if [ -z "$JAVA_HOME" ] 56then 57 echo "Environment variable JAVA_HOME needs to be set first!" 58 exit 1 59fi 60 61 62# check if the parms files are exist and readable 63if [ ! -r $DMT1 ] 64then 65 echo "Cannot find fist DMT file with path: $DMT1" 66 exit 1 67fi 68 69if [ ! -r $DMT2 ] 70then 71 echo "Cannot find second DMT file with path: $DMT2" 72 exit 1 73fi 74 75 76#Call the com.mot.dm.tool.DMTSTool to to find difference 77 78echo "Begin comparison ..." 79 80$JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool $VERBOSE -difference $DMT1 $DMT2 81 82if [ $? -ne 1 ] 83then 84 echo "Error occured ..." 85 exit 1 86fi 87 88 89 90 91