Skip to contentSkip to conversation

base-files: provide a mechanism to skip creation of the hostname file

PATCH In review Mark Hatle 2 participants 2 messages Sep 8, 2012 – Sep 12, 2012

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

PATCH v4 1/1 base-files: provide a mechanism to skip creation of the hostname file

From: Mark Asselstine <[email protected]>

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 "" for 'hostname' which will skip the creation of the /etc/hostname file by the base-files package.

---
 meta/recipes-core/base-files/base-files_3.0.14.bb |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +8 -6
index 6bab040..e80cff1 100644
@@ -1,7 +1,7 @@
 SUMMARY = "Miscellaneous files for the base system."
 DESCRIPTION = "The base-files package creates the basic system directory structure and provides a small set of key configuration files for the system."
 SECTION = "base"
-PR = "r71"
+PR = "r72"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://licenses/GPL-2;md5=94d55d512a9ba36caa9b7df079bae19f"
 # Removed all license related tasks in this recipe as license.bbclass 
@@ -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}" != "" ]; 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}  
@@ -144,5 +146,5 @@ FILES_${PN}-doc = "${docdir} ${datadir}/common-licenses"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/fstab ${sysconfdir}/hostname"
+CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]}"
 
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 53 lines · Mark Hatle

From: Mark Asselstine <[email protected]>

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 "" for 'hostname' which will skip the creation of the /etc/hostname file by the base-files package.

---
  meta/recipes-core/base-files/base-files_3.0.14.bb |   14 ++++++++------
  1 files changed, 8 insertions(+), 6 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +8 -6
index 6bab040..e80cff1 100644
@@ -1,7 +1,7 @@
  SUMMARY = "Miscellaneous files for the base system."
  DESCRIPTION = "The base-files package creates the basic system directory structure and provides a small set of key configuration files for the system."
  SECTION = "base"
-PR = "r71"
+PR = "r72"
  LICENSE = "GPLv2"
  LIC_FILES_CHKSUM = "file://licenses/GPL-2;md5=94d55d512a9ba36caa9b7df079bae19f"
  # Removed all license related tasks in this recipe as license.bbclass
@@ -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}" != "" ]; 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}
@@ -144,5 +146,5 @@ FILES_${PN}-doc = "${docdir} ${datadir}/common-licenses"
 
  PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/fstab ${sysconfdir}/hostname"
+CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]}"