From de72a098cc28dcbd1b85cfff12adec832acd20b4 Mon Sep 17 00:00:00 2001 From: yuzh <1109426275@qq.com> Date: Wed, 20 Aug 2025 10:55:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Edeb=E5=8C=85=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KAELz4/Makefile | 8 +- KAEZlib/Makefile | 9 +- KAEZlib/setup.sh | 6 -- README.md | 11 +++ build.sh | 133 +++++++++++++++++++++++++++++ package/debian/changelog | 8 ++ package/debian/compat | 1 + package/debian/control | 24 ++++++ package/debian/kae-driver.install | 21 +++++ package/debian/kae-driver.postinst | 13 +++ package/debian/kae-driver.postrm | 10 +++ package/debian/kae-driver.preinst | 14 +++ package/debian/kae-driver.prerm | 3 + package/debian/kae-zip.install | 10 +++ package/debian/kae-zip.postinst | 15 ++++ package/debian/kae-zip.postrm | 11 +++ package/debian/kae-zip.preinst | 15 ++++ package/debian/kae-zip.prerm | 2 + package/debian/rules | 64 ++++++++++++++ package/debian/source/format | 1 + 20 files changed, 371 insertions(+), 8 deletions(-) create mode 100644 package/debian/changelog create mode 100644 package/debian/compat create mode 100644 package/debian/control create mode 100644 package/debian/kae-driver.install create mode 100644 package/debian/kae-driver.postinst create mode 100644 package/debian/kae-driver.postrm create mode 100644 package/debian/kae-driver.preinst create mode 100644 package/debian/kae-driver.prerm create mode 100644 package/debian/kae-zip.install create mode 100644 package/debian/kae-zip.postinst create mode 100644 package/debian/kae-zip.postrm create mode 100644 package/debian/kae-zip.preinst create mode 100644 package/debian/kae-zip.prerm create mode 100644 package/debian/rules create mode 100644 package/debian/source/format diff --git a/KAELz4/Makefile b/KAELz4/Makefile index 2209132..746038b 100644 --- a/KAELz4/Makefile +++ b/KAELz4/Makefile @@ -66,7 +66,12 @@ OBJS = $(foreach x,$(SRCEXTS), \ .PHONY : all objs clean cleanall rebuild -all : $(TARGET) libkaelz4.a +all : $(TARGET) libkaelz4.a symlinks + +symlinks : $(TARGET) + @echo Creating symbolic links + $(SILENCE) $(LN) $(TARGET) $(SOFTLINK) + $(SILENCE) $(LN) $(TARGET) $(SOFTLINK).0 # Rules for creating the dependency files (.d). %.d : %.c @@ -90,6 +95,7 @@ rebuild: clean all clean : @-$(RM) *.d *.a *.so *.symbol $(TARGET) + @-$(RM) $(SOFTLINK) $(SOFTLINK).0 @-$(RM) @find ${WORK_PATH} -name '*.o' -exec $(RM) {} \; @echo all clean diff --git a/KAEZlib/Makefile b/KAEZlib/Makefile index d0306e6..9fdaad4 100644 --- a/KAEZlib/Makefile +++ b/KAEZlib/Makefile @@ -41,6 +41,7 @@ INCDIR += -I ${WORK_PATH}/../uadk/include INCDIR += -I ${WORK_PATH}/src/utils INCDIR += -I ${WORK_PATH}/src/v1 INCDIR += -I ${WORK_PATH}/src/v2 +INCDIR += -I ${WORK_PATH}/../kae_build/head/ # Include Libs. LIBDIR += -L/usr/lib64 @@ -69,7 +70,12 @@ OBJS = $(foreach x,$(SRCEXTS), \ .PHONY : all objs clean cleanall rebuild -all : $(TARGET) +all : $(TARGET) symlinks + +symlinks : $(TARGET) + @echo Creating symbolic links + $(SILENCE) $(LN) $(TARGET) $(SOFTLINK) + $(SILENCE) $(LN) $(TARGET) $(SOFTLINK).0 # Rules for creating the dependency files (.d). %.d : %.c @@ -88,6 +94,7 @@ rebuild: clean all clean : @-$(RM) *.d *.a *.so *.symbol $(TARGET) + @-$(RM) $(SOFTLINK) $(SOFTLINK).0 @-$(RM) @find ${WORK_PATH} -name '*.o' -exec $(RM) {} \; @echo all clean diff --git a/KAEZlib/setup.sh b/KAEZlib/setup.sh index e93217e..fb26925 100644 --- a/KAEZlib/setup.sh +++ b/KAEZlib/setup.sh @@ -45,9 +45,6 @@ function Dev_Build_kaezip() make clean make cd "${SRC_PATH}"/open_source/zlib-1.2.11/ - # patch -Np1 < ../../patch/kaezip_for_sec_CVE-2018-25032.patch - # patch -Np1 < ../../patch/kaezip_for_sec_CVE-2022-37434.patch - # patch -Np1 < ../../patch/kaezip_for_zlib-1.2.11.patch ./configure --prefix=/usr/local/kaezip make KAEBUILDPATH=${SRC_PATH}/../kae_build KAEZLIBPATH=${SRC_PATH} echo "build zlib success" @@ -63,9 +60,6 @@ function Build_kaezip() make install cd "${SRC_PATH}"/open_source/zlib-1.2.11/ - # patch -Np1 < ../../patch/kaezip_for_sec_CVE-2018-25032.patch - # patch -Np1 < ../../patch/kaezip_for_sec_CVE-2022-37434.patch - # patch -Np1 < ../../patch/kaezip_for_zlib-1.2.11.patch ./configure --prefix=/usr/local/kaezip export LD_LIBRARY_PATH=/usr/local/kaezip/lib:/usr/local/lib:$LD_LIBRARY_PATH make KAEBUILDPATH=${SRC_PATH}/../kae_build KAEZLIBPATH=${SRC_PATH} diff --git a/README.md b/README.md index dbad0fe..18254b5 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,17 @@ sh build.sh lz4 clean 压缩库lz4卸载 sh build.sh cleanup 一键式卸载 ``` +### 2.4.3 DEB包安装 + +当前分支代码支持在Debian OS(内核版本 5.15)上以deb包形式完成安装。 + +deb包构建的相关文件位于`package/debian`目录下。 + +deb包构建命令: +`bash build.sh debpack` + +执行成功后,会生成`output`目录,相关构建产物位于该目录下。 + # 三、常见问题 ## 3.1 安装问题 diff --git a/build.sh b/build.sh index 0cd96e4..041bbe7 100644 --- a/build.sh +++ b/build.sh @@ -263,6 +263,123 @@ function build_rpm() cp $KAE_LZ4_DIR/open_source/lz4-1.9.4/programs/lz4.1 $KAE_BUILD/kaelz4/share/man/man1 } +function build_deb() +{ + if [ -d $KAE_BUILD ]; then + rm -rf $KAE_BUILD/* + else + mkdir $KAE_BUILD + fi + mkdir -p $KAE_BUILD_LIB + mkdir -p $KAE_BUILD_HEAD + + local KERNEL_VERSION_BY_BUILDENV=`uname -r` + + # 编译 driver + cd ${KAE_KERNEL_DIR} + make -j + + mkdir -p $KAE_BUILD/driver + cp ${KAE_KERNEL_DIR}/hisilicon/hisi_qm.ko $KAE_BUILD/driver + cp ${KAE_KERNEL_DIR}/uacce/uacce.ko $KAE_BUILD/driver + cp ${KAE_KERNEL_DIR}/hisilicon/zip/hisi_zip.ko $KAE_BUILD/driver + cp ${KAE_KERNEL_DIR}/conf/hisi_zip.conf $KAE_BUILD/driver + + # 编译 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/0003-fix-uadk-openssl3-bug.patch || true + patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0003-fix-uadk-openssl3-bug.patch + patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0005-add-uadk-ecc-and-comp-header-for-kae.patch || true + patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0005-add-uadk-ecc-and-comp-header-for-kae.patch + patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0006-fix-uadk-lz77-data-error.patch || true + patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0006-fix-uadk-lz77-data-error.patch + + patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0007-uadk-support-lz77-only-for-kaelz4.patch || true + patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0007-uadk-support-lz77-only-for-kaelz4.patch + + patch --no-backup-if-mismatch -p1 -R -s --forward < ./scripts/patches/0008-uadk-support-sgl-zero-copy-for-kaelz4.patch || true + patch --no-backup-if-mismatch -p1 -N -s --forward < ./scripts/patches/0008-uadk-support-sgl-zero-copy-for-kaelz4.patch + + + cd $KAE_UADK_DIR + bash autogen.sh + # bash conf.sh + # 在 conf.sh中的内容后添加 --prefix 参数,为了使uadk编译生成的pkgconfig/*.pc文件中动态库的路径为RPM包编译时的临时目录,这样Opensslengine编译时才能够找到uadk动态库。 + ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ./configure \ + --enable-perf=yes \ + --host aarch64-linux-gnu \ + --target aarch64-linux-gnu \ + --includedir=/usr/local/include/ \ + --disable-static --enable-shared \ + --prefix=$KAE_BUILD/uadk/ + make -j + + mkdir -p $KAE_BUILD/uadk/lib + mkdir -p $KAE_BUILD/uadk/include + mkdir -p $KAE_BUILD/uadk/include/v1 + mkdir -p $KAE_BUILD/uadk/include/drv + mkdir -p $KAE_BUILD/uadk/pkgconfig + + cp -a ${KAE_UADK_DIR}/.libs/*so* $KAE_BUILD/uadk/lib + cp -r $KAE_UADK_DIR/include/*.h $KAE_BUILD/uadk/include + cp -r $KAE_UADK_DIR/v1/*.h $KAE_BUILD/uadk/include/v1 + cp -r $KAE_UADK_DIR/include/drv/*.h $KAE_BUILD/uadk/include/drv + cp -r $KAE_UADK_DIR/lib/*.pc $KAE_BUILD/uadk/pkgconfig + + mkdir -p $KAE_BUILD_HEAD/uadk + mkdir -p $KAE_BUILD_HEAD/uadk/v1 + mkdir -p $KAE_BUILD_HEAD/uadk/drv + + cp -r $KAE_UADK_DIR/include/*.h $KAE_BUILD_HEAD/uadk + cp -r $KAE_UADK_DIR/v1/*.h $KAE_BUILD_HEAD/uadk/v1 + cp -r $KAE_UADK_DIR/include/drv/*.h $KAE_BUILD_HEAD/uadk/drv + + mkdir -p $KAE_BUILD/lib + cp -a ${KAE_UADK_DIR}/.libs/*so* $KAE_BUILD/lib + + # 编译 zlib + cd $KAE_ZLIB_DIR + bash setup.sh devbuild KAE2 + + mkdir -p $KAE_BUILD/kaezip + mkdir -p $KAE_BUILD/kaezip/include + mkdir -p $KAE_BUILD/kaezip/lib + mkdir -p $KAE_BUILD/kaezip/lib/pkgconfig + mkdir -p $KAE_BUILD/kaezip/share/man/man3 + + cp -a $KAE_ZLIB_DIR/lib* $KAE_BUILD/kaezip/lib + cp -a $KAE_ZLIB_DIR/open_source/zlib-1.2.11/lib* $KAE_BUILD/kaezip/lib + cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/zlib.pc $KAE_BUILD/kaezip/lib/pkgconfig + cp $KAE_ZLIB_DIR/include/*.h $KAE_BUILD/kaezip/include + cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/zlib.h $KAE_BUILD/kaezip/include + cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/zconf.h $KAE_BUILD/kaezip/include + cp $KAE_ZLIB_DIR/open_source/zlib-1.2.11/zlib.3 $KAE_BUILD/kaezip/share/man/man3 + + # 编译 lz4 + cd ${SRC_PATH}/KAELz4 + bash build.sh devbuild + + mkdir -p $KAE_BUILD/kaelz4/lib + mkdir -p $KAE_BUILD/kaelz4/bin + mkdir -p $KAE_BUILD/kaelz4/include + mkdir -p $KAE_BUILD/kaelz4/share/man/man1 + + cp -a $KAE_LZ4_DIR/lib* $KAE_BUILD/kaelz4/lib + cp -a $KAE_LZ4_DIR/open_source/lz4-1.9.4/lib/liblz4.so* $KAE_BUILD/kaelz4/lib + cp $KAE_LZ4_DIR/open_source/lz4-1.9.4/lib/liblz4.a $KAE_BUILD/kaelz4/lib + + cp $KAE_LZ4_DIR/open_source/lz4-1.9.4/programs/lz4 $KAE_BUILD/kaelz4/bin + + + cp $KAE_LZ4_DIR/open_source/lz4-1.9.4/lib/*.h $KAE_BUILD/kaelz4/include + cp $KAE_LZ4_DIR/include/*.h $KAE_BUILD/kaelz4/include + cp $KAE_LZ4_DIR/src/utils/kaelz4_log.h $KAE_BUILD/kaelz4/include + + cp $KAE_LZ4_DIR/open_source/lz4-1.9.4/programs/lz4.1 $KAE_BUILD/kaelz4/share/man/man1 +} + function build_driver() { cd ${KAE_KERNEL_DIR} @@ -561,6 +678,7 @@ function help() echo "build KAE" echo "bash build.sh all -- install all component(not include gmssl)" echo "bash build.sh rpmpack -- build rpm pack(not include gmssl)" + echo "bash build.sh debpack -- build deb pack(include driver, uadk, zlib and lz4)" echo "bash build.sh driver -- install KAE driver" echo "bash build.sh driver clean -- uninstall KAE driver" @@ -748,6 +866,21 @@ main() { rpmbuild -bb $KAE_SPEC_FILE cp /root/rpmbuild/RPMS/aarch64/kae* $KAE_BUILD ;; + "deb") + set +e + clear_all_components + set -e + build_deb + ;; + "debpack") + rm -rf $KAE_BUILD ${SRC_PATH}/output/ + cd ${SRC_PATH}/package/ + dpkg-buildpackage -us -uc + cd ${SRC_PATH} + mkdir -p ${SRC_PATH}/output/ + mv *.deb ${SRC_PATH}/output/ + mv kae_*.dsc kae_*.tar.gz kae_*.buildinfo kae_*.changes ${SRC_PATH}/output/ + ;; "cleanup") echo "Cleanup all" clear_all_components diff --git a/package/debian/changelog b/package/debian/changelog new file mode 100644 index 0000000..ba99f5e --- /dev/null +++ b/package/debian/changelog @@ -0,0 +1,8 @@ +kae (1.0.0) unstable; urgency=medium + + * Initial Debian package release + * Includes: + - kae-driver kernel modules + - kae-zip compression libraries + + -- Maintainer yuzh Fri, 15 Aug 2025 12:00:00 +0800 \ No newline at end of file diff --git a/package/debian/compat b/package/debian/compat new file mode 100644 index 0000000..3cacc0b --- /dev/null +++ b/package/debian/compat @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/package/debian/control b/package/debian/control new file mode 100644 index 0000000..746c007 --- /dev/null +++ b/package/debian/control @@ -0,0 +1,24 @@ +Source: kae +Section: libs +Priority: optional +Standards-Version: 1.0.0 +Maintainer: Huawei Technologies +Build-Depends: autoconf, + automake, + libtool, + m4, + pkg-config, + dh-autoreconf, + libnuma-dev + +Package: kae-driver +Architecture: arm64 +Depends: ${shlibs:Depends} +Description: KAE Driver Package + Huawei Kunpeng Accelerator Engine kernel modules and libraries. + +Package: kae-zip +Architecture: arm64 +Depends: ${shlibs:Depends} +Description: KAE Zip Libraries + Huawei Kunpeng Accelerator Engine for Zip compression. \ No newline at end of file diff --git a/package/debian/kae-driver.install b/package/debian/kae-driver.install new file mode 100644 index 0000000..ea82de8 --- /dev/null +++ b/package/debian/kae-driver.install @@ -0,0 +1,21 @@ +# driver +lib/modules/*/extra/*.ko + +# conf +etc/modprobe.d/*.conf + +# uadk library +usr/local/lib/libwd.* +usr/local/lib/libwd_comp.* +usr/local/lib/libwd_crypto.* +usr/local/lib/libhisi_hpre.* +usr/local/lib/libhisi_sec.* +usr/local/lib/libhisi_zip.* +usr/local/lib/libhisi_dae.* +usr/local/lib/libisa_ce.* +usr/local/lib/libisa_sve.* +usr/local/lib/libwd_dae.* + +# uadk header file +usr/include/uadk/*.h +usr/include/uadk/drv/*.h \ No newline at end of file diff --git a/package/debian/kae-driver.postinst b/package/debian/kae-driver.postinst new file mode 100644 index 0000000..933dd50 --- /dev/null +++ b/package/debian/kae-driver.postinst @@ -0,0 +1,13 @@ +#!/bin/bash +case "$1" in + configure) + # 加载内核模块 + depmod -a + modprobe uacce + modprobe hisi_qm + modprobe hisi_zip uacce_mode=2 pf_q_num=256 + # 创建配置文件 + echo "options hisi_zip uacce_mode=2 pf_q_num=256" > /etc/modprobe.d/hisi_zip.conf + /sbin/ldconfig + ;; +esac \ No newline at end of file diff --git a/package/debian/kae-driver.postrm b/package/debian/kae-driver.postrm new file mode 100644 index 0000000..f43efab --- /dev/null +++ b/package/debian/kae-driver.postrm @@ -0,0 +1,10 @@ +rm -rf /usr/local/lib/libwd.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_comp.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_crypto.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_hpre.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_sec.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_zip.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_dae.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libisa_ce.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libisa_sve.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_dae.* > /dev/null 2>&1 || true \ No newline at end of file diff --git a/package/debian/kae-driver.preinst b/package/debian/kae-driver.preinst new file mode 100644 index 0000000..c15a747 --- /dev/null +++ b/package/debian/kae-driver.preinst @@ -0,0 +1,14 @@ +echo "Preprocessing before installing the driver" +modprobe -r hisi_zip > /dev/null 2>&1 || true +modprobe -r hisi_qm > /dev/null 2>&1 || true +modprobe -r uacce > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_comp.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_crypto.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_hpre.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_sec.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_zip.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libhisi_dae.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libisa_ce.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libisa_sve.* > /dev/null 2>&1 || true +rm -rf /usr/local/lib/libwd_dae.* > /dev/null 2>&1 || true \ No newline at end of file diff --git a/package/debian/kae-driver.prerm b/package/debian/kae-driver.prerm new file mode 100644 index 0000000..7c27d08 --- /dev/null +++ b/package/debian/kae-driver.prerm @@ -0,0 +1,3 @@ +modprobe -r hisi_zip || true +modprobe -r hisi_qm || true +modprobe -r uacce || true \ No newline at end of file diff --git a/package/debian/kae-zip.install b/package/debian/kae-zip.install new file mode 100644 index 0000000..7742088 --- /dev/null +++ b/package/debian/kae-zip.install @@ -0,0 +1,10 @@ +# Zlib +usr/local/kaezip/lib/* +usr/local/kaezip/include/*.h +usr/local/kaezip/share/man/man3/* + +# LZ4 +usr/local/kaelz4/lib/* +usr/local/kaelz4/bin/* +usr/local/kaelz4/include/*.h +usr/local/kaelz4/share/man/man1/* \ No newline at end of file diff --git a/package/debian/kae-zip.postinst b/package/debian/kae-zip.postinst new file mode 100644 index 0000000..ddce868 --- /dev/null +++ b/package/debian/kae-zip.postinst @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +case "$1" in + configure) + implementer=$(grep "CPU implementer" /proc/cpuinfo | awk 'NR==1{print $4}') + part=$(grep "CPU part" /proc/cpuinfo | awk 'NR==1{print $4}') + if [ "${implementer}-${part}" != "0x48-0xd02" ]; then + rm -rf /usr/local/kaelz4 + fi + /sbin/ldconfig + ;; +esac + +exit 0 diff --git a/package/debian/kae-zip.postrm b/package/debian/kae-zip.postrm new file mode 100644 index 0000000..917a277 --- /dev/null +++ b/package/debian/kae-zip.postrm @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +rm -rf /usr/local/kaezip > /dev/null 2>&1 || true +rm -f /var/log/kaezip.log* > /dev/null 2>&1 || true +implementer=$(cat /proc/cpuinfo | grep "CPU implementer" | awk 'NR==1{printf $4}') +part=$(cat /proc/cpuinfo | grep "CPU part" | awk 'NR==1{printf $4}') +if [ "${implementer}-${part}" != "0x48-0xd01" ]; then + rm -rf /usr/local/kaelz4 > /dev/null 2>&1 || true + rm -f /var/log/kaelz4.log* > /dev/null 2>&1 || true +fi +/sbin/ldconfig diff --git a/package/debian/kae-zip.preinst b/package/debian/kae-zip.preinst new file mode 100644 index 0000000..a07226d --- /dev/null +++ b/package/debian/kae-zip.preinst @@ -0,0 +1,15 @@ +#!/bin/bash +set -e # 遇到错误立即退出 +echo "Running pre-installation cleanup for zip package..." + +implementer=$(grep "CPU implementer" /proc/cpuinfo | awk 'NR==1{print $4}') +part=$(grep "CPU part" /proc/cpuinfo | awk 'NR==1{print $4}') +if [ "${implementer}-${part}" != "0x48-0xd01" ] && [ "${implementer}-${part}" != "0x48-0xd02" ]; then + echo "WARNING: Not Kunpeng CPU - hardware acceleration disabled" +fi + +if [ "$1" = "upgrade" ]; then + rm -rf /usr/local/kaezip >/dev/null 2>&1 || true +fi + +exit 0 diff --git a/package/debian/kae-zip.prerm b/package/debian/kae-zip.prerm new file mode 100644 index 0000000..5de91bf --- /dev/null +++ b/package/debian/kae-zip.prerm @@ -0,0 +1,2 @@ +#!/bin/bash +echo "uninstalling zip-deb" diff --git a/package/debian/rules b/package/debian/rules new file mode 100644 index 0000000..0508ef0 --- /dev/null +++ b/package/debian/rules @@ -0,0 +1,64 @@ +#!/usr/bin/make -f + +KERNEL_VER := $(shell uname -r) +PROJECT_ROOT := $(CURDIR)/.. + +%: + dh $@ --without usrlocal + +override_dh_auto_configure: + # CPU check + implementer=$$(grep "CPU implementer" /proc/cpuinfo | awk 'NR==1{print $$4}'); \ + part=$$(grep "CPU part" /proc/cpuinfo | awk 'NR==1{print $$4}'); \ + if [ "$${implementer}-$${part}" != "0x48-0xd01" ] && [ "$${implementer}-$${part}" != "0x48-0xd02" ]; then \ + echo "Error: Only supported on Kunpeng CPUs"; \ + exit 1; \ + fi + +override_dh_auto_build: + cd $(PROJECT_ROOT) && bash build.sh deb + +override_dh_auto_install: + # driver path + install -d debian/tmp/lib/modules/$(KERNEL_VER)/extra/ + install -d debian/tmp/etc/modprobe.d/ + + # uadk path + install -d debian/tmp/usr/local/lib/ + install -d debian/tmp/usr/include/uadk/ + install -d debian/tmp/usr/include/uadk/drv/ + + # zlib path + install -d debian/tmp/usr/local/kaezip/lib/ + install -d debian/tmp/usr/local/kaezip/include/ + install -d debian/tmp/usr/local/kaezip/share/man/man3/ + + # lz4 path + install -d debian/tmp/usr/local/kaelz4/lib/ + install -d debian/tmp/usr/local/kaelz4/include/ + install -d debian/tmp/usr/local/kaelz4/bin/ + install -d debian/tmp/usr/local/kaelz4/share/man/man1/ + + # install driver + install -b -m755 $(PROJECT_ROOT)/kae_build/driver/*.ko debian/tmp/lib/modules/$(KERNEL_VER)/extra/ + install -b -m755 $(PROJECT_ROOT)/kae_build/driver/*.conf debian/tmp/etc/modprobe.d/ + + # install uadk + chrpath -d $(PROJECT_ROOT)/kae_build/uadk/lib/* + install -b -m755 $(PROJECT_ROOT)/kae_build/uadk/include/*.h debian/tmp/usr/include/uadk/ + install -b -m755 $(PROJECT_ROOT)/kae_build/uadk/include/drv/*.h debian/tmp/usr/include/uadk/drv/ + cp -a $(PROJECT_ROOT)/kae_build/uadk/lib/* debian/tmp/usr/local/lib/ + + # install zlib library + cp -a $(PROJECT_ROOT)/kae_build/kaezip/lib/* debian/tmp/usr/local/kaezip/lib/ + cp -a $(PROJECT_ROOT)/kae_build/kaezip/include/* debian/tmp/usr/local/kaezip/include/ + cp -a $(PROJECT_ROOT)/kae_build/kaezip/share/* debian/tmp/usr/local/kaezip/share/ + + # install lz4 library + cp -a $(PROJECT_ROOT)/kae_build/kaelz4/lib/* debian/tmp/usr/local/kaelz4/lib/ + cp -a $(PROJECT_ROOT)/kae_build/kaelz4/bin/* debian/tmp/usr/local/kaelz4/bin/ + cp -a $(PROJECT_ROOT)/kae_build/kaelz4/include/* debian/tmp/usr/local/kaelz4/include/ + cp -a $(PROJECT_ROOT)/kae_build/kaelz4/share/* debian/tmp/usr/local/kaelz4/share/ + +override_dh_usrlocal: + @echo "skip dh_usrlocal checking" \ No newline at end of file diff --git a/package/debian/source/format b/package/debian/source/format new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/package/debian/source/format @@ -0,0 +1 @@ +1.0 \ No newline at end of file -- Gitee