代码拉取完成,页面将自动刷新
#!/bin/sh
set -e
SRC_PATH=$(pwd)
KAE_KERNEL_DIR=""
KAE_SPEC_FILE=""
KAE_UADK_DIR=${SRC_PATH}/uadk
KAE_OPENSSL_DIR=${SRC_PATH}/KAEOpensslEngine
KAE_ZLIB_DIR=${SRC_PATH}/KAEZlib
KAE_ZSTD_DIR=${SRC_PATH}/KAEZstd
KAE_LZ4_DIR=${SRC_PATH}/KAELz4
KAE_BUILD=${SRC_PATH}/kae_build/
KAE_BUILD_LIB=${SRC_PATH}/kae_build/lib
KAE_BUILD_HEAD=${SRC_PATH}/kae_build/head
IMPLEMENTER=""
CPUPART=""
function build_check_OS_version()
{
local KERNEL_VERSION=`rpm -q --qf '%{VERSION}\n' kernel-devel | head -n 1`
if [ "$KERNEL_VERSION" == "6.6.0" ]; then
KAE_KERNEL_DIR=${SRC_PATH}/KAEKernelDriver/KAEKernelDriver-OLK-6.6
KAE_SPEC_FILE=${SRC_PATH}/scripts/specFile/kae_openeuler2403.spec
elif [ "$KERNEL_VERSION" == "5.10.0" ]; then
KAE_KERNEL_DIR=${SRC_PATH}/KAEKernelDriver/KAEKernelDriver-OLK-5.10
KAE_SPEC_FILE=${SRC_PATH}/scripts/specFile/kae.spec
else
echo "[KAE error]:unsupport kernel version"
fi
}
function build_all_comp_sva()
{
if [ -d $KAE_BUILD ]; then
rm -rf $KAE_BUILD/*
else
mkdir $KAE_BUILD
fi
mkdir -p $KAE_BUILD_LIB
mkdir -p $KAE_BUILD_HEAD
# 编译Kernel
cd ${KAE_KERNEL_DIR}
make -j
cp ${KAE_KERNEL_DIR}/hisilicon/sec2/hisi_sec2.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/hpre/hisi_hpre.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/hisi_qm.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/uacce/uacce.ko $KAE_BUILD_LIB
cp ${KAE_KERNEL_DIR}/hisilicon/zip/hisi_zip.ko $KAE_BUILD_LIB
# 编译uadk
cd $KAE_UADK_DIR
sh autogen.sh
sh conf.sh
make -j
cp ${KAE_UADK_DIR}/.libs/lib* $KAE_BUILD_LIB
mkdir -p $KAE_BUILD_HEAD/uadk
mkdir -p $KAE_BUILD_HEAD/uadk/v1
cp -r ${KAE_UADK_DIR}/include/* $KAE_BUILD_HEAD/uadk
cp -r ${KAE_UADK_DIR}/v1/*.h $KAE_BUILD_HEAD/uadk/v1
# 编译openssl
cd $KAE_OPENSSL_DIR
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
./configure --libdir=/usr/local/lib/engines-1.1/
make -j
cp $KAE_OPENSSL_DIR/src/.libs/*kae*so* $KAE_BUILD_LIB
# 编译zlib
cd $KAE_ZLIB_DIR
sh setup.sh devbuild KAE2
cp $KAE_ZLIB_DIR/lib* $KAE_BUILD_LIB
cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/lib* $KAE_BUILD_LIB
# 编译zstd
cd $KAE_ZSTD_DIR
sh build.sh devbuild
cp $KAE_ZSTD_DIR/lib* $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstd $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstdgrep $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/programs/zstdless $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/lib/libzstd.so* $KAE_BUILD_LIB
cp $KAE_ZSTD_DIR/open_source/zstd/lib/libzstd.a $KAE_BUILD_LIB
}
function build_rpm()
{
if [ -d $KAE_BUILD ]; then
rm -rf $KAE_BUILD/*
else
mkdir $KAE_BUILD
fi
local KERNEL_VERSION_BY_BUILDENV=`rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel-devel | head -n 1`
# 编译
build_driver
build_uadk
build_engine
build_zlib
build_zstd
build_lz4
## copy driver
mkdir -p $KAE_BUILD/driver
cp /lib/modules/$KERNEL_VERSION_BY_BUILDENV/extra/*.ko $KAE_BUILD/driver
cp /etc/modprobe.d/*.conf $KAE_BUILD/driver
## copy uadk
mkdir -p $KAE_BUILD/uadk/include
mkdir -p $KAE_BUILD/uadk/include/drv
mkdir -p $KAE_BUILD/uadk/lib
cp $KAE_UADK_DIR/include/*.h $KAE_BUILD/uadk/include
cp $KAE_UADK_DIR/include/drv/*.h $KAE_BUILD/uadk/include/drv
cp -r $KAE_UADK_DIR/.libs/*so* $KAE_BUILD/uadk/lib
## copy opensslengine
mkdir -p $KAE_BUILD/KAEOpensslEngine/lib
cp -r $KAE_OPENSSL_DIR/src/.libs/*so* $KAE_BUILD/KAEOpensslEngine/lib
## copy zlib
mkdir -p $KAE_BUILD/KAEZlib
cp -r /usr/local/kaezip $KAE_BUILD/KAEZlib
## copy zstd
mkdir -p $KAE_BUILD/KAEZstd
cp -r /usr/local/kaezstd $KAE_BUILD/KAEZstd
}
function build_driver()
{
cd ${KAE_KERNEL_DIR}
make -j
make nosva #默认使用nosva模式
# make install
}
function build_driver_sva()
{
cd ${KAE_KERNEL_DIR}
make -j
# make nosva #默认使用nosva模式
make install
}
function driver_clean()
{
cd ${KAE_KERNEL_DIR}
make uninstall
make clean
}
function build_uadk()
{
cd ${SRC_PATH}
patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0001-uadk-add-ctr-mode.patch || true
patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0001-uadk-add-ctr-mode.patch # uadk没支持ctr模式,engine层已经软件层面适配,可以定制化使能
patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0002-fix-uadk-zstd-bug.patch || true
patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0002-fix-uadk-zstd-bug.patch
cd ${SRC_PATH}/uadk
sh autogen.sh
sh conf.sh
make -j64
make install
}
function uadk_clean()
{
cd ${SRC_PATH}/uadk
make uninstall
make clean
sh cleanup.sh
}
function build_engine()
{
cd ${SRC_PATH}/KAEOpensslEngine
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
./configure --libdir=/usr/local/lib/engines-1.1/ --enable-kae CFLAGS="-Wl,-z,relro,-z,now -fstack-protector-strong"
make -j
make install
}
function engine_clean()
{
cd ${SRC_PATH}/KAEOpensslEngine
make uninstall
make clean
rm -rf /usr/local/lib/engines-1.1
}
function build_engine_openssl3()
{
openssl3_install_path=$1
if [ "$1" = "" ];then
openssl3_install_path=$(which openssl | awk -F'/bin' '{print $1}')
fi
cd ${SRC_PATH}/KAEOpensslEngine
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
if [ ! -f "$openssl3_install_path/include/openssl/opensslv.h" ]; then
echo "openssl3 install path is wrong, $openssl3_install_path/include/openssl/opensslv.h is not exist."
exit 1
else
if $openssl3_install_path/bin/openssl version | grep -q "OpenSSL 3."; then
echo "OpenSSL version is 3.x."
elif $openssl3_install_path/bin/openssl version | grep -q "OpenSSL 1."; then
$openssl3_install_path/bin/openssl version
echo "OpenSSL version is 1.x, please use openssl3.0 install path"
exit 1
else
$openssl3_install_path/bin/openssl version
echo "OpenSSL version is not support"
exit 1
fi
fi
./configure --libdir=/usr/local/lib/engines-3.0 --enable-kae --enable-engine --with-openssl_install_dir=$openssl3_install_path #/usr/local/ssl3
make -j
make install
}
function engine_clean_openssl3()
{
cd ${SRC_PATH}/KAEOpensslEngine
make uninstall
make clean
rm -rf /usr/local/lib/engines-3.0
}
function build_engine_gmssl()
{
cd ${SRC_PATH}/KAEOpensslEngine
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
autoreconf -i
# gmssl当前仅支持no-sva设备
./configure --libdir=/usr/local/gmssl/lib/engines-1.1 --enable-kae --enable-kae-gmssl CFLAGS="-Wl,-z,relro,-z,now -fstack-protector-strong -I/usr/local/gmssl/include/"
make -j
make install
}
function engine_clean_gmssl()
{
cd ${SRC_PATH}/KAEOpensslEngine
make uninstall
make clean
rm -rf /usr/local/gmssl/lib/engines-1.1
}
function build_zlib()
{
cd ${SRC_PATH}/KAEZlib
sh setup.sh install
}
function zlib_clean()
{
cd ${SRC_PATH}/KAEZlib
sh setup.sh uninstall
rm -rf /usr/local/kaezip
}
function build_zstd()
{
cd ${SRC_PATH}/KAEZstd
sh build.sh install
}
function zstd_clean()
{
cd ${SRC_PATH}/KAEZstd
sh build.sh uninstall
rm -rf /usr/local/kaezstd/
}
function build_lz4()
{
cd ${SRC_PATH}/KAELz4
sh build.sh install
}
function lz4_clean()
{
cd ${SRC_PATH}/KAELz4
sh build.sh uninstall
rm -rf /usr/local/kaelz4/
}
function help()
{
echo "build KAE"
echo "sh build.sh all -- install all component(not include gmssl)"
echo "sh build.sh rpmpack -- build rpm pack(not include gmssl)"
echo "sh build.sh driver -- install KAE driver"
echo "sh build.sh driver clean -- uninstall KAE driver"
echo "sh build.sh uadk -- install uadk"
echo "sh build.sh uadk clean -- uninstall uadk"
echo "sh build.sh engine -- install KAE openssl engine"
echo "sh build.sh engine clean -- uninstall KAE openssl engine"
echo "sh build.sh engine3 <openssl3.0 install path>-- install KAE openssl3.0 engine"
echo "sh build.sh engine3 clean -- uninstall KAE openssl3.0 engine"
echo "sh build.sh engine_gmssl -- install KAE gmssl engine"
echo "sh build.sh engine_gmssl clean -- uninstall KAE gmssl engine"
echo "sh build.sh zlib -- install zlib using KAE"
echo "sh build.sh zlib clean -- uninstall zlib using KAE"
echo "sh build.sh zstd -- install zstd using KAE"
echo "sh build.sh zstd clean -- uninstall zstd using KAE"
echo "sh build.sh cleanup -- clean up all component"
}
function check_environment()
{
IMPLEMENTER=$(cat /proc/cpuinfo | grep "CPU implementer" | awk 'NR==1{printf $4}')
CPUPART=$(cat /proc/cpuinfo | grep "CPU part" | awk 'NR==1{printf $4}')
if [ "${IMPLEMENTER}" != "0x48" ];then
echo "Only installed on kunpeng CPUs"
exit 1
fi
}
function build_all_components()
{
build_driver
build_uadk
build_engine
build_zlib
if [ "${IMPLEMENTER}-${CPUPART}" == "0x48-0xd01" ];then
echo "this cpu not support kaezstd and kaelz4."
else
build_zstd
build_lz4
fi
}
function clear_all_components()
{
driver_clean || true
uadk_clean || true
engine_clean || true
zlib_clean || true
if [ "${IMPLEMENTER}-${CPUPART}" == "0x48-0xd01" ];then
echo "this cpu not support kaezstd and kaelz4."
else
zstd_clean || true
lz4_clean || true
fi
}
main() {
check_environment
build_check_OS_version
case "$1" in
"all")
build_all_components
;;
"driver")
if [ "$2" = "clean" ]; then
driver_clean
elif [ "$2" = "sva" ]; then
build_driver_sva
else
build_driver
fi
;;
"uadk")
if [ "$2" = "clean" ]; then
uadk_clean
else
build_uadk
fi
;;
"engine")
if [ "$2" = "clean" ]; then
engine_clean
else
build_engine
fi
;;
"engine3")
if [ "$2" = "clean" ]; then
engine_clean_openssl3
else
build_engine_openssl3 $2
fi
;;
"engine_gmssl")
if [ "$2" = "clean" ]; then
engine_clean_gmssl
else
build_engine_gmssl
fi
;;
"zlib")
if [ "$2" = "clean" ]; then
zlib_clean
else
build_zlib
fi
;;
"zstd")
if [ "${IMPLEMENTER}-${CPUPART}" == "0x48-0xd01" ]; then
echo "This CPU does not support zstd."
else
if [ "$2" = "clean" ]; then
zstd_clean
else
build_zstd
fi
fi
;;
"lz4")
if [ "${IMPLEMENTER}-${CPUPART}" == "0x48-0xd01" ]; then
echo "This CPU does not support lz4."
else
if [ "$2" = "clean" ]; then
lz4_clean
else
build_lz4
fi
fi
;;
"rpm")
set +e
clear_all_components
set -e
build_rpm
;;
"rpmpack")
rm -rf /root/rpmbuild/SOURCES/kae* /root/rpmbuild/RPMS/aarch64/kae-* $KAE_BUILD
mkdir -p $KAE_BUILD /root/rpmbuild/SOURCES
tar -zcvf /root/rpmbuild/SOURCES/kae-2.0.3.tar.gz .
rpmbuild -bb $KAE_SPEC_FILE
cp /root/rpmbuild/RPMS/aarch64/kae* $KAE_BUILD
;;
"cleanup")
echo "Cleanup all"
clear_all_components
rm -rf $KAE_BUILD/*
;;
*)
help
;;
esac
}
main "$@"
exit $?
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。