[OE-core] [PATCH V2] base-files: provide a mechanism to skip creation of the hostname file

Mark Asselstine mark.asselstine at windriver.com
Tue Aug 28 18:20:28 UTC 2012


The existence of a /etc/hostname file causes any hostname provided on
the kernel command line or via dhcp to be overwritten by the
initscripts 'init.d/hostname.sh'. This change allows you to set a
value of 'none' for 'hostname' which will skip the creation of the
/etc/hostname file by the base-files package.

Signed-off-by: Mark Asselstine <mark.asselstine at windriver.com>
---
V2: Koen Kooi didn't want to see the handling of the hostname variable
    changed so I removed those changes and just focused on the creation
    of the /etc/hostname file.

  Changes from V1:
  * patch renamed, was 
    "base-files: allow for more flexibility related to hostname",
  * removed the rename of hostname to MACHINE_HOSTNAME
  * removed the addition made to meta/conf/local.conf.sample

 meta/recipes-core/base-files/base-files_3.0.14.bb |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/recipes-core/base-files/base-files_3.0.14.bb
index 6bab040..dfcca78 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -107,10 +107,12 @@ do_install () {
 }
 
 do_install_basefilesissue () {
-	if [ -n "${MACHINE}" -a "${hostname}" = "openembedded" ]; then
-		echo ${MACHINE} > ${D}${sysconfdir}/hostname
-	else
-		echo ${hostname} > ${D}${sysconfdir}/hostname
+	if [ "${hostname}" != "none" ]; then
+		if [ -n "${MACHINE}" -a "${hostname}" = "openembedded" ]; then
+			echo ${MACHINE} > ${D}${sysconfdir}/hostname
+		else
+			echo ${hostname} > ${D}${sysconfdir}/hostname
+		fi
 	fi
 
 	install -m 644 ${WORKDIR}/issue*  ${D}${sysconfdir}  
-- 
1.7.9.5





More information about the Openembedded-core mailing list