Bug 14616

Summary: pkg_postinst_${PN}_append doesn't always append
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Michael Burr <Michael.Burr>
Component: oe-core otherAssignee: Aníbal Limón <anibal>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: anibal, randy.macleod, richard.purdie
Version: 3.2.5   
Target Milestone: 6.0 M4   
Hardware: Other   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Michael Burr 2021-11-05 22:44:32 UTC
Try appending the post-install script for wpa_supplicant in a "wpa_supplicant_%.bbappend" file, like this:

pkg_postinst_${PN}_append () { ... }

At least in my case, it caused a warning of this form:

WARNING: Variable key pkg_postinst_${PN} (...) replaces original key pkg_postinst_wpa-supplicant (...).

The warning is correct, insofar as wpa_supplicant already has a post-install script in its main recipe, and the outcome in the WORKDIR seems to be that it was overwritten instead of appended.

On the other hand, the following worked as expected, and eliminated the warning too:

pkg_postinst_wpa-supplicant_append () { ... }

Not sure if it's relevant, but the main recipe itself does _not_ use ${PN}: it rather writes in the name explicitly.
Comment 1 Richard Purdie 2021-11-08 21:50:59 UTC
When you write such an append you do need to write the append in the form the recipe had written in in so this is really expected. It can be problematic which is why the code throws the warning if something happened where bitbake thinks the wrong thing may have happened. I appreciate this isn't ideal but we've struggled to come up with anything better than showing the warning.
Comment 2 Michael Burr 2021-11-08 22:13:47 UTC
Thank you very much for the reply!

Could I suggest one (or more) of the following possible mitigations?

1. Change the main wpa_supplicant.bb recipe so it uses ${PN} instead of the explicit name (assuming the former is considered the 'right' or better way).

2. Make the language of the warning more specific, so that basically it tells the user what you just told me, if it can detect this particular situation. (Since the solution wasn't at all obvious, and I only found it with a lucky guess.)

3. Improve documentation about this (non-obvious) requirement for appending post-install scripts.

Although: is this a more a general thing, that is documented elsewhere and maybe I should've known it? Is it true that *any* BB task or function can only be successfully appended with exactly the same name (i.e. no expansion takes place when trying to match the function name)?
Comment 3 Richard Purdie 2021-11-11 17:16:28 UTC
I've sent out a patch for 1). The language in the warning is tricky since it is generic code, it can't be specific to a specific use case. For 3), I'll reassign this bug to documentation in case they can see how to better document the issue.

(The issue is that package overrides should match the form used in PACKAGES.)
Comment 4 Randy MacLeod 2024-10-24 15:03:54 UTC
Bulk move of 5.1 M4 to 5.2 M2 as approved by AlexB.
Comment 5 Antonin Godard 2025-06-06 07:42:30 UTC
Bulk move of bugs I am assigned to from Milestone 5.2M4 to 5.3M1.
Comment 6 Randy MacLeod 2026-05-28 15:17:35 UTC
Issue 1) that Michael identified has been fixed.
The other two issues are not tractable for reasons explained in comments.