How should I sed files on Yocto-generated rootfs?

I would like to find a way to run sed scripts in files in a Yocto-generated OS from a .bbappend file. My OS only has read-only root files that seem to terminate any possibility after installing the script. In particular, I need to make these changes to /etc/default/ssh(how it starts after loading the generated OS):

sed -i 's/var\/run/etc/' /etc/default/ssh 
sed -i 's/_readonly//' /etc/default/ssh

Here is mine openssh_7.1p1.bbappendthat I created in an attempt to solve these problems:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += " \
    file://ssh_host_dsa_key.pub  \
    file://ssh_host_rsa_key.pub  \
    ...
    "

do_install_append() {
    sed -i 's/var\/run/etc/' ${D}${sysconfdir}/default/ssh
    sed -i 's/_readonly//' ${D}${sysconfdir}/default/ssh

    # these lines work fine
    install -m 0755 ${WORKDIR}/ssh_host_dsa_key          ${D}/etc/ssh
    install -m 0755 ${WORKDIR}/ssh_host_dsa_key.pub      ${D}/etc/ssh
    ...
}
FILES_${PN} += "${sysconfdir}/default/ssh"

#these lines work
FILES_${PN} += "${sysconfdir}/ssh/ssh_host_dsa_key"
FILES_${PN} += "${sysconfdir}/ssh/ssh_host_dsa_key.pub"
...

BitBake error while executing do_install_append()with this error:

sed: can't read ${TMPDIR}/work/x86-poky-linux/openssh/image/etc/default/ssh: No such file or directory

(where TMPDIR is my actual tmp directory) Obviously, this file does not exist, because the proper copy is created in a separate directory MULTIMACH_TARGET_SYS(i.e. not x86-poky-linux) using image.bbclass.

.bbappend( - )? .inc ROOTFS_POSTPROCESS_COMMAND , .

+4
2

, sed SRC_URI.

0

, post-installation .bbappend ?

pkg_postinst_${PN} () {
    #!/bin/sh
    if [ x"$D" = "x" ]; then
        sed -i 's/var\/run/etc/' /etc/default/ssh 
        sed -i 's/_readonly//' /etc/default/ssh
    else
        exit 1
    fi
}

sed , .

+1

Source: https://habr.com/ru/post/1620399/


All Articles