1#!/bin/bash
2# Copyright (c) 2023 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
15#kernel deps dir, must be a git repo
16DEPS=(
17    "kernel/linux/build"
18    "kernel/linux/linux-5.10"
19    "kernel/linux/linux-6.6"
20    "kernel/linux/patches"
21    "kernel/linux/config"
22    "kernel/linux/common_modules"
23    "third_party/bounds_checking_function"
24    "device/soc/hisilicon/common/platform/wifi"
25    "third_party/FreeBSD/sys/dev/evdev"
26    "drivers/hdf_core"
27)
28
29case $(uname -m) in
30    aarch64)
31        DEPS+=("prebuilts/clang/ohos/linux-aarch64/llvm/bin")
32        ;;
33    *)
34        DEPS+=("prebuilts/clang/ohos/linux-x86_64/llvm/bin")
35esac
36
37function is_kernel_change
38{
39    ROOT_PATH=$1
40    BUILD_INFO_PATH=$ROOT_PATH/out/kernel/checkpoint
41
42    if [ ! -d "$BUILD_INFO_PATH" ]; then
43        mkdir -p $BUILD_INFO_PATH
44    fi
45
46    touch $BUILD_INFO_PATH/last_build.info
47    rm -f $BUILD_INFO_PATH/current_build.info
48
49    for dep in ${DEPS[@]}
50    do
51        if [[ $dep == "prebuilts/clang/ohos/linux-x86_64/llvm/bin" || $dep == "prebuilts/clang/ohos/linux-aarch64/llvm/bin" ]];then
52            echo $dep: >> $BUILD_INFO_PATH/current_build.info
53            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $BUILD_INFO_PATH/current_build.info
54            cd $ROOT_PATH/$dep
55            md5sum clang >> $BUILD_INFO_PATH/current_build.info
56            cd -
57            echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $BUILD_INFO_PATH/current_build.info
58        else
59            echo $dep: >> $BUILD_INFO_PATH/current_build.info
60            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $BUILD_INFO_PATH/current_build.info
61            cd $ROOT_PATH/$dep
62            git log -n 2 >> $BUILD_INFO_PATH/current_build.info
63            cd -
64            echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $BUILD_INFO_PATH/current_build.info
65        fi
66
67    done
68
69    diff $BUILD_INFO_PATH/last_build.info $BUILD_INFO_PATH/current_build.info
70}
71