Issue with rpmbuild --target from a rocky 8 to a pcc64 architecture

71 Views Asked by At

I'm doing an rpmbuild with --target option and I fail with the error described here but my need is to really build the rpm for another architecture. Not to run it on my architecture.

The PERL build process with following arguments is OK. It is at, or just after, the install process that it fails.

./Configure -Dbuild=x86_64 -Dtarget=ppc64-ibm-AIX -des -Dprefix=$OCS_INSTALL_DIR/perl

Any help will be very much appreciated ! :)

My specfile :

#
# 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


My rpmbuiild line (part of a CI/CD pipeline)

    - 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

And the error message I've had :

Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.sPIxik
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}' '!=' / ']'
+ rm -rf '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}'
++ dirname '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}'
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}'
+ cd ocsinventory-agent-core-iti-1.0
+ rm -rf '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}'
+ mkdir -p '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}/opt/ocsinventory'
+ mkdir -p '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}/usr/bin'
+ cp -R /tmp/ocs/opt/ocsinventory/ocsinventory-agent /tmp/ocs/opt/ocsinventory/perl /tmp/ocs/opt/ocsinventory/var '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}/opt/ocsinventory/'
+ install -p -m 750 /tmp/ocs/usr/bin/ipdiscover '/root/rpmbuild/BUILDROOT/ocsinventory-agent-core-iti-1.0-1.aix.%{_arch}/usr/bin/'
+ /usr/lib/rpm/check-buildroot
xargs: invalid number for -P option
Usage: xargs [OPTION]... COMMAND [INITIAL-ARGS]...

I use a rocky8 docker image as host

2

There are 2 best solutions below

0
Arnaud DUBOIS On

The solution was to use the following code in the spec file :

# disable check-buildroot 
%define __arch_install_post %{nil}

%define __os_install_post %{nil}

0
msuchy On

Your solution may work. By accident. Reliable solution is:

rpmbuild -bs yourpackage.spec

This creates yourpackage.src.rpm. And then you can run:

sudo dnf install qemu-user-static mock
mock -r rocky+epel-9-ppc64le yourpackage.src.rpm

This will run the rpmbuild on ppc64le architecture using QEMU. More info: https://rpm-software-management.github.io/mock/Feature-forcearch.html