2 Star 0 Fork 17

JofDiamonds/Kmesh

forked from openEuler/Kmesh 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.sh 3.52 KB
一键复制 编辑 原始数据 按行查看 历史
以梦喂马 提交于 2024-07-14 16:03 . fix typo
#!/bin/bash
ROOT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
# adjust the range of BPF code compilation based on the kernel is enhanced
function bpf_compile_range_adjust() {
if [ "$ENHANCED_KERNEL" == "enhanced" ]; then
sed -i '/ads\/tracepoint\.c/s/\(.*\)generate/\/\/go:generate/' bpf/kmesh/bpf2go/bpf2go.go
sed -i '/ads\/sockops\.c/s/\(.*\)generate/\/\/go:generate/' bpf/kmesh/bpf2go/bpf2go.go
else
sed -i '/ads\/tracepoint\.c/s/\(.*\)generate/\/\/not go:generate/' bpf/kmesh/bpf2go/bpf2go.go
sed -i '/ads\/sockops\.c/s/\(.*\)generate/\/\/not go:generate/' bpf/kmesh/bpf2go/bpf2go.go
fi
}
function set_enhanced_kernel_env() {
# we use /usr/include/linux/bpf.h to determine the runtime environment’s
# support for kmesh. Considering the case of online image compilation, a
# variable KERNEL_HEADER_LINUX_BPF is used here to specify the path of the
# source of macro definition.
# When using an online compiled image, /usr/include/linux/bpf.h in host
# machine will be mounted to config/linux-bpf.h.
# Otherwise, /usr/include/linux/bpf.h from the current compilation
# environment will be obtained
export KERNEL_HEADER_LINUX_BPF=$ROOT_DIR/config/linux-bpf.h
if [ ! -f "$KERNEL_HEADER_LINUX_BPF" ]; then
export KERNEL_HEADER_LINUX_BPF=/usr/include/linux/bpf.h
fi
if grep -q "FN(parse_header_msg)" $KERNEL_HEADER_LINUX_BPF; then
export ENHANCED_KERNEL="enhanced"
else
export ENHANCED_KERNEL="unenhanced"
fi
}
function prepare() {
bash kmesh_compile_env_pre.sh
bash kmesh_macros_env.sh
bash kmesh_bpf_env.sh
if [ "$(arch)" == "x86_64" ]; then
export EXTRA_CDEFINE="-D__x86_64__"
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu:$C_INCLUDE_PATH
fi
if [ "$(arch)" == "aarch64" ]; then
export C_INCLUDE_PATH=/usr/include/aarch64-linux-gnu:$C_INCLUDE_PATH
fi
export EXTRA_GOFLAGS="-gcflags=\"-N -l\""
export EXTRA_CFLAGS="-O0 -g"
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0
export PATH="$PATH:$(go env GOPATH)/bin"
bpf_compile_range_adjust
}
function install() {
mkdir -p /etc/kmesh
chmod 700 /etc/kmesh
cp $ROOT_DIR/build/kmesh-start-pre.sh /usr/bin
chmod 500 /usr/bin/kmesh-start-pre.sh
cp $ROOT_DIR/build/kmesh-stop-post.sh /usr/bin
chmod 500 /usr/bin/kmesh-stop-post.sh
mkdir -p /etc/oncn-mda
chmod 700 /etc/oncn-mda
cp $ROOT_DIR/oncn-mda/etc/oncn-mda.conf /etc/oncn-mda/
chmod 600 /etc/oncn-mda/oncn-mda.conf
}
function uninstall() {
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
rm -rf /etc/oncn-mda
rm -rf /usr/share/oncn-mda
}
function clean() {
rm -rf /etc/kmesh
rm -rf /usr/bin/kmesh-start-pre.sh
rm -rf /usr/bin/kmesh-stop-post.sh
}
set_enhanced_kernel_env
if [ "$1" == "-h" -o "$1" == "--help" ]; then
echo build.sh -h/--help : Help.
echo build.sh -b/--build: Build Kmesh.
echo build.sh -i/--install: Install Kmesh.
echo build.sh -c/--clean: Clean the built binary.
echo build.sh -u/--uninstall: Uninstall Kmesh.
exit
fi
if [ -z "$1" -o "$1" == "-b" -o "$1" == "--build" ]; then
prepare
make
exit
fi
if [ "$1" == "-i" -o "$1" == "--install" ]; then
make install
install
exit
fi
if [ "$1" == "-u" -o "$1" == "--uninstall" ]; then
make uninstall
uninstall
exit
fi
if [ "$1" == "-c" -o "$1" == "--clean" ]; then
make clean
clean
exit
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kwb0523/Kmesh.git
git@gitee.com:kwb0523/Kmesh.git
kwb0523
Kmesh
Kmesh
docs

搜索帮助

D67c1975 1850385 1daf7b77 1850385