buildroot

Patching a file in resulting rootfs


I am using buildroot to create an OS for the Raspberry PI. How do I apply a patch to a file in the resulting rootfs?

For example adding the lines

auto eth0

iface eth0 inet dhcp

to /etc/network/interfaces on the resulting rootfs.

I realize that this can be done with a script after unpacking the rootfs on my target, but I am wondering if it can be automated using buildroot.


Solution

  • First of all take a look at BR2_EXTERNAL mechanism. This way you can manage your project/configurations/package independent from Buildroot tree.

    Then look at "Root filesystem overlays (BR2_ROOTFS_OVERLAY)" and "Post-build scripts (BR2_ROOTFS_POST_BUILD_SCRIPT)" in Customizing the generated target filesystem section. They describe both ways, i.e supply your custom file via fs-overlay or run a post-build script and alter the file within this script.