Patchwork [meta-fsl-ppc] sysvinit: auto detect hostname for qoriq machines

login
register
mail settings
Submitter Ting Liu
Date Aug. 1, 2014, 7:36 a.m.
Message ID <1406878578-6899-1-git-send-email-ting.liu@freescale.com>
Download mbox | patch
Permalink /patch/77077/
State Rejected
Headers show

Comments

Ting Liu - Aug. 1, 2014, 7:36 a.m.
From: Ting Liu <ting.liu@freescale.com>

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@freescale.com>
---
 .../sysvinit/qoriq-ppc/auto-detect-hostname.patch      | 18 ++++++++++++++++++
 recipes-core/sysvinit/sysvinit_2.88dsf.bbappend        |  7 ++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
Gary Thomas - Aug. 1, 2014, 11:07 a.m.
On 2014-08-01 01:36, ting.liu@freescale.com wrote:
> From: Ting Liu <ting.liu@freescale.com>
>
> 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.

What if one wanted to have a permanent setting of /etc/hostname that
is neither from the boot command line nor the automatic setting?  I
don't think your patch allows for that.

>
> Also add support to set hostname via bootargs/cmdline.
>
> Signed-off-by: Ting Liu <ting.liu@freescale.com>
> ---
>   .../sysvinit/qoriq-ppc/auto-detect-hostname.patch      | 18 ++++++++++++++++++
>   recipes-core/sysvinit/sysvinit_2.88dsf.bbappend        |  7 ++++++-
>   2 files changed, 24 insertions(+), 1 deletion(-)
>   create mode 100644 recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
>
> 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..533f92e
> --- /dev/null
> +++ b/recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
> @@ -0,0 +1,18 @@
> +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,14 @@
> + #
> + . /etc/default/rcS
> +
> ++# auto detect hostname
> ++#
> ++if 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_2.88dsf.bbappend b/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
> index 72d991c..b87dd6b 100644
> --- a/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
> +++ b/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
> @@ -1 +1,6 @@
> -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
> +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
> +
> +SRC_URI_append_qoriq-ppc = " \
> +    file://auto-detect-hostname.patch;patchdir=../ \
> +"
> +
>
Otavio Salvador - Aug. 1, 2014, 1:01 p.m.
On Fri, Aug 1, 2014 at 4:36 AM,  <ting.liu@freescale.com> wrote:
> From: Ting Liu <ting.liu@freescale.com>
>
> 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@freescale.com>

This patch is a behaviour not a BSP thing. Please don't include it.

Nack!

Check the discussion we're having in OE-Core mailing list about the hostname.

Patch

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..533f92e
--- /dev/null
+++ b/recipes-core/sysvinit/sysvinit/qoriq-ppc/auto-detect-hostname.patch
@@ -0,0 +1,18 @@ 
+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,14 @@
+ #
+ . /etc/default/rcS
+ 
++# auto detect hostname
++#
++if 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_2.88dsf.bbappend b/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
index 72d991c..b87dd6b 100644
--- a/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
+++ b/recipes-core/sysvinit/sysvinit_2.88dsf.bbappend
@@ -1 +1,6 @@ 
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
+
+SRC_URI_append_qoriq-ppc = " \
+    file://auto-detect-hostname.patch;patchdir=../ \
+"
+