base-files: clean up and clarify hostname logic
PATCH 1/1 base-files: clean up and clarify hostname logic
Change the hostname logic so that the magic value to use MACHINE as hostname is clearly a machine value ("machinename" instead of "openembedded"), and add a comment explaining how to set the hostname from outside the recipe and what happens if it's unset.
--- meta/recipes-core/base-files/base-files_3.0.14.bb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +9 -6
@@ -59,10 +59,13 @@ conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \ ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \ ${sysconfdir}/default" +# The default hostname. If set to the magic value "machinename" then the value +# of MACHINE is used. If the hostname is unset then a /etc/hostname file isn't +# written, suitable for environments with dynamic hostnames. # -# set standard hostname, might be a candidate for a DISTRO variable? :M: -# -hostname = "openembedded" +# This can be changed outside of this recipe by using +# hostname_pn-base-files = "my-host-name". +hostname = "machinename" BASEFILESISSUEINSTALL ?= "do_install_basefilesissue"
@@ -111,15 +114,15 @@ do_install () { DISTRO_VERSION[vardepsexclude] += "DATE" do_install_basefilesissue () { - if [ "${hostname}" != "" ]; then - if [ -n "${MACHINE}" -a "${hostname}" = "openembedded" ]; then + if [ "${hostname}" ]; then + if [ "${hostname}" = "machinename" ]; then echo ${MACHINE} > ${D}${sysconfdir}/hostname else echo ${hostname} > ${D}${sysconfdir}/hostname fi fi - install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir} + install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir} if [ -n "${DISTRO_NAME}" ]; then printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net
Signature · 1 line
1.7.10.4
meta/recipes-core/base-files/base-files_3.0.14.bb conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \ · line 68
Quoted 13 lines · Ross Burton
+# The default hostname. If set to the magic value "machinename" then the value
+# of MACHINE is used. If the hostname is unset then a/etc/hostnamefile isn'tmeta/recipes-core/base-files/base-files_3.0.14.bb +4
-3+# written, suitable for environments with dynamic hostnames. # -# set standard hostname, might be a candidate for a DISTRO variable? :M: -# -hostname = "openembedded" +# This can be changed outside of this recipe by using +# hostname_pn-base-files = "my-host-name". +hostname = "machinename"
Question, why use a magic value at all? Why not just set hostname = "${MACHINE}"?
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics
Quoted 3 lines · Christopher Larson
Question, why use a magic value at all? Why not just set hostname = "${MACHINE}"?
Because that would be sensible? V2 incoming.
Ross