1#!/bin/bash 2# Copyright (c) 2021 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# Author: Tools Team 15# param description: 16# $1 : the path of notice file to be verified. 17# $2 : the file of writing verification results. 18# $3 : the current platform dir. 19# notice. 20 21set -e 22 23if [ ! -f "$1" ]; then 24 echo "Note: The notice file $1 does not exist." 25 echo "Success" > $2 26 exit 0 27fi 28 29line_of_equal_in_file="$3/lineOfEqualInFile" 30line_of_new_file_flag_in_file="$3/lineOfNewFileFlagInFile" 31line_of_divide_in_file="$3/lineOfDivideInFile" 32 33rm -f $line_of_equal_in_file 34rm -f $line_of_new_file_flag_in_file 35rm -f $line_of_divide_in_file 36 37NOTICEFILE=$1 38 39grep -n "^============================================================$" $NOTICEFILE | cut -d ':' -f 1 > $line_of_equal_in_file 40grep -n "Notices for file(s):" $NOTICEFILE | cut -d ':' -f 1 > $line_of_new_file_flag_in_file 41grep -n "^------------------------------------------------------------$" $NOTICEFILE | cut -d ':' -f 1 > $line_of_divide_in_file 42 43nums_equal_in_file=$(cat $line_of_equal_in_file | wc -l) 44nums_new_file_flag_in_file=$(cat $line_of_new_file_flag_in_file | wc -l) 45nums_divid_in_file=$(cat $line_of_divide_in_file | wc -l) 46 47if [[ "$nums_equal_in_file" != "$nums_new_file_flag_in_file" ]];then 48 echo "Error:nums_equal_in_file is $nums_equal_in_file,nums_new_file_flag_in_file is $nums_new_file_flag_in_file" 49 echo "Failed" > $2 50 exit 1 51elif [[ "$nums_equal_in_file" != "$nums_divid_in_file" ]];then 52 echo "Warning!! maybe something wrong! nums_equal_in_file is $nums_equal_in_file,nums_divid_in_file is $nums_divid_in_file" 53fi 54 55rm -f $line_of_equal_in_file 56rm -f $line_of_new_file_flag_in_file 57rm -f $line_of_divide_in_file 58 59echo "Success" > $2 60 61set +e 62