Skip to contentSkip to conversation

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

PATCH Superseded Mark Hatle 3 participants 4 messages Sep 7, 2012 – Sep 8, 2012

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

PATCH v3 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 |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +7 -5
index 6bab040..cda13f4 100644
@@ -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 24 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 |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +0 -1
index 6bab040..cda13f4 100644
@@ -107,10 +107,12 @@ do_install () {
 }
 
 do_install_basefilesissue () {
-	if [ -n "${MACHINE}" -a "${hostname}" = "openembedded" ]; then

meta/recipes-core/base-files/base-files_3.0.14.bb do_install () { · line 116

Quoted 10 lines
meta/recipes-core/base-files/base-files_3.0.14.bb +6 -3
-		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

Is this missing a hostname ??= "openembedded" perhaps?

Cheers,

Richard

Quoted 8 lines
meta/recipes-core/base-files/base-files_3.0.14.bb +1 -1
 	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) != '')]}"
 
author
#2 lore raw
Quoted 23 lines · Richard Purdie
Quoted 22 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 |   12 +++++++-----
  1 files changed, 7 insertions(+), 5 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +0 -0
index 6bab040..cda13f4 100644
@@ -107,10 +107,12 @@ do_install () {
  }
 
Quoted 15 lines

meta/recipes-core/base-files/base-files_3.0.14.bb do_install () { · line 116

Quoted 12 lines
meta/recipes-core/base-files/base-files_3.0.14.bb +6 -4
  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

Is this missing a hostname ??= "openembedded" perhaps?

There is already a hostname = "openembedded" in the package. Nothing in that part was changed by this patch. The normal override process is to define hostname_override = "newhostname".

I verified this is working properly.

--Mark

Quoted 14 lines

Cheers,

Richard

Quoted 8 lines
meta/recipes-core/base-files/base-files_3.0.14.bb +1 -1
  	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) != '')]}"
 
#3 lore raw
In reply to Mark Hatle

Op 7 sep. 2012, om 23:51 heeft Mark Hatle <[email protected]> het volgende geschreven:

Quoted 40 lines

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 | 12 +++++++-----

1 files changed, 7 insertions(+), 5 deletions(-)
meta/recipes-core/base-files/base-files_3.0.14.bb +6 -4
index 6bab040..cda13f4 100644
@@ -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}"

meta/recipes-core/base-files/base-files_3.0.14.bb FILES_${PN}-doc = "${docdir} ${datadir}/common-licenses" · line 149

Quoted 2 lines
meta/recipes-core/base-files/base-files_3.0.14.bb +1 -1
-CONFFILES_${PN} = "${sysconfdir}/fstab ${sysconfdir}/hostname"
+CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname'][(d.getVar('hostname', True) != '')]}"

MIssing PR bump