Customize Yocto build by condition

53 views Asked by At

I have image and I need installer version of this image. In installer version differs from cunsumers version by one line in /etc/xdg/weston/weston.ini and other passwords of root and user. What is better way of generation two images with minor differences?

I have created in my layer layer/recipes-core/images another file image-installer.bb similar to image-consumer.bb

And want to choose version by typing bitbake image-installer(consumer)

and in image-installer.bb I have add lines for changing passwords:

EXTRA_USERS_PARAMS = "usermod -P user password;"

But how should I change /etc/xdg/wayland/weston.ini? I add to image-installer.bb lines

do_install_append() {
  install -D -p ${WORKDIR}/weston_for_installer.ini ${D}${sysconfdir}/xdg/weston/weston.ini
  #or
  sed -i "/\[shell\]/apanel-position=none" ${D}${sysconfdir}/xdg/weston/weston.ini
}

but this lines does not changes anything

1

There are 1 answers

0
hilt0n On

First of all and regarding the handling of the 2 images themselve, I would create a common class from which inherit both of your image recipes, something like that :

  1. custom-image-base.bbclass
    SUMMARY = "..."
    IMAGE_INSTALL = "..."
    
    inherit core-image
    
    <other common stuff>
    
  2. image-consumer.bb
    inherit custom-image-base
    
  3. image-installer.bb
    inherit custom-image-base
    
    <do special action here or install additional recipe which modify the final image>
    

From here, there is perhaps multiple solutions but the most simple is to modify the rootfs after its complete creation. You can do it in image recipes using the ROOTFS_POSTPROCESS_COMMAND helper. You can also manage user creation/modification from this recipe:

image-installer.bb

inherit custom-image-base extrausers

modify_wayland_ini_file() {
    if [ -f "${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini" ]; then
        sed -i "/\[shell\]/apanel-position=none" ${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini
    fi
}
ROOTFS_POSTPROCESS_COMMAND += "modify_wayland_ini_file;"

# printf "%q" $(mkpasswd -m sha256crypt myawesomepwd)
PWD = "\$5\$NWH15.mb3GHy61Je\$2YAfr4Nj1uGFfEokXzSQpLGreZ06b3LbEwZOya762gB"

EXTRA_USERS_PARAMS = " useradd -u 1000 admin; \
                       usermod -p '${PWD}' admin; \
                       usermod -a -G sudo admin;"