Override Yocto ALTERNATIVE_PRIORITY with bbappend


is it possible to override the ALTERNATIVE_PRIORITY with a bbappend file?
I have tried it with the following recipe as systemd_%.bbappend without success.

SUMMARY = "Remap resolv.conf from connman back to systemd-resolv"


inherit update-alternatives

ALTERNATIVE_${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}"
ALTERNATIVE_TARGET[resolv-conf] = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${sysconfdir}/resolv-conf.systemd','',d)}"
ALTERNATIVE_LINK_NAME[resolv-conf] = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${sysconfdir}/resolv.conf','',d)}"

do_install_append() {	

I want to link /etc/resolv.conf to systemd by default.


Hi @gandi ,

Thanks for reaching out to Toradex.

We are looking at your question and get back to you as soon as possible.

Best Regards

Hi @gandi ,

I would expect that a systemd_%.bbappend with the following content would do what you want to do:

# increase priority from 50 to 200
ALTERNATIVE_PRIORITY[resolv-conf] = "200"

The ALTERNATIVE_PRIORITY[resolv-conf] ?= “50” setting takes precedence over your systemd global ALTERNATIVE_PRIORITY = “200”.

Overwritting ALTERNATIVE_${PN} the way you do it removes all the other alternatives the systemd recipe defines. Is this something you really want / need?


Hi @max.tx ,
thank you for your answer, it works now.

My target is to use systemd-network for eth0 and eth1, so I blacklisted these interfaces without the connman configuration. I want to keep connman for future use with bluetooth or wifi. My filesytem is readonly and /etc is overlayed with a folder on a separate partition.

But now I have the problem that /etc/machine-id is empty after bootup (fresh install) and the dhcp client wont start. The overlay is applied in fstab.
Do you have any idea how to fix this behaviour?

Thank you

Hi @gandi !

As you are overlayfs-ing the /etc folder, it is possible that the interaction of the overlayfs with the machine-id service is rendering an empty /etc/machine-id.

Could you please use systemd-analyze dump to output systemd’s steps and find when the overlayfs and the machine-id are bring performed?

Best regards,