-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
%_target_cpu and various other macros are wrong in during build in BuildArch packages #3049
Labels
Comments
pmatilai
added a commit
to pmatilai/rpm
that referenced
this issue
Apr 30, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter. A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: rpm-software-management#3049
pmatilai
added a commit
to pmatilai/rpm
that referenced
this issue
Apr 30, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (rpm-software-management#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: rpm-software-management#3049
pmatilai
added a commit
to pmatilai/rpm
that referenced
this issue
Apr 30, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (rpm-software-management#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: rpm-software-management#3049
pmatilai
added a commit
to pmatilai/rpm
that referenced
this issue
Apr 30, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (rpm-software-management#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: rpm-software-management#3049
pmatilai
added a commit
that referenced
this issue
May 6, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: #3049
dmnks
pushed a commit
to dmnks/rpm
that referenced
this issue
May 17, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (rpm-software-management#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: rpm-software-management#3049 (cherry picked from commit 96467dc)
dmnks
pushed a commit
that referenced
this issue
May 17, 2024
When BuildArch is encountered during spec parse, rpm recurses the parse, but this doesn't reset/reload the global configuration and macros to match. So eg a "BuildArch: noarch" package gets built with a dramatically different macros depending on whether "--target noarch" was used or not, whereas people expect it to be the same - after all we give zero indication that anything might be wrong when --target wasn't specified. Automatically detect and handle this condition in the rpmbuild tool: if the spec parse architecture disagrees with our loaded configuration, request a reparse with reloaded configuration for the matching target. This ensures 'rpmbuild -bb noarch.spec' and 'rpmbuild -bb --target noarch noarch.spec' run with the same exact configuration. Doing this also fixes the situation where build-time macro expansion of build scriptlets (for template bits and dynamically generated spec parts) yields totally different (bogus) than in the initial spec parse. This also goes for RPM_ARCH environment and similar. Avoid --undefine for dependency generation test, it doesn't work. --undefine with --target was always broken, now it's just more visible since it automatically applies to BuildArch too. Fixing that is a separate matter (#3070). A more sophisticated fix could be having a stack of macro contexts that we copy, push and pop as necessary. That ought to solve the undefine too. Fixes: #3049 (cherry picked from commit 96467dc)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One report of the issue is here: https://bugzilla.redhat.com/show_bug.cgi?id=2069163 but also ran into this in various other circumstances, eg #2319 and %ifarch not working in dynamic spec parts.
The spec parsing recurses through build architectures, pushing and popping %_target_cpu as it goes, and the last pop leaves the value to whatever the host is, ie almost certainly wrong and always wrong for noarch packages. It's not just %_target_cpu though, RPM_ARCH environment variable in the build scriptlets gets set from %_arch which is similarly off, and then there's %_libdir, %optflags and all.
This affects both dynamically generated .specpart and the templated parts that get expanded during doScript().
The text was updated successfully, but these errors were encountered: