diff mbox series

rpmbuild doesn't work on the target system out of the box with standard macros in the specfile

Message ID d8337e11-0727-a5cb-d3db-1cd6b5ad9190@gmail.com
State New
Headers show
Series rpmbuild doesn't work on the target system out of the box with standard macros in the specfile | expand

Commit Message

Böszörményi Zoltán July 14, 2023, 12:53 p.m. UTC
Hi,

I have to create a Yocto based system with a lot of developer
tools and SDK including rpmbuild. This is because a third party
developer is comfortable with building stuff on hardware but
not with cross-compiling and creating Bitbake recipes.

Anyway, with the image created and installed, I tried to build
an RPM from an autotools based project on the target system
The specfile used the standard %configure macro.

./configure stopped with an error saying the compiler doesn't
produce working binaries.

It turned out that %optflags was not defined correctly and
in this case rpm --eval "%optflags" returns the passed-in
string as is.

The OS was built using MACHINE=genericx86-64 and
I had to make this change manually in rpmrc to make it work:

--------------------------------------------------------------------
# diff -u /usr/lib/rpm/rpmrc.old /usr/lib/rpm/rpmrc
--------------------------------------------------------------------

I think a lot of other BSPs would have the same issue.
For one, meta-intel defines BSPs that produce builds for newer
archs than genericx86-64. They probably wouldn't work either.

It would be nice if Yocto's rpm recipe added the possible
buildarchtranslate lines for BSP target archs automatically.

Best regards,
Zoltán Böszörményi

Comments

Ross Burton July 14, 2023, 1:23 p.m. UTC | #1
On 14 Jul 2023, at 13:53, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
> It would be nice if Yocto's rpm recipe added the possible
> buildarchtranslate lines for BSP target archs automatically.

As you’re in the perfect position to test this, would you be willing to come up with a patch?

It might be as simple as only changing the macro files in native builds, so the target rpm has conventional macros.  Then again I don’t know much about RPM so may be wrong!

A test case that does a simple build using rpm would be a good step too.

Cheers,
Ross
Böszörményi Zoltán July 14, 2023, 1:48 p.m. UTC | #2
2023. 07. 14. 15:23 keltezéssel, Ross Burton írta:
> On 14 Jul 2023, at 13:53, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>> It would be nice if Yocto's rpm recipe added the possible
>> buildarchtranslate lines for BSP target archs automatically.
> As you’re in the perfect position to test this, would you be willing to come up with a patch?

I am trying to.
Currently I am stuck with making this work for Yocto 3.4.
Later I may be able to come up with something that works for Yocto master.

> It might be as simple as only changing the macro files in native builds, so the target rpm has conventional macros.  Then again I don’t know much about RPM so may be wrong!

rpmrc and the platform specific macros file need changing.

rpm --eval '%{_arch}' also not correct. strace shows that
it looks at the contents of /etc/rpm/platform and then
wants to read /usr/lib/rpm/platform/<platform>/macros
which doesn't exist for e.g. platform=genericx86-64 or
other BSPs.

Also, I am not using multiarch so the default
/usr/lib/rpm/platform/x86_64-linux/macros is not correct
as it tells rpmbuild to use /usr/lib64 as opposed to use /usr/lib.

Not sure what to do with a multiarch Yocto build.

> A test case that does a simple build using rpm would be a good step too.
>
> Cheers,
> Ross
Böszörményi Zoltán July 24, 2023, 12:40 p.m. UTC | #3
2023. 07. 14. 15:48 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:
> 2023. 07. 14. 15:23 keltezéssel, Ross Burton írta:
>> On 14 Jul 2023, at 13:53, Zoltan Boszormenyi via lists.openembedded.org 
>> <zboszor=gmail.com@lists.openembedded.org> wrote:
>>> It would be nice if Yocto's rpm recipe added the possible
>>> buildarchtranslate lines for BSP target archs automatically.
>> As you’re in the perfect position to test this, would you be willing to come up with a 
>> patch?
>
> I am trying to.
> Currently I am stuck with making this work for Yocto 3.4.
> Later I may be able to come up with something that works for Yocto master.
>
>> It might be as simple as only changing the macro files in native builds, so the target 
>> rpm has conventional macros.  Then again I don’t know much about RPM so may be wrong!
>
> rpmrc and the platform specific macros file need changing.

It seems only the latter needs to be changed.
In case of MACHINE=genericx86-64, RPM packages with
.genericx86_64.rpm suffix will be generated this way.

I just sent the patch against the rpm recipe. Please
review and comment.

I hope I got it right for architectures I don't usually build for.

>
> rpm --eval '%{_arch}' also not correct. strace shows that
> it looks at the contents of /etc/rpm/platform and then
> wants to read /usr/lib/rpm/platform/<platform>/macros
> which doesn't exist for e.g. platform=genericx86-64 or
> other BSPs.
>
> Also, I am not using multiarch so the default
> /usr/lib/rpm/platform/x86_64-linux/macros is not correct
> as it tells rpmbuild to use /usr/lib64 as opposed to use /usr/lib.
>
> Not sure what to do with a multiarch Yocto build.
>
>> A test case that does a simple build using rpm would be a good step too.
>>
>> Cheers,
>> Ross
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#184265): https://lists.openembedded.org/g/openembedded-core/message/184265
> Mute This Topic: https://lists.openembedded.org/mt/100140377/3617728
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

--- /usr/lib/rpm/rpmrc.old    2023-05-18 12:28:44.000000000 +0000
+++ /usr/lib/rpm/rpmrc    2023-07-14 12:34:59.840691763 +0000
@@ -380,6 +380,8 @@ 
  buildarchtranslate: x86_64: x86_64
  buildarchtranslate: amd64: x86_64
  buildarchtranslate: ia32e: x86_64
+buildarchtranslate: genericx86_64: x86_64
+buildarchtranslate: core2_64: x86_64

  buildarchtranslate: sh3: sh3
  buildarchtranslate: sh4: sh4