1#!/bin/bash 2# 3# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 4# 5# This software is licensed under the terms of the GNU General Public 6# License version 2, as published by the Free Software Foundation, and 7# may be copied, distributed, and modified under those terms. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# 15 16set -e 17 18OHOS_SOURCE_ROOT=$1 19KERNEL_BUILD_ROOT=$2 20KERNEL_PATCH_PATH=$3 21DEVICE_NAME=$4 22HDF_COMMON_PATCH="common" 23 24ln_list=( 25 $OHOS_SOURCE_ROOT/drivers/hdf_core/adapter/khdf/linux drivers/hdf/khdf 26 $OHOS_SOURCE_ROOT/drivers/hdf_core/framework drivers/hdf/framework 27 $OHOS_SOURCE_ROOT/drivers/hdf_core/framework/include include/hdf 28) 29 30cp_list=( 31 $OHOS_SOURCE_ROOT/third_party/bounds_checking_function ./ 32 $OHOS_SOURCE_ROOT/device/soc/hisilicon/common/platform/wifi drivers/hdf/ 33 $OHOS_SOURCE_ROOT/third_party/FreeBSD/sys/dev/evdev drivers/hdf/ 34) 35 36 37function copy_external_compents() 38{ 39 for ((i=0; i<${#cp_list[*]}; i+=2)) 40 do 41 dst_dir=${cp_list[$(expr $i + 1)]}/${cp_list[$i]##*/} 42 mkdir -p $dst_dir 43 [ -d "${cp_list[$i]}"/ ] && cp -arfL ${cp_list[$i]}/* $dst_dir/ 44 done 45} 46 47function ln_hdf_repos() 48{ 49 for ((i=0; i<${#ln_list[*]}; i+=2)) 50 do 51 ln -sf ${ln_list[$i]} ${ln_list[$(expr $i + 1)]} 52 done 53} 54 55function put_hdf_patch() 56{ 57 HDF_PATCH_FILE=${KERNEL_PATCH_PATH}/${DEVICE_NAME}_patch/hdf.patch 58 if [ ! -e "${HDF_PATCH_FILE}" ] 59 then 60 HDF_PATCH_FILE=${KERNEL_PATCH_PATH}/${HDF_COMMON_PATCH}_patch/hdf.patch 61 fi 62 patch -p1 < $HDF_PATCH_FILE 63} 64 65function main() 66{ 67 cd $KERNEL_BUILD_ROOT 68 put_hdf_patch 69 ln_hdf_repos 70 copy_external_compents 71 cd - 72} 73 74main 75