systemd-compat-units: fix the post install script

The pkg_postinst_ontarget adds the following into the post
install script:
"""
if [ -n "$D" ]; then
    $INTERCEPT_DIR/postinst_intercept delay_to_first_boot %s mlprefix=%s
    exit 0
fi
"""
Which doesn't work when installing packages with anaconda and failed with:
line 24: /postinst_intercept: No such file or directory

So change to pkg_postinst and do the following to ensure the post install
script run successfully both in do_rootfs and with anaconda:

* "networking" is a sysv init script, no systemd service file, systemd
  command actually calls update-rc.d to enable the service, so change to
  use update-rc.d command directly.

* Use different OPT according to the content of $D.

Partial-Bug: 1901820

Change-Id: I76a74228ed01e78f11876e2ef8901624ab9c6f0c
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
This commit is contained in:
Jackie Huang 2020-11-02 22:49:32 +08:00
parent c74ebee4bc
commit 587e1dbcf2

View File

@ -1,6 +1,16 @@
SYSTEMD_DISABLED_SYSV_SERVICES_remove += " networking"
pkg_postinst_ontarget_${PN}() {
systemctl enable networking.service
pkg_postinst_${PN}_append () {
if [ -n "$D" ]; then
OPT="-f -r $D"
else
OPT="-f"
fi
if [ -f "$D${sysconfdir}/init.d/networking" ]; then
update-rc.d $OPT networking defaults
fi
}
RDEPENDS_${PN} += "update-rc.d"