# 不输出debug信息,不产生debug包 %define debug_package %{nil} # 定义openHarmony软件包的版本变量,所有包应该都是OpenHarmony-v3.2-Release %global oh_version OpenHarmony-v3.2-Release # 定义下编译根目录变量,此处用/root/rpmbuild/BUILD/distributed_build作为编译根目录 %global build_opt /opt/distributed-middleware-build %global bundle_dir %{build_opt}/openeuler/compiler_gn/base/notification/eventhandler %global eventhandler_path %{_builddir}/base/notification # rpm包名称 Name: notification_eventhandler # rpm包版本号 Version: 1.0.0 # rpm包Release号,每次修改需要+1,changelog同步修改 Release: 1 # rpm简介 Summary: C++ common basic library for distributed module construction and operation # License openHarmony的应该都是Apache License 2.0 License: Apache License 2.0 # 软件包上游社区 Url: https://gitee.com/openharmony/notification_eventhandler # tar包的下载地址,由于gitee下载路径是不带软件包名的,会导致和name不匹配, # 所以此处在后面用注释方式修改spec识别的tar包名称,属于取巧,但无可奈何。 Source1: https://gitee.com/openharmony/notification_eventhandler/repository/archive/%{oh_version}.tar.gz #/%{name}-%{oh_version}.tar.gz Source2: eventhandler.bundle.json Source3: eventhandler.BUILD.gn # 补丁定义 Patch0001: 0001-notification-eventhandler.patch # 编译依赖,提交代码时需要分析依赖层级,从底往上提交代码。 BuildRequires: distributed-build, hilog, commonlibrary_c_utils BuildRequires: python3-jinja2 python3-pyyaml BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel Requires: hilog # 软件包的详细描述 %description Provide some commonly used C++ development tool classes for standard systems, This repository is compatible with compilation on the OpenEuler operating system # 软件包编译前的准备阶段 %prep # 解压tar包到commonlibrary_c_utils-OpenHarmony-v3.2-Release路径下 rm -rf %{_builddir}/* # build directory cp -rf %{build_opt} %{_builddir}/build [ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh [ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn [ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py cp -r %{_builddir}/build/openeuler/vendor %{_builddir}/ cp -r %{_builddir}/build/openeuler/compiler_gn/third_party %{_builddir}/ # 统一用setup,不用autosetup,distributed-build除外 mkdir -p %{eventhandler_path} %setup -q -D -T -a 1 -c -n %{eventhandler_path} mv %{name}-%{oh_version} %{eventhandler_path}/eventhandler # patch命令统一使用-P来指定第几个patch %patch -P1 -p1 -d %{eventhandler_path}/eventhandler # 拷贝依赖的组件的gn文件 mkdir -p %{_builddir}/base/hiviewdfx mkdir -p %{_builddir}/commonlibrary cp -rf %{_builddir}/build/openeuler/compiler_gn/base/hiviewdfx/hilog %{_builddir}/base/hiviewdfx cp -rf %{_builddir}/build/openeuler/compiler_gn/commonlibrary/c_utils %{_builddir}/commonlibrary # 编译阶段 %build rm -rf %{_builddir}/out %ifarch x86_64 bash %{_builddir}/build.sh --product-name openeuler --target-cpu x86_64 %endif %ifarch aarch64 bash %{_builddir}/build.sh --product-name openeuler --target-cpu arm64 %endif # 安装阶段 %install install -d -m 0755 %{buildroot}/%{_includedir}/eventhandler install -d -m 0755 %{buildroot}/%{bundle_dir}/ # 建so文件目录 /usr/lib64 install -d -m 0755 %{buildroot}/%{_libdir} # innerkits/linux-arm64/eventhandler %ifarch aarch64 %define module_out_path out/openeuler/linux_clang_arm64 %endif %ifarch x86_64 %define module_out_path out/openeuler/linux_clang_x86_64 %endif #copy shared library files %define so_out_path %{module_out_path}/notification/eventhandler install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler_native.z.so %{buildroot}/%{_libdir} install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler.z.so %{buildroot}/%{_libdir} # %define sdk_out_path %{module_out_path}/eventhandler # cp -rf %{_builddir}/${sdk_out_path}/* %{buildroot}/%{bundle_dir}/ cp -rf %{SOURCE2} %{buildroot}/%{bundle_dir}/bundle.json # 到源码路径下拷贝头文件及其目录到%{buildroot}/usr/include/eventhandler下,保持目录结构相同 install -m 554 %{_builddir}/base/notification/eventhandler/interfaces/inner_api/*.h %{buildroot}/%{_includedir}/eventhandler #copy correct eventhandler BUILD.gn cp -rf %{SOURCE3} %{buildroot}%{bundle_dir}/BUILD.gn # rpm安装后需要安装到系统中的文件,及上面说的so和头文件 %files %{_libdir}/*.so %{_includedir}/eventhandler/* %{bundle_dir}/* # 变更日志 %changelog * Thu Jun 15 2023 chrisshangguan - 1.0.0-1 - Init and adapt to openeuler