public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "chris.larson via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: Cedric Hombourger <cedric.hombourger@siemens.com>,
	Christopher Larson <chris.larson@siemens.com>
Subject: [PATCH 2/3] hostname-customization: add initial customization package
Date: Tue, 11 Mar 2025 14:09:37 -0700	[thread overview]
Message-ID: <20250311210939.4090-3-chris.larson@siemens.com> (raw)
In-Reply-To: <20250311210939.4090-1-chris.larson@siemens.com>

From: Christopher Larson <chris.larson@siemens.com>

This package provides a simple customization package that allows the hostname to
be set in the image. As this value is set from the `HOSTNAME` metadata variable,
it must be set in the metadata.

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 .../customizations/hostname-customization.bb          | 11 +++++++++++
 .../hostname-customization/postinst.tmpl              |  5 +++++
 2 files changed, 16 insertions(+)
 create mode 100644 meta/recipes-support/customizations/hostname-customization.bb
 create mode 100644 meta/recipes-support/customizations/hostname-customization/postinst.tmpl

diff --git a/meta/recipes-support/customizations/hostname-customization.bb b/meta/recipes-support/customizations/hostname-customization.bb
new file mode 100644
index 00000000..ba37c973
--- /dev/null
+++ b/meta/recipes-support/customizations/hostname-customization.bb
@@ -0,0 +1,11 @@
+inherit dpkg-customization
+
+DESCRIPTION      = "Amend the system hostname"
+LICENSE          = "gpl-2.0"
+LIC_FILES_CHKSUM = "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
+MAINTAINER       = "isar-users <isar-users@googlegroups.com>"
+DEBIAN_DEPENDS   = "netbase"
+PV               = "0.3"
+SRC_URI          = "file://postinst.tmpl"
+TEMPLATE_FILES   = "postinst.tmpl"
+TEMPLATE_VARS    = "HOSTNAME"
diff --git a/meta/recipes-support/customizations/hostname-customization/postinst.tmpl b/meta/recipes-support/customizations/hostname-customization/postinst.tmpl
new file mode 100644
index 00000000..db9475df
--- /dev/null
+++ b/meta/recipes-support/customizations/hostname-customization/postinst.tmpl
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo "${HOSTNAME}" > /etc/hostname
+echo "127.0.1.1	${HOSTNAME}" >> /etc/hosts
+sed -i  -e 's/^127.0.0.1[[:space:]]\+localhost$/& localhost.localdomain/' /etc/hosts
-- 
2.47.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250311210939.4090-3-chris.larson%40siemens.com.

  parent reply	other threads:[~2025-03-11 21:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 21:09 [PATCH 0/3] Add 'customization' package support chris.larson via isar-users
2025-03-11 21:09 ` [PATCH 1/3] classes: add " chris.larson via isar-users
2025-03-11 21:09 ` chris.larson via isar-users [this message]
2025-03-11 21:09 ` [PATCH 3/3] testsuite: add 'customizations' test chris.larson via isar-users
2025-03-25 16:55 ` [PATCH 0/3] Add 'customization' package support Uladzimir Bely

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=20250311210939.4090-3-chris.larson@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=cedric.hombourger@siemens.com \
    --cc=chris.larson@siemens.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