从 yocto SDK 生成 aarch64 RPM 包

Generating aarch64 RPM package from yocto SDK

我在Docker运行Ubuntu18:04x86_64。 我已经复制并采购了我用 Yocto 制作的 SDK。

source /sdk/environment-setup-aarch64-poky-linux

我正在编译我的库

cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

到目前为止一切都很好,当我检查库架构时 file myLib.so 它说 aarch64

myLib.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=5e01090be56b47a2dd2edd7c44e9861709f3090a, with debug_info, not stripped

现在我想使用cpack -G "RPM"

生成RPM包
-- Toolchain file defaulted to '/sdk/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake'
CPack: Create package using RPM
CPack: Install projects
CPack: - Run preinstall target for: myLib
CPack: - Install project: myLib
CPack: Create package
-- CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=/myLib/build/_CPack_Packages/Linux/RPM
CPackRPM: Will use GENERATED spec file: /myLib/build/_CPack_Packages/Linux/RPM/SPECS/myLib.spec
CPack: - package: /myLib/build/myLib.rpm generated.

我用rpm -qi myLib.so查看rpm文件的结果是

Name        : myLib
Version     : 1.1.1
Release     : 1
Architecture: x86_64
...

为什么RPM文件的架构是x86_64?
cpack 生成 aarch64 RPM 文件我缺少什么?

变量 CPACK_RPM_PACKAGE_ARCHITECTURE 默认为 uname -m,它当前设置为您计算机的体系结构。您可以手动设置此变量以覆盖包架构。

CPACK_RPM_PACKAGE_ARCHITECTURE=aarch64 cpack -G "RPM"