Name:          libwd
Summary:       User Space Accelerator Development Kit
Version:       2.3.21
Release:       5
License:       Apache-2.0
Source:        %{name}-%{version}.tar.gz
Vendor:        Huawei Corporation
ExclusiveOS:   linux
URL:           https://support.huawei.com
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Conflicts:     %{name} < %{version}-%{release}
Provides:      %{name} = %{version}-%{release}
BuildRequires: numactl-devel, openssl-devel
BuildRequires: automake, autoconf, libtool
BuildRequires: gcc, make
ExclusiveArch: aarch64
Patch0001:     0001-uadk-digest-add-stream-mode-for-digest-sync.patch
Patch0002:     0002-test-digest-support-the-digest-stream-mode.patch
Patch0003:     0003-aead-cipher-digest-fix-some-code-issues.patch
Patch0004:     0004-digest-v1-fixed-hmac-key-0-length-checking.patch
Patch0005:     0005-digest-v1-check-the-length-of-the-key-need-to-be-cha.patch
Patch0006:     0006-qm-v1-fixup-the-incorrect-configuration-of-the-type.patch
Patch0007:     0007-qm-fixup-the-incorrect-configuration-of-the-type.patch
Patch0008:     0008-uadk_benchmark-use-the-uadk_tool-instead-of-uadk_ben.patch
Patch0009:     0009-digest-some-optimizations-for-digest-stream-mode.patch
Patch0010:     0010-uadk-fix-error-of-wd_get_avail_ctx-return-value.patch
Patch0011:     0011-uadk-fix-comment-content.patch
Patch0012:     0012-uadk-max-numa-number-should-not-be-fixed.patch
Patch0013:     0013-uadk-mempool-remove-MISC_DVE_UACCE_CTRL.patch
Patch0014:     0014-uadk-mempool-check-stats-null-pointer.patch
Patch0015:     0015-uadk-fix-wd_get_config_numa-info.patch
Patch0016:     0016-uadk-fix-static-check-warning.patch
Patch0017:     0017-uadk-fix-numa-array-use-too-much-stack-space.patch
Patch0018:     0018-uadk-fix-get_dev_info.patch
Patch0019:     0019-uadk-fix-pthread_spin_init.patch
Patch0020:     0020-uadk-env-optimize-find_async_queue.patch
Patch0021:     0021-uadk-env-optimize-some-function.patch
Patch0022:     0022-uadk-v1-delete-unused-parameter.patch
Patch0023:     0023-uadk-env-fix-wd_add_task_to_async_queue-return-value.patch
Patch0024:     0024-uadk-sched-fix-memory-leak.patch
Patch0025:     0025-hisi-sec-bugfix-for-out_bytes-checking.patch
Patch0026:     0026-uadk-tools-modify-NO-SVA-test-scenario.patch
Patch0027:     0027-wd-fix-wd_parse_async_poll_num.patch
Patch0028:     0028-uadk-optimize-wd_init_async_polling_thread_per_numa.patch
Patch0029:     0029-uadk-env-fix-wd_add_task_to_async_queue.patch
Patch0030:     0030-uadk-optimize-find_async_queue.patch
Patch0031:     0031-uadk-fix-check_after_sink.patch
Patch0032:     0032-uadk-fix-wd_request_ctx.patch
Patch0033:     0033-uadk-fix-sched-params-begin-issue.patch
Patch0034:     0034-uadk-optimize-wd_request_ctx.patch
Patch0035:     0035-uadk-env-bugfix-for-wd_init_resource.patch
Patch0036:     0036-uadk-env-fix-wd-ctx-num-init.patch
Patch0037:     0037-uadk-modify-for-free-and-return.patch
Patch0038:     0038-uadk-include-fix-uadk-compatibility.patch
Patch0039:     0039-uadk-fix-for-resources-are-repeatedly-released.patch
Patch0040:     0040-aead-modify-the-aead-s-request-api.patch
Patch0041:     0041-cipher-add-semi-weak-keys-checking.patch
Patch0042:     0042-uadk-ioctl-return-result-should-be-printed.patch
Patch0043:     0043-uadk-fix-environment-uninit-repeatly-error.patch
Patch0044:     0044-uadk-fix-wd_free_ctx-and-wd_uninit_sched_config.patch
Patch0045:     0045-uadk-env-fix-free-ctx-table-memory-leak.patch
Patch0046:     0046-uadk-remove-uadk_benchmark-binary-and-header-file.patch
Patch0047:     0047-uadk-fix-for-wd_env_config-numa_num.patch
Patch0048:     0048-hisi-sec-add-some-dfx-information-in-comments.patch
Patch0049:     0049-hisi-sec-delete-some-dummy-parameter-checking.patch
Patch0050:     0050-hisi-qm-udrv-v1-deleted-a-dummy-branch.patch
Patch0051:     0051-hisi-sec-v1-update-the-SEC-BD1-mode-configuration.patch
Patch0052:     0052-uadk-optimize-algorithm-initialization.patch
Patch0053:     0053-uadk-fix-send-exception-handling.patch
Patch0054:     0054-uadk-sec-fix-hisi_sec_digest_send.patch
Patch0055:     0055-uadk-sec-some-clean-code.patch
Patch0056:     0056-uadk-optimize-wd_ctx_qfr_mmap.patch
Patch0057:     0057-uadk-optimize-wd_sched_rr_instance.patch
Patch0058:     0058-uadk-optimize-wd_get_accel_list.patch
Patch0059:     0059-uadk-fix-staic-check-warning.patch
Patch0060:     0060-uadk-v1-fix-the-waiting-time-for-receiving-task.patch
Patch0061:     0061-uadk-comp-optimize-for-spin-lock.patch
Patch0062:     0062-hisi-comp-cleanup-for-duplication-code.patch
Patch0063:     0063-wd_comp-remove-some-useless-printf.patch
Patch0064:     0064-sample-add-a-demo-for-comp.patch
Patch0065:     0065-uadk-tool-modify-uadk_benchmark-toos-code.patch
Patch0066:     0066-uadk-tools-modify-uadk-benchmark-clean-code.patch
Patch0067:     0067-uadk-v1-fix-for-cookie-initialization.patch
Patch0068:     0068-uadk-update-file-permission-on-cleanup.patch
Patch0069:     0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
Patch0070:     0070-rsa-fix-interface-name-and-log-msg.patch
Patch0071:     0071-uadk-modify-param-verification.patch
Patch0072:     0072-uadk-v1-cleanup-ret-value.patch
Patch0073:     0073-uadk-wd-fixup-about-checking-device.patch
Patch0074:     0074-uadk-cleanup-hpre-code.patch
Patch0075:     0075-uadk-v1-fix-pool-cstatus-memset-problem.patch
Patch0076:     0076-uadk-bugfix-segment-fault-when-uninitializing.patch
Patch0077:     0077-drv-sec-support-sm4-ecb-alg-by-new-fs.patch
Patch0078:     0078-digest-simplify-the-process-of-represent-BD-state.patch
Patch0079:     0079-uadk-qm_udrv-Modify-goto-err_out.patch
Patch0080:     0080-uadk-unify-wd-print-format.patch
Patch0081:     0081-uadk-v1-fix-wd_bmm-pool_init.patch
Patch0082:     0082-uadk-v1-fix-wd-create-ctx-memory-leak.patch
Patch0083:     0083-uadk-mempool-fix-redundant-assignment.patch
Patch0084:     0084-uadk-v1-fix-del-ctx.patch
Patch0085:     0085-uadk-v1-clean-code-for-wd.patch
Patch0086:     0086-uadk-v1-fix-drv_reserve_mem-memory-leak.patch
Patch0087:     0087-uadk-cipher-fix-wd_cipher_check_params.patch
Patch0088:     0088-sec-unify-print-format.patch
Patch0089:     0089-drv-hpre-unify-print-format.patch
Patch0090:     0090-rsa-dh-ecc-unify-print-format.patch
Patch0091:     0091-drv-hpre-free-memory-when-BD-sends-failed.patch
Patch0092:     0092-v1-hpre-add-unlikely-for-branch-prefetch.patch
Patch0093:     0093-comp-unify-print-format.patch
Patch0094:     0094-drv-comp-unify-print-format.patch
Patch0095:     0095-comp-add-unlikely-for-branch-prefetch.patch
Patch0096:     0096-drv-comp-add-unlikely-for-branch-prefetch.patch
Patch0097:     0097-hisi_hpre-modify-the-return-value-of-function.patch
Patch0098:     0098-uadk-parse-epoll-flag-from-environment-variable.patch
Patch0099:     0099-test-enable-epoll-in-sanity-scripts.patch

%description
This package contains the User Space Accelerator Library
for hardware accelerator, compress, symmetric encryption
and decryption, asymmetric encryption and decryption.

%prep
%global debug_package %{nil}
%autosetup -n %{name}-%{version} -p1

%build
sh autogen.sh
./configure
make

%install
mkdir -p ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libwd.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libwd_crypto.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libwd_comp.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libhisi_sec.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libhisi_hpre.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
install -b -m755 .libs/libhisi_zip.so.%{version} ${RPM_BUILD_ROOT}/usr/lib64
mkdir -p ${RPM_BUILD_ROOT}/usr/include/warpdrive/include
cp v1/uacce.h ${RPM_BUILD_ROOT}/usr/include/warpdrive/include
cp v1/wd.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_cipher.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_comp.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_dh.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_digest.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_rsa.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
cp v1/wd_bmm.h ${RPM_BUILD_ROOT}/usr/include/warpdrive
mkdir -p ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp include/uacce.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_cipher.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_comp.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_dh.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_digest.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_rsa.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_aead.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_ecc.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_ecc_curve.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_alg_common.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_common.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp include/wd_sched.h ${RPM_BUILD_ROOT}/usr/include/uadk
cp v1/uacce.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_cipher.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_comp.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_dh.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_digest.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_rsa.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1
cp v1/wd_bmm.h ${RPM_BUILD_ROOT}/usr/include/uadk/v1

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(755,root,root)
/usr/lib64/libwd.so.%{version}
/usr/lib64/libwd_crypto.so.%{version}
/usr/lib64/libwd_comp.so.%{version}
/usr/lib64/libhisi_sec.so.%{version}
/usr/lib64/libhisi_hpre.so.%{version}
/usr/lib64/libhisi_zip.so.%{version}
%defattr(644,root,root)
/usr/include/warpdrive/include/uacce.h
/usr/include/warpdrive/wd.h
/usr/include/warpdrive/wd_cipher.h
/usr/include/warpdrive/wd_comp.h
/usr/include/warpdrive/wd_dh.h
/usr/include/warpdrive/wd_digest.h
/usr/include/warpdrive/wd_rsa.h
/usr/include/warpdrive/wd_bmm.h
/usr/include/uadk/uacce.h
/usr/include/uadk/wd.h
/usr/include/uadk/wd_cipher.h
/usr/include/uadk/wd_comp.h
/usr/include/uadk/wd_dh.h
/usr/include/uadk/wd_digest.h
/usr/include/uadk/wd_rsa.h
/usr/include/uadk/wd_aead.h
/usr/include/uadk/wd_ecc.h
/usr/include/uadk/wd_ecc_curve.h
/usr/include/uadk/wd_alg_common.h
/usr/include/uadk/wd_common.h
/usr/include/uadk/wd_sched.h
/usr/include/uadk/v1/uacce.h
/usr/include/uadk/v1/wd.h
/usr/include/uadk/v1/wd_cipher.h
/usr/include/uadk/v1/wd_comp.h
/usr/include/uadk/v1/wd_dh.h
/usr/include/uadk/v1/wd_digest.h
/usr/include/uadk/v1/wd_rsa.h
/usr/include/uadk/v1/wd_bmm.h
%exclude /usr/lib64/libwd.so.2
%exclude /usr/lib64/libwd_crypto.so.2
%exclude /usr/lib64/libwd_comp.so.2
%exclude /usr/lib64/libhisi_sec.so.2
%exclude /usr/lib64/libhisi_hpre.so.2
%exclude /usr/lib64/libhisi_zip.so.2

%pre
if [ "$1" = "2" ] ; then  #2: update
    rm -rf /usr/lib64/libwd.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_crypto.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_crypto.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_comp.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_comp.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_sec.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_sec.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_hpre.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_hpre.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_zip.so   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_zip.so.2   > /dev/null 2>&1 || true
fi

%post
if [[ "$1" = "1" || "$1" = "2" ]] ; then  #1: install 2: update
    cd /usr/lib64
    ln -sf libwd.so.%{version} libwd.so
    ln -sf libwd.so.%{version} libwd.so.2
    ln -sf libwd_crypto.so.%{version} libwd_crypto.so
    ln -sf libwd_crypto.so.%{version} libwd_crypto.so.2
    ln -sf libwd_comp.so.%{version} libwd_comp.so
    ln -sf libwd_comp.so.%{version} libwd_comp.so.2
    ln -sf libhisi_sec.so.%{version} libhisi_sec.so
    ln -sf libhisi_sec.so.%{version} libhisi_sec.so.2
    ln -sf libhisi_hpre.so.%{version} libhisi_hpre.so
    ln -sf libhisi_hpre.so.%{version} libhisi_hpre.so.2
    ln -sf libhisi_zip.so.%{version} libhisi_zip.so
    ln -sf libhisi_zip.so.%{version} libhisi_zip.so.2
fi
/sbin/ldconfig

%preun
if [ "$1" = "0" ] ; then  #0: uninstall
    rm -rf /usr/lib64/libwd.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd.so.2    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_crypto.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_crypto.so.2    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_comp.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libwd_comp.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_sec.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_sec.so.2   > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_hpre.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_hpre.so.2    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_zip.so    > /dev/null 2>&1 || true
    rm -rf /usr/lib64/libhisi_zip.so.2    > /dev/null 2>&1 || true
fi

%postun
/sbin/ldconfig

%changelog
* Mon Mar 21 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-5
- libwd: backport the patch of uadk from 2.3.28 to 2.3.31

* Tue Mar 1 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-4
- libwd: backport the patch of uadk from 2.3.27 to 2.3.28

* Mon Feb 21 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-3
- libwd: backport the patch of uadk from 2.3.24 to 2.3.27

* Tue Jan 04 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-2
- libwd: backport the patch of uadk from 2.3.21 to 2.3.24

* Mon Dec 06 2021 linwenkai <linwenkai6@hisilicon.com> 2.3.21-1
- libwd: update uadk from 2.3.20 to 2.3.21

* Wed Nov 24 2021 linwenkai <linwenkai6@hisilicon.com> 2.3.20-2
- libwd: add missing head files and fix install path

* Mon Nov 22 2021 Yang Shen <shenyang39@huawei.com> 2.3.20-1
- libwd: update uadk from 2.3.11 to 2.3.20

* Fri Sep 03 2021 Yang Shen <shenyang39@huawei.com> 2.3.11-4
- uadk-access-the-file-isolate-before-read-it.patch

* Fri Aug 06 2021 Pengju Jiang <jiangpengju2@huawei.com> 2.3.11-3
- bugfix-of-gcc-10.patch

* Wed Jul 21 2021 caodongxia <caodongxia@huawei.com> 2.3.11-2
- change uacce.h path.

* Tue Jul 06 2021 Hao Fang <fanghao11@huawei.com> 2.3.11-1
- update warpdrive to uadk, support kunpeng 920/930.

* Sun Mar 15 2020 zhangtao <zhangtao221@huawei.com> 1.2.10-3
- Specify compilation aarch64 as platform

* Tue Mar 03 2020 catastrowings <jianghuhao1994@163.com> 1.2.10-2
- openEuler init

* Tue Jan 07 2020 jinbinhua <jinbinhua@huawei.com> 1.2.7-1
- First Spec Version Include Warpdrive Code
