Reputation: 519
I am running Yocto Pyro, and I am trying to create a recipe that creates a symlink to an area that will be mounted at runtime. We are mounting our secondary storage at /var/local in the fstab. I would like to store the network settings there since the rootFS gets wiped out when we do firmware upgrade of our devices.
This is the recipe I am working on.
DESCRIPTION = "Create links to the persistent storage area for the network files."
PRIORITY = "optional"
LICENSE = "CLOSED"
FILES_${PN} += "/etc /etc/systemd/network"
S = "${WORKDIR}"
do_install() {
ln -frs /var/local/network/hostname ${D}/hostname
ln -frs /var/local/network/eth0.network ${D}/etc/systemd/network/eth0.network
# ln -frs /var/local/network/sysctl.conf ${D}/etc/sysctl.conf
# ln -frs /var/local/network/iptables-config ${D}/etc/sysconfig/iptables-config
}
The error I am getting is that it is failing to create the symbolic link.
| ln: failed to create symbolic link '/home/gen-ccm-root/workdir/tools/poky/build-dev/tmp/work/armv7ahf-neon-poky-linux-gnueabi/network-links/1.0-r0/image/etc/systemd/network/eth0.network': No such file or directory
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_install (log file is located at /home/gen-ccm-root/workdir/tools/poky/build-dev/tmp/work/armv7ahf-neon-poky-linux-gnueabi/network-links/1.0-r0/temp/log.do_install.118559)
ERROR: Task (/home/gen-ccm-root/workdir/tools/poky/meta-markem-imaje-private-bsp/recipes-core/network-links/network-links_1.0.bb:do_install) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2805 tasks of which 2796 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/gen-ccm-root/workdir/tools/poky/meta-markem-imaje-private-bsp/recipes-core/network-links/network-links_1.0.bb:do_install
Is there a way to make the links? Or do I need to take a different approach of reading the files at bootup and copying them in or something of that nature? I do believe that the security team will eventually want to make the root filesystem read only, so links are preferred to modifying the RootFS at startup.
Upvotes: 4
Views: 3325
Reputation: 568
What we do is create a postinstall function in .inc file in our image folder.
ROOTFS_POSTPROCESS_COMMAND += " symlinkfunction "
symlinkfunction() {
ln -s /path/on/target "${IMAGE_ROOTFS}/path/in/rootfs"
}
Use the .inc file in any image file that creates your target and it will update the target root file system with a new symlink.
Upvotes: 3
Reputation: 1257
You might want to do that via extending base-files recipe via a bbappend
base-files_%.bbappend
do_install_append() {
...
}
Upvotes: 1