Search code examples
yoctoopenembeddedbitbake

Run a command in bitbake recipe as if on live system


Is it possible to run a command in a recipe as if it were run on the live system? If so, how? I want to import my key(s) into gpg before the image is created so I don't have to log onto the system after formatting the SD card.


Solution

  • I found a solution that involves specifying a post install script that runs when do_rootfs is called. All I added to my recipe which installs my public key on the system is below:

    pkg_postinst_${PN}() {
    #!/bin/sh
    
    if [ -n "$D" ]; then
        OPT="--homedir $D/home/root/.gnupg"
    else
        OPT=""
    fi
    
    gpg $OPT --import ${D}${datadir}/mykey.gpg
    }