Bug 12896

Summary: "qemu udevadm hwdb" called from postinst instead of using intercept mechanism
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Yann Dirson <ydirson>
Component: coreAssignee: Yann Dirson <ydirson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher, Qi.Chen, randy.macleod, ross.burton
Version: unspecified   
Target Milestone: 0.0.0   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Yann Dirson 2018-08-23 14:39:54 UTC
This looks as if it could make use of the postinst-intercept mechanism.  As, it forces to modify/bbappend each recipe (eudev, systemd) if one wants to change things (eg. when target is not fully supported by qemu).
Comment 1 Randy MacLeod 2018-08-30 23:47:39 UTC
Yann,
  If you can, a patch sent to the oe-core list would be nice. 

If you aren't able to do that Qi will work on it next week or at least before 2.6-M4 as per Richard's request.

Let us know what the plan is please.

../Randy
Comment 2 Chen Qi 2018-09-03 02:06:39 UTC
(In reply to comment #1)
> Yann,
>   If you can, a patch sent to the oe-core list would be nice. 
> 
> If you aren't able to do that Qi will work on it next week or at least
> before 2.6-M4 as per Richard's request.
> 
> Let us know what the plan is please.
> 
> ../Randy

I'll check it late this week or early next week.
Comment 3 Chen Qi 2018-09-03 07:54:46 UTC
I just take a quick look, I think things are OK ATM.

"""
PACKAGE_WRITE_DEPS += "qemu-native"
pkg_postinst_eudev-hwdb () {
    if test -n "$D"; then
        if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true','false', d)}; then
            ${@qemu_run_binary(d, '$D', '${bindir}/udevadm')} hwdb --update --root $D
            chown root:root $D${sysconfdir}/udev/hwdb.bin
        else
            $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
        fi
    else
        udevadm hwdb --update
    fi
}
"""

What's the actual problem?
Comment 4 Yann Dirson 2018-09-10 20:21:05 UTC
The yocto project provides the postinst-intercept framework to allow working around 
the readonly constraint.  Without knowing the rationale for this framework, the
main advantage I see is that it puts all such mechanism in one place, and as many
recipes can use it without code duplication.  Combined with the ability to override
the scripts with POSTINST_INTERCEPTS_DIR, it allows overriding an intercept rule only
once to benefit many packages (here udev and systemd).

As I understand it, that would basically be moving the "then" part of the postinst
into a new intercept scriptlet.
Comment 5 Chen Qi 2018-09-11 00:56:01 UTC
(In reply to comment #4)
> The yocto project provides the postinst-intercept framework to allow working
> around 
> the readonly constraint.  Without knowing the rationale for this framework,
> the
> main advantage I see is that it puts all such mechanism in one place, and as
> many
> recipes can use it without code duplication.  Combined with the ability to
> override
> the scripts with POSTINST_INTERCEPTS_DIR, it allows overriding an intercept
> rule only
> once to benefit many packages (here udev and systemd).
> 
> As I understand it, that would basically be moving the "then" part of the
> postinst
> into a new intercept scriptlet.

Please just send out a patch.
I don't understand what you are talking about.
Comment 6 Chen Qi 2018-09-13 05:20:18 UTC
I personally don't think the current handling has problem.
Please double check it.
Comment 7 Yann Dirson 2018-09-18 19:36:50 UTC
I'll send a patch
Comment 8 Stephen K Jolley 2018-10-05 17:24:46 UTC
It appears that Yann has accepted this, moving out of NEEDINFO.
Comment 9 Randy MacLeod 2019-01-10 16:13:41 UTC
Yann, any update? Will you be able to work on this soon?
Comment 10 Ross Burton 2019-11-07 15:48:07 UTC
The current systed postinst is:

pkg_postinst_udev-hwdb () {
	if test -n "$D"; then
		$INTERCEPT_DIR/postinst_intercept update_udev_hwdb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX}
	else
		udevadm hwdb --update
	fi
}

And eudev:

PACKAGE_WRITE_DEPS += "qemu-native"
pkg_postinst_eudev-hwdb () {
    if test -n "$D"; then
        $INTERCEPT_DIR/postinst_intercept update_udev_hwdb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX}
    else
        udevadm hwdb --update
    fi
}

Fixed in oe-core d6b737a31a8842cdc770b05e28503c81a691d10d.