public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH v6 2/4] meta/isar-cfg-localepurge: added locale purge recipe
Date: Wed, 30 May 2018 13:49:58 +0200	[thread overview]
Message-ID: <20180530115000.14424-3-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20180530115000.14424-1-claudius.heine.ext@siemens.com>

From: Claudius Heine <ch@denx.de>

The package 'isar-cfg-localepurge' is used to set the locales of the
root file system and purge all not required locales.

The variables used to configure the locale with this package are `LOCALE_GEN`
which is basically the content of the desired `/etc/locale.gen` with each
line seperated by '\n' and `LOCALE_DEFAULT` which sets the global default
locale of the system.

Signed-off-by: Claudius Heine <ch@denx.de>
---
 .../isar-cfg-localepurge/files/postinst       | 13 ++++
 .../isar-cfg-localepurge.bb                   | 65 +++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
 create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

diff --git a/meta/recipes-support/isar-cfg-localepurge/files/postinst b/meta/recipes-support/isar-cfg-localepurge/files/postinst
new file mode 100644
index 0000000..c5f1c51
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/files/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+cat /usr/lib/isar-cfg-localepurge/locale.gen \
+	>> /etc/locale.gen
+cat /usr/lib/isar-cfg-localepurge/locale.nopurge \
+	> /etc/locale.nopurge
+
+debconf-set-selections /usr/lib/isar-cfg-localepurge/locale.debconf
+
+dpkg-reconfigure -f noninteractive locales
+
+localepurge
diff --git a/meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb b/meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb
new file mode 100644
index 0000000..bdbc2b1
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb
@@ -0,0 +1,65 @@
+# This software is a part of ISAR.
+
+DESCRIPTION = "Isar configuration package for locale and localepurge"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+DEBIAN_DEPENDS = "localepurge"
+
+SRC_URI = "file://postinst"
+
+inherit dpkg-raw
+
+LOCALE_GEN ?= "en_US.UTF-8 UTF-8\n\
+               en_US ISO-8859-1\n"
+LOCALE_DEFAULT ?= "en_US.UTF-8"
+
+def get_locale_gen(d):
+    locale_gen = d.getVar("LOCALE_GEN", True) or ""
+    return '\n'.join(sorted(set(i.strip()
+                                for i in locale_gen.split('\\n')
+                                if i.strip())))
+
+def get_dc_locale_gen(d):
+    locale_gen = d.getVar("LOCALE_GEN", True) or ""
+    return ', '.join(sorted(set(i.strip()
+                                for i in locale_gen.split('\\n')
+                                if i.strip())))
+
+def get_nopurge(d):
+    locale_gen = d.getVar("LOCALE_GEN", True) or ""
+    return '\n'.join(sorted(set(i.strip()
+                                for j in locale_gen.split('\\n')
+                                if j.strip()
+                                for i in (j.split()[0].split("_")[0],
+                                          j.split()[0].split(".")[0],
+                                          j.split()[0]))))
+
+do_gen_config[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
+do_gen_config() {
+	cat<<-__EOF__ > ${WORKDIR}/locale.gen
+		${@get_locale_gen(d)}
+	__EOF__
+	cat<<-__EOF__ > ${WORKDIR}/locale.debconf
+		locales     locales/locales_to_be_generated    multiselect ${@get_dc_locale_gen(d)}
+		locales     locales/default_environment_locale select      ${LOCALE_DEFAULT}
+	__EOF__
+	cat<<-__EOF__ > ${WORKDIR}/locale.nopurge
+		#USE_DPKG
+		MANDELETE
+		DONTBOTHERNEWLOCALE
+		#SHOWFREEDSPACE
+		#QUICKNDIRTYCALC
+		#VERBOSE
+		${@get_nopurge(d)}
+	__EOF__
+}
+addtask gen_config after do_unpack before do_install
+
+do_install() {
+	install -v -d ${D}/usr/lib/${PN}
+	install -v -m 644 ${WORKDIR}/locale.debconf \
+                          ${D}/usr/lib/${PN}/locale.debconf
+	install -v -m 644 ${WORKDIR}/locale.gen \
+                          ${D}/usr/lib/${PN}/locale.gen
+	install -v -m 644 ${WORKDIR}/locale.nopurge \
+                          ${D}/usr/lib/${PN}/locale.nopurge
+}
-- 
2.17.0


  parent reply	other threads:[~2018-05-30 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 11:49 [PATCH v6 0/4] One-shot configuration packages claudius.heine.ext
2018-05-30 11:49 ` [PATCH v6 1/4] isar-bootstrap|configscript: implement one transient packages claudius.heine.ext
2018-05-30 11:49 ` claudius.heine.ext [this message]
2018-05-30 11:49 ` [PATCH v6 3/4] meta-isar/isar-image-base: switch use isar-cfg-localepurge claudius.heine.ext
2018-05-30 11:50 ` [PATCH v6 4/4] doc: added description of `IMAGE_TRANSIENT_PACKAGES` and locale vars claudius.heine.ext

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=20180530115000.14424-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