From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [RFC PATCH 2/2] meta: add isar-cfg-hostname recipe for setting the hostname
Date: Tue, 5 Feb 2019 14:42:35 +0100 [thread overview]
Message-ID: <20190205134235.27523-3-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20190205134235.27523-1-claudius.heine.ext@siemens.com>
From: Claudius Heine <ch@denx.de>
The isar-cfg-hostname recipe is a central point to set the hostname
for images. It provides the `CFG_HOSTNAME` variables, which can be set
from any `.conf` file or via `isar-cfg-hostname.bbappend` to the
hostname that should be used. The default is 'isar'.
Signed-off-by: Claudius Heine <ch@denx.de>
---
meta-isar/conf/local.conf.sample | 2 +-
meta-isar/recipes-app/example-raw/files/postinst | 2 --
.../isar-cfg-hostname/files/postinst.tmpl | 8 ++++++++
.../isar-cfg-hostname/isar-cfg-hostname.bb | 16 ++++++++++++++++
4 files changed, 25 insertions(+), 3 deletions(-)
create mode 100644 meta/recipes-support/isar-cfg-hostname/files/postinst.tmpl
create mode 100644 meta/recipes-support/isar-cfg-hostname/isar-cfg-hostname.bb
diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index a2bdd7e..ddd15a4 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -162,7 +162,7 @@ CONF_VERSION = "1"
#
# The default list of extra packages to be installed.
IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck \
- isar-cfg-rootpw"
+ isar-cfg-rootpw isar-cfg-hostname"
#
# Enable cross-compilation support
diff --git a/meta-isar/recipes-app/example-raw/files/postinst b/meta-isar/recipes-app/example-raw/files/postinst
index f48d993..a28afa3 100644
--- a/meta-isar/recipes-app/example-raw/files/postinst
+++ b/meta-isar/recipes-app/example-raw/files/postinst
@@ -14,5 +14,3 @@ if ! getent passwd isar >/dev/null; then
fi
chown -R isar:isar /var/lib/isar
-
-echo "isar" > /etc/hostname
diff --git a/meta/recipes-support/isar-cfg-hostname/files/postinst.tmpl b/meta/recipes-support/isar-cfg-hostname/files/postinst.tmpl
new file mode 100644
index 0000000..b46433b
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-hostname/files/postinst.tmpl
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+if [ ! -e "/etc/hostname" ]; then
+ echo "${CFG_HOSTNAME}" > /etc/hostname
+else
+ echo "/etc/hostname already exists, error" >&2
+ exit -1
+fi
diff --git a/meta/recipes-support/isar-cfg-hostname/isar-cfg-hostname.bb b/meta/recipes-support/isar-cfg-hostname/isar-cfg-hostname.bb
new file mode 100644
index 0000000..aa41f73
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-hostname/isar-cfg-hostname.bb
@@ -0,0 +1,16 @@
+# This software is a part of ISAR.
+
+DESCRIPTION = "Isar configuration package for hostname"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+SRC_URI = "file://postinst.tmpl"
+
+TEMPLATE_FILES = "postinst.tmpl"
+TEMPLATE_VARS = "CFG_HOSTNAME"
+CFG_HOSTNAME ??= "isar"
+
+inherit dpkg-raw
+
+do_install() {
+ echo "intentionally left blank"
+}
--
2.20.1
next prev parent reply other threads:[~2019-02-05 13:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-05 13:42 [RFC PATCH 0/2] Centralize root password and hostname setting claudius.heine.ext
2019-02-05 13:42 ` [RFC PATCH 1/2] meta: add isar-cfg-rootpw recipe for setting root password claudius.heine.ext
2019-02-06 12:12 ` Henning Schild
2019-02-05 13:42 ` claudius.heine.ext [this message]
2019-02-06 12:15 ` [RFC PATCH 2/2] meta: add isar-cfg-hostname recipe for setting the hostname Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190205134235.27523-3-claudius.heine.ext@siemens.com \
--to=claudius.heine.ext@siemens.com \
--cc=ch@denx.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox