How to change file /etc/hosts in a Yocto image?

Viewed 58

I need to substitute the default file /etc/hosts of an Yocto image by a new hosts file.
What's the Yocto recipe which allows to do that?
Thanks

1 Answers

I've found the recipe that (at least in Zeus release of Yocto) is:
meta/recipes-core/base-fles/base-files_<recipe_version>.bb

So I can add a base_files_%.bbappend file (in mylayer/recipes-core/base-files) and substitute the default hosts file with my new hosts file.

The content of my file base_files_%.bbappend is:

FILESEXTRAPATHS_prepend := "${THISDIR}/base-files:"
SRC_URI = "file://rotation \
       file://nsswitch.conf \
       file://motd \
       file://hosts \
       file://host.conf \
       file://profile \
       file://shells \
       file://fstab \
       file://issue.net \
       file://issue \
       file://share/dot.bashrc \
       file://share/dot.profile \
       file://licenses/GPL-2 \
"

Furthermore I have inserted the new hosts file inside the folder:
meta/recipes-core/base-fles/base-files

The other files listed in the SRC_URI definition (rotation, nsswitch.conf, and so on) continue to come from the main base-files recipe.

Related