[oe] systemd service failing at start

Sébastien Mennetrier smennetrier at connected-labs.com
Fri Jul 11 07:37:25 UTC 2014


Hi,

I had the same issue and for me the problem came from the postinst script :

When you add a pkg_postinst_${PN} in the recipe, the documentation say to
use :

pkg_postinst_PACKAGENAME () {
     #!/bin/sh -e
     if [ x"$D" = "x" ]; then
          # Actions to carry out on the device go here
     else
          exit 1
     fi
     }

But for recipe that inherit systemd, the pkg_postint script is followed by
(see in systemd.bbclass) :

systemd_postinst() {
OPTS=""

if [ -n "$D" ]; then
    OPTS="--root=$D"
fi

if type systemctl >/dev/null 2>/dev/null; then
    systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE}

    if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
        systemctl restart ${SYSTEMD_SERVICE}
    fi
fi
}

So your script is followed by "systemctl restart ${SYSTEMD_SERVICE}". And
if the service have some "Requires" that is not start when the postinst
script is executed, the message " A Start job is running for Run pending
postinsts" appears.

For solve the issue, I writed my pkg_postinst follow this schema :

pkg_postinst_${PN} () {
if [ x"$D" != "x" ]; then
    if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then
        # Script in systemd_postinst function
        OPTS="--root=$D"
        if type systemctl >/dev/null 2>/dev/null; then
            systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE}
        fi
    fi

    # Script in updatercd_postinst function
    OPT="-r $D"
    if type update-rc.d >/dev/null 2>/dev/null; then
        update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
    fi
    exit 1
else
    # Actions to carry out on the device go here
    exit 0
fi
}


I think that is maybe a bug in yocto ;)


Regards,
Seb M


2014-07-11 8:01 GMT+02:00 Li Zhijian <lizhijian at cn.fujitsu.com>:

>
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel
>



More information about the Openembedded-devel mailing list