Bug 13897 - POSTINST_INTERCEPTS_DIR broken by undocumented POSTINST_INTERCEPTS_PATHS since thud
Summary: POSTINST_INTERCEPTS_DIR broken by undocumented POSTINST_INTERCEPTS_PATHS sinc...
Status: RESOLVED NOTABUG
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: oe-core other (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.2 M1
Assignee: Unassigned
QA Contact:
URL:
Whiteboard: Backport
Depends on:
Blocks:
 
Reported: 2020-05-11 09:56 UTC by Yann Dirson
Modified: 2022-10-27 15:52 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yann Dirson 2020-05-11 09:56:14 UTC
In sumo I have an image recipe setting POSTINST_INTERCEPTS_DIR to a custom directory.

Updating to warrior this does not work any more.  What I found out so far:

* POSTINST_INTERCEPTS_PATHS was added before thud in commits 9ba2f2b1d and 7a2044df, but it is still not documented in dunfell, and nothing appears in "moving to thud" either

* "bitbake -e" says POSTINST_INTERCEPTS is set from image-postinst-intercepts.bbclass, but any trace I add there don't get into the log

* adding traces to PackageManager._initialize_intercepts() confirms it was set previously

Debugging hints appreciated :)
Comment 1 Alexander Kanavin 2020-05-14 10:24:44 UTC
Can you provide easy steps to reproduce this please?
Comment 2 Yann Dirson 2020-05-15 08:09:52 UTC
Good point.  In fact with simple variable setting it works (but that's not a very interesting case, we can do nearly as much already with the default POSTINST_INTERCEPTS_PATHS).

What does not work is setting it from an anonymous python block, which I'm using to set it conditionally.

$ git clone git://git.yoctoproject.org/poky
$ cd poky
$ cp -a scripts/postinst-intercepts/ intercepts-copy

$ cat > ../meta/recipes-core/images/test-image.bb <<EOF
include core-image-minimal.bb
#POSTINST_INTERCEPTS_DIR="/tmp/poky/intercepts-copy"
python () {
    d.setVar('POSTINST_INTERCEPTS_DIR', "/tmp/poky/intercepts-copy")
}
EOF

$ bitbake test-image -e |& grep ^POSTINST_INTERCEPT|grep -v CHECKSUM
POSTINST_INTERCEPTS="/tmp/poky/scripts/postinst-intercepts/delay_to_first_boot /tmp/poky/scripts/postinst-intercepts/postinst_intercept /tmp/poky/scripts/postinst-intercepts/update_font_cache /tmp/poky/scripts/postinst-intercepts/update_gio_module_cache /tmp/poky/scripts/postinst-intercepts/update_gtk_immodules_cache /tmp/poky/scripts/postinst-intercepts/update_icon_cache /tmp/poky/scripts/postinst-intercepts/update_pixbuf_cache /tmp/poky/scripts/postinst-intercepts/update_udev_hwdb"
POSTINST_INTERCEPTS_DIR="/tmp/poky/intercepts-copy"
POSTINST_INTERCEPTS_PATHS="/tmp/poky/meta-poky/postinst-intercepts:/tmp/poky/build/postinst-intercepts:/tmp/poky/meta/postinst-intercepts:/tmp/poky/meta-yocto-bsp/postinst-intercepts:/tmp/poky/intercepts-copy"
Comment 3 Alexander Kanavin 2020-05-19 09:38:21 UTC
Sadly I cannot help you further. This is not a scenario we test or support, so I'd say you have to find out where it breaks yourself.
Comment 4 Yann Dirson 2020-05-19 10:01:50 UTC
I'd be happy to squash this bug, but:

* the lack of doc ot the feature remains
* I'll need some assistance as to why traces added to image-postinst-intercepts.bbclass don't show up in the task log
Comment 5 Randy MacLeod 2020-06-11 08:01:48 UTC
Mingli can you work on this for M2?
Comment 6 Randy MacLeod 2020-08-10 11:20:15 UTC
Mingli had moved this to 3.99 since she's not able to work on it for 3.2.
I'm moving it back to 3.2-M3 / unassigned in case someone wants to fix it. It seems like a use case that few people trip over so perhaps it should be a lower importance.
Comment 7 Christopher Larson 2021-03-25 15:34:05 UTC
The issue here is that image-postinst-intercepts uses the variables to set other variables at RecipePreFinalise event, which runs before anonymous python functions do. To set POSTINST_INTERCEPTS_DIR or POSTINST_INTERCEPTS_PATHS programmatically, you'd have to have an event handler of your own which runs before this one (registered before this one, i.e. create your own class and add it to INHERIT), or define it using inline python, i.e. POSTINST_INTERCEPTS_DIR = "${@my_function(d)}", or copy the event handler from image-postinst-intercepts.bbclass into a function so you can call it directly after you set it in your anonymous python function.

In any case, there's no real way around this. image-postinst-intercepts has to do this processing at parse time to ensure we track the checksums of the external postinst intercept scripts to ensure the task is re-run when those change or are created, so it cannot be postponed to image creation time.
Comment 8 Richard Purdie 2022-10-27 15:52:39 UTC
As Christopher mentions, we can't really avoid this. We have to include the checksums of the intercepts in the task hashes for sstate purposes so setting this conditionally from anonymous python isn't possible,