代码拉取完成,页面将自动刷新
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Check whether TencentOS Kernel KAPI is compliant
#
srctree=$(dirname "$0")/../
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
NO_COLOR="\033[0m"
function pr_err()
{
printf "${RED}$1${NO_COLOR}\n"
}
function pr_info()
{
printf "${GREEN}$1${NO_COLOR}\n"
}
function pr_warn()
{
printf "${YELLOW}$1${NO_COLOR}\n"
}
function usage_info()
{
echo "Usage: $0 <arch>"
echo " arch: x86 x86_64 arm64"
}
function compile_kernel()
{
local machine=$1
local arch=$2
local thread_num=$(nproc)
thread_num=$((thread_num * 2))
if [ "${machine}" == "x86_64" ] && [ "${arch}" == "arm64" ] && [ "X$CROSS_COMPILE" == "X" ]; then
local CROSS_COMPILE="aarch64-linux-gnu-"
fi
make ARCH=${arch} CROSS_COMPILE=${CROSS_COMPILE} tencentconfig -sk 1> /dev/null
if [ $? -ne 0 ]; then
pr_err "make tencentconfig failed"
return 1
fi
echo "start to compile kernel, may take a long time..."
make ARCH=${arch} CROSS_COMPILE=${CROSS_COMPILE} -j ${thread_num} -sk 1> /dev/null
if [ $? -ne 0 ]; then
pr_err "compile kernel failed"
return 1
fi
return 0
}
function check_kapi()
{
local ret=0
# XXX: The Ruyi config needs to be closed to compile normally
./scripts/config -d CONFIG_RUE
# modify the Makefile to enable CONFIG_TKERNEL_CHECK_KAPI
sed -i "s/obj-\$(CONFIG_TKERNEL_CHECK_KAPI) += checkkapi/obj-m += checkkapi/g" kernel/tkernel/Makefile
sed -i "s/obj-\$(CONFIG_TKERNEL_CHECK_KAPI) += check_kapi/obj-m += check_kapi/g" kernel/tkernel/checkkapi/Makefile
make ARCH=${arch} CROSS_COMPILE=${CROSS_COMPILE} M=kernel/tkernel/checkkapi modules
if [ $? -ne 0 ]; then
pr_err "check KAPI failed"
ret=1
else
pr_info "check KAPI success"
ret=0
fi
# Restore the Makefile
sed -i "s/obj-m += checkkapi/obj-\$(CONFIG_TKERNEL_CHECK_KAPI) += checkkapi/g" kernel/tkernel/Makefile
sed -i "s/obj-m += check_kapi/obj-\$(CONFIG_TKERNEL_CHECK_KAPI) += check_kapi/g" kernel/tkernel/checkkapi/Makefile
return $ret
}
function check_param()
{
local arch=$1
local machine=$(uname -m)
if [ "$#" -ne 1 ]; then
usage_info
return 1
fi
if [ "${machine}" != "x86_64" ] && [ "${machine}" != "aarch64" ]; then
pr_err "not support machine:${machine}"
usage_info
return 1
fi
if [ "${arch}" != "x86" ] && [ "${arch}" != "x86_64" ] && [ "${arch}" != "arm64" ]; then
pr_err "not support arch:${arch}"
usage_info
return 1
fi
if [ "${machine}" == "aarch64" ] && [ "${arch}" == "x86" -o "${arch}" == "x86_64" ]; then
pr_err "machine aarch64 not support cross compile"
usage_info
return 1
fi
return 0
}
function main()
{
local arch=$1
local machine=$(uname -m)
check_param $@
if [ $? -ne 0 ]; then
return 1
fi
cd ${srctree}
echo "arch: ${arch}"
echo "machine: ${machine}"
compile_kernel ${machine} ${arch}
if [ $? -ne 0 ]; then
return 1
fi
check_kapi
if [ $? -ne 0 ]; then
return 1
fi
return 0
}
main $@
exit $?
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。