Skip to content

Commit

Permalink
configs: s/powerpc64le/ppc64le/ the %_host_cpu macro
Browse files Browse the repository at this point in the history
For older RPM versions, %_host_cpu macro used to be set wrongly in
ppc64le Mock chroots.  Work-around this fact.

That's because RPM always decides the per-distribution %_host_cpu macro
value at the rpm.rpm package built-time.  The value is given to RPM by
the build system/environment.

The older versions of RPMs are using config.guess script (originally
C&P'ed from the Automake package) for this purpose, and that script
reports (even nowadays in Y2024) a wrong variant of the architecture
string in it's N-ary output:

    $ /usr/lib/rpm/redhat/config.guess
    powerpc64le-unknown-linux-gnu

Newer versions of RPMs (v4.19+, so Fedora 39+ and EL 10+) have moved to
CMake build-system where the build-time decision is done correctly, and
so the %_host_cpu contains a correct value for "newer" ppc64le chroots.

The point of this commit is to fix (override) the macro for older
chroots, with RPM v4.18 and older.  This is what the Fedora Koji build
system has been doing for ages anyways for (all) the ppc64le Mock
chroots (just this is being done for everyone in Mock).

The macro %_host_cpu is used, e.g., transitively by /bin/rpmbuild while
checking for the 'ExclusiveArch/ExcludeArch' architecture validity.
Maintainers often do:

    ExcludeArch: %java_arches

But since %java_arches doesn't contain the "non-standard" 'powerpc64le'
architecture from %_host_cpu (no similar macro does actually, neither
the much more beefy ones like %go_arches), such a build in Mock would
fail early:

    error: Architecture is not included: ppc64le

That's because:

    $ rpm --eval %java_arches
    aarch64 ppc64le s390x x86_64
    $ rpm --eval %_host_cpu
    powerpc64le

This affects `BuildArch: noarch` packages, too.  These packages have
`%_target_cpu == noarch` initially, so RPM checks %_build_cpu:

    https://github.com/rpm-software-management/rpm/blob/21457de886faf2415500a8bb7cc6c816d72939ef/build/parsePreamble.c#L442-L449

which equals to %_host_cpu:

    $ rpm --showrc | grep build_cpu
    -13: _build_cpu %{_host_cpu}

Relates: fedora-copr/copr#2870
Relates: https://bugzilla.redhat.com/show_bug.cgi?id=1461288
  • Loading branch information
praiskup committed Sep 11, 2024
1 parent 76216e0 commit 608c1ad
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/centos-stream+epel-8-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ config_opts['root'] = 'centos-stream+epel-8-ppc64le'
config_opts['description'] = 'CentOS Stream 8 + EPEL'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/centos-stream+epel-9-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ config_opts['root'] = 'centos-stream+epel-9-ppc64le'
config_opts['description'] = 'CentOS Stream 9 + EPEL'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ config_opts['root'] = 'centos-stream+epel-next-8-ppc64le'
config_opts['description'] = 'CentOS Stream 8 + EPEL Next'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ config_opts['root'] = 'centos-stream+epel-next-9-ppc64le'
config_opts['description'] = 'CentOS Stream 9 + EPEL Next'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/centos-stream-8-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ config_opts['root'] = 'centos-stream-8-ppc64le'
config_opts['description'] = 'CentOS Stream 8'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/centos-stream-9-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ include('templates/centos-stream-9.tpl')
config_opts['root'] = 'centos-stream-9-ppc64le'
config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/rhel-7-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)

config_opts['rhel_product'] = 'power-le'
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/rhel-8-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ include('templates/rhel-8.tpl')

config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'
2 changes: 2 additions & 0 deletions mock-core-configs/etc/mock/rhel-9-ppc64le.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ include('templates/rhel-9.tpl')

config_opts['target_arch'] = 'ppc64le'
config_opts['legal_host_arches'] = ('ppc64le',)
# see pull-request #1195
config_opts['macros']['%_host_cpu'] = 'ppc64le'

0 comments on commit 608c1ad

Please sign in to comment.