代码拉取完成,页面将自动刷新
同步操作将从 anolis/SysAK 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#! /bin/sh
config_host_mak="config-host.mak"
kern_ver=`uname -r`
objdir=$(pwd)/out
enable_lkm=NO
enable_libbpf=NO
enable_packages=NO
disable_libbpf=NO
static_link=no
enable_all=no
default_target=yes
kernel_bpf_support=NO
disable_list=test
usage() {
echo "Usage: configure [options]"
echo "options:"
echo " --kernel=KERNEL_VERSION kernel version"
echo " --builddir=OBJDIR the build dir"
echo " --enable-lkm enable linux kernel module"
echo " --enable-libbpf enable libbpf"
echo " --enable-packages auto install dependent packages for tools"
echo " --disable-libbpf disable all bpf tools"
echo " --enable-static static link for c/cpp tools"
echo " --enable-target-xxx xxx is the actual tool, like memleak, you may use --show-target to list all"
echo " --enable-target-all enable all components"
echo " --disable-default disable default components to built-in"
echo " --disable-target-xxx xxx is the actual tool, like memleak, you may use --show-target to list all"
echo " --show-target list all support tools"
}
check_bpf_kernel() {
kern_major=$(echo $kern_ver | awk -F '.' '{print $1}')
kern_minor=$(echo $kern_ver | awk -F '.' '{print $2}')
is_centos7=$(echo $kern_ver | grep el7 | wc -l)
if [ $((kern_major)) -ge 4 -a $((kern_minor)) -ge 4 ]; then
kernel_bpf_support="YES"
fi
if [ $is_centos7 = 1 ]; then
centos_minor=$(echo $kern_ver | awk -F '-' '{print $2}' | awk -F '.' '{print $1}')
if [ $((centos_minor)) -ge 957 ];then
kernel_bpf_support="YES"
fi
fi
if [ $kernel_bpf_support != "YES" ];then
echo "this kernel version not support ebpf"
exit 1
else
echo "check kernel bpf support OK"
fi
}
check_bpf_depend() {
if [ ! -d "source/lib/internal/ebpf/coolbpf/build.sh" ];then
echo "Cloning coolbpf"
git submodule update --init
fi
check_bpf_kernel
if [ $kernel_bpf_support = "YES" ];then
clang -v > /dev/null
if [ $? = 0 ];then
echo "check clang OK"
else
echo "check clang failed, should intall first"
exit 1
fi
fi
}
check_lkm_depend() {
if [ ! -d "source/lib/internal/kernel_module" ];then
echo "download sysak-module ... "
wget https://gitee.com/anolis/sysak-module/repository/archive/master.zip -O sysak-module.zip
echo "extract sysak-module"
unzip sysak-module.zip -d source/lib/internal/
mv source/lib/internal/sysak-module-master source/lib/internal/kernel_module
fi
rpm -q kernel-devel-$kern_ver > /dev/null
if [ $? != 0 ];then
echo "check kernel-devel-$kern_ver failed, should intall first"
exit 1;
fi
}
check_packages_depend() {
PWD=$(pwd)
PACKAGEBUILD_TMP="packagebuild_tmp"
BUILD_SH="package_build.sh"
SH_ABS_PATH=$(pwd)/$PACKAGEBUILD_TMP/$BUILD_SH
mkdir -p $(pwd)/$PACKAGEBUILD_TMP
if [ -f "$SH_ABS_PATH" ];then
rm -f $SH_ABS_PATH
fi
echo "$(grep "DEP_PKG_INSTALL" $(pwd)/source/ -nr | awk -F ":=" '{print$2}'| tr -d "\"")"| while read line
do
echo $line
OLDIFS="$IFS"
IFS=@
echo "cd $(pwd)/$PACKAGEBUILD_TMP" >> $SH_ABS_PATH
for cmd in $line
do
echo $cmd >> $SH_ABS_PATH
if [[ $cmd =~ "git clone" ]];then
echo "WARNING:\"$cmd\" failed"
fi
#source $cmd
done
IFS="$OLDIFS"
echo "cd $PWD" >> $SH_ABS_PATH
done
chmod +x $SH_ABS_PATH
exec ./$PACKAGEBUILD_TMP/$BUILD_SH
cd $PWD
}
check_depend() {
if [ $enable_lkm = "YES" ]; then
check_lkm_depend
fi
if [ $enable_libbpf = "YES" ]; then
check_bpf_depend
fi
if [ $enable_packages = "YES" ]; then
check_packages_depend
fi
}
for opt; do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
case "$opt" in
--kernel=*)
kern_ver=$optarg
;;
--builddir=*)
objdir=$(readlink -f $optarg)
;;
--enable-lkm)
enable_lkm="YES"
;;
--enable-libbpf)
enable_libbpf="YES"
;;
--enable-packages)
enable_packages="YES"
;;
--disable-libbpf)
disable_libbpf="YES"
;;
--enable-static)
static_link="yes"
;;
--enable-target-*)
target=$(expr "$opt" : '--enable-target-\(.*\)')
if [ $target = "all" ]; then
enable_all="yes"
else
target_list="$target $target_list"
fi
;;
--disable-default)
default_target=no
;;
--disable-target-*)
disable=$(expr "$opt" : '--disable-target-\(.*\)')
disable_list="$disable|$disable_list"
;;
--show-target)
find $(pwd)/source/tools/ -name Makefile -exec grep -H 'target :=' {} \; | awk '{print $3}' | grep -v test
exit
;;
*)
usage
exit
;;
esac
done
if [ $default_target = "yes" ]; then
target_list="tcp_syn_drop cpuirq sysmonitor cpu_flamegraph $target_list"
fi
for i in $target_list;do
target_files="$(grep -nrw "target := $i" $(pwd)/source/tools/ | awk -F ":" '{print $1}') $target_files"
done
if [ $disable_libbpf = "YES" ]; then
disable_target_1=$(grep "bpf\.mk" $(pwd)/source/tools/ -nEr --color | xargs -I {} expr {} : '.*/source/tools/\(.*\)/\(.*\)' |grep -E "combine|bpf_test|cgroup"|awk -F "/" '{print $2}' | uniq)
for single_target_1 in $disable_target_1;do
disable_list="$single_target_1|$disable_list"
done
disable_target_2=$(grep "bpf\.mk" $(pwd)/source/tools/ -nEr --color | xargs -I {} expr {} : '.*/source/tools/\(.*\)/\(.*\)' |grep -v -E "combine|bpf_test|cgroup"|awk -F "/" '{print $3}' | uniq)
for single_target_2 in $disable_target_2;do
disable_list="$single_target_2|$disable_list"
done
fi
if [ $enable_all = "yes" ]; then
target_files=$(grep -nrw "target :=" $(pwd)/source/tools/ | grep -vwE $disable_list | awk -F ":" '{print $1}' | grep "Makefile")
fi
for file in $target_files;do
target_path=$(dirname $file)
target_paths="$target_path $target_paths"
grep -nrw modin $file > /dev/null
if [ $? = 0 ]; then
echo "$target_path need lkm, you may set --enable-lkm"
fi
grep -nr "bpf.mk" $file > /dev/null
if [ $? = 0 ]; then
enable_libbpf="YES"
echo "$target_path need libbpf"
fi
done
check_depend
echo "# Automatically generated by configure - do not modify" > $config_host_mak
if [ $static_link = "yes" ]; then
echo "EXTRA_LDFLAGS = --static" >> $config_host_mak
fi
echo "KERNEL_VERSION = $kern_ver" >> $config_host_mak
echo "OBJPATH = $objdir" >> $config_host_mak
echo "BUILD_KERNEL_MODULE = $enable_lkm" >> $config_host_mak
echo "BUILD_LIBBPF = $enable_libbpf" >> $config_host_mak
echo "TARGET_LIST = $target_paths" >> $config_host_mak
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。