[meta-freescale] [meta-fsl-demos][PATCH 2/3] sysvinit: auto detect hostname for qoriq machines

Zhenhua Luo zhenhua.luo at freescale.com
Wed Sep 9 01:28:31 PDT 2015


If a rootfs only contains core specific pkgs (no machine specific
ones), it is convenient and possible to share a common rootfs image
for all the machines with same core.

Add a patch (only works for fsl qoriq boards) to auto set hostname.

Also add support to set hostname via bootargs/cmdline.

Signed-off-by: Ting Liu <ting.liu at freescale.com>
Signed-off-by: Zhenhua Luo <zhenhua.luo at freescale.com>
---
 .../sysvinit/qoriq-ppc/auto-detect-hostname.patch  | 35 ++++++++++++++++++++++
 recipes-core/sysvinit/sysvinit_%.bbappend          |  5 ++++
 2 files changed, 40 insertions(+)
 create mode 100644 recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
 create mode 100644 recipes-core/sysvinit/sysvinit_%.bbappend

diff --git a/recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch b/recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
new file mode 100644
index 0000000..b1c6765
--- /dev/null
+++ b/recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
@@ -0,0 +1,35 @@
+auto detect hostname for qoriq machines
+    
+If a rootfs only contains core specific pkgs (no machine specific
+ones), it is convenient and possible to share a common rootfs image
+for all the machines with same core.
+    
+Add a patch (only works for fsl qoriq boards) to auto set hostname.
+    
+Also add support to set hostname via bootargs/cmdline.
+    
+Upstream-Status: Inappropriate
+
+Signed-off-by: Ting Liu <ting.liu at freescale.com>
+Signed-off-by: Zhenhua Luo <zhenhua.luo at freescale.com>
+
+diff -uNr sysvinit/rcS sysvinit-new/rcS
+--- sysvinit/rcS	2014-07-09 11:19:59.000000000 +0800
++++ sysvinit-new/rcS	2014-08-01 15:01:54.000000000 +0800
+@@ -21,6 +21,16 @@
+ #
+ . /etc/default/rcS
+ 
++# auto detect hostname
++#
++if test -r /proc/cmdline && grep -q ip=.*:.*: /proc/cmdline; then
++  sed -e "s,.*ip=.*:.*:.*:.*:\(\S*\):.*:.*,\1," /proc/cmdline >/etc/hostname
++elif test -r /proc/cmdline && grep -q hostname= /proc/cmdline; then
++  sed -e "s,.*hostname=\(\S*\)\s*.*,\1," /proc/cmdline >/etc/hostname
++elif test -r /proc/cpuinfo && grep -q ^model.*, /proc/cpuinfo; then
++  grep ^model /proc/cpuinfo | cut -d, -f2 | tr [A-Z] [a-z] >/etc/hostname
++fi
++
+ #
+ #	Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
+ #
diff --git a/recipes-core/sysvinit/sysvinit_%.bbappend b/recipes-core/sysvinit/sysvinit_%.bbappend
new file mode 100644
index 0000000..973492e
--- /dev/null
+++ b/recipes-core/sysvinit/sysvinit_%.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
+
+SRC_URI_append_qoriq-ppc = " \
+    file://auto-detect-hostname.patch;patchdir=../ \
+"
-- 
2.4.3



More information about the meta-freescale mailing list