You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rocky8环境下rpmbuild指定--target ppc64架构构建失败求助

跨架构构建ppc64 RPM包失败:xargs -P选项参数无效错误

问题场景

在Rocky8 Docker镜像环境中,使用rpmbuild的--target选项构建ppc64架构RPM包时失败。Perl跨架构构建步骤(./Configure -Dbuild=x86_64 -Dtarget=ppc64-ibm-AIX -des -Dprefix=$OCS_INSTALL_DIR/perl)执行正常,但问题出在install阶段或之后。

使用的rpmbuild命令:

rpmbuild -bb --target "ppc64" --define "version ${PACKAGE_VERSION}" --define "release ${PACKAGE_REVISION}.${RHEL_VERSION}" --define "name ${PACKAGE_NAME}" ${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_REVISION}.spec

报错信息

执行/usr/lib/rpm/check-buildroot时出现:

xargs: invalid number for -P option

spec文件内容

#
# APM IBM
# RedHat 6
#

%define logmsg logger -t RPM %{name}
#%define debug_package %{nil}

Name:           %{name}
Version:        %{version}
Release:        %{release}
License:        GPLv2+
Group:          Applications/Communications
#BuildArch:      noarch
Source0:        %{name}-%{version}-%{release}.tar.gz
#BuildRequires:
Autoreq: 0
AutoReqProv: no
Requires(pre):       /usr/bin/yum
#Requires(preun):    /usr/bin/systemctl
#Requires(post):     /sbin/service, /sbin/chkconfig, /etc/services
#Requires(postun):   /sbin/service, /usr/sbin/userdel, /usr/sbin/groupdel
#Conflicts:
#Provides:
#Obsoletes:

%prep
%setup -q

%build
./Packager-for-Unix-master/compileSource.sh

%install
rm -rf %{buildroot}

mkdir -p %{buildroot}/opt/ocsinventory
mkdir -p %{buildroot}/usr/bin

cp -R /tmp/ocs/opt/ocsinventory/* %{buildroot}/opt/ocsinventory/
install -p -m 750 /tmp/ocs/usr/bin/ipdiscover %{buildroot}/usr/bin/

%clean
rm -rf %{buildroot}
rm -rf %{_builddir}

%files

%defattr(-,root,root,-)
/opt/ocsinventory/
%attr(0750,root,root)   /usr/bin/ipdiscover

%changelog

- Create core package

解决方案

1. 强制设置有效并行数参数

报错根源是跨架构构建时,rpm内部的%_smp_ncpus变量可能被设为无效值(如0),导致check-buildroot脚本中xargs -P参数出错。可以通过rpm定义强制指定有效并行数:

rpmbuild -bb --target "ppc64" --define "_smp_ncpus 1" --define "version ${PACKAGE_VERSION}" --define "release ${PACKAGE_REVISION}.${RHEL_VERSION}" --define "name ${PACKAGE_NAME}" ${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_REVISION}.spec

2. 完善跨架构构建环境

Rocky8下跨架构构建需要安装必要的模拟和交叉编译工具:

dnf install -y qemu-user-static rpm-build cross-binutils-ppc64 cross-gcc-ppc64

同时确保Docker镜像已启用binfmt_misc支持,保证ppc64二进制能被模拟执行。

3. 明确spec文件的架构设置

取消注释并修改spec中的架构定义,避免rpmbuild检测混淆:

BuildArch: ppc64

4. 验证构建产物的架构兼容性

检查/tmp/ocs下的二进制文件是否为ppc64架构产物,确保compileSource.sh脚本正确生成了目标架构的文件,而非本地x86_64架构文件。


内容的提问来源于stack exchange,提问作者Arnaud DUBOIS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 02:42:47