From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH 3/6] meta/classes: add image-locales-extension class
Date: Thu, 18 Apr 2019 13:25:42 +0200 [thread overview]
Message-ID: <20190418112545.1201-4-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20190418112545.1201-1-claudius.heine.ext@siemens.com>
From: Claudius Heine <ch@denx.de>
This class allows to configure the locales of the image and also uses
'localepurge' to remove unwanted locales.
The locale can be configured the same way as with the
isar-cfg-localepurge package, via the `LOCALE_GEN` and `LOCALE_DEFAULT`
variables.
Signed-off-by: Claudius Heine <ch@denx.de>
---
meta/classes/image-locales-extension.bbclass | 97 ++++++++++++++++++++
meta/classes/image.bbclass | 1 +
meta/classes/rootfs.bbclass | 4 +
3 files changed, 102 insertions(+)
create mode 100644 meta/classes/image-locales-extension.bbclass
diff --git a/meta/classes/image-locales-extension.bbclass b/meta/classes/image-locales-extension.bbclass
new file mode 100644
index 0000000..3c0758f
--- /dev/null
+++ b/meta/classes/image-locales-extension.bbclass
@@ -0,0 +1,97 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+#
+# This class extends the image.bbclass for setting locales and purging unneeded
+# ones.
+
+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, sep='\n'):
+ locale_gen = d.getVar("LOCALE_GEN", True) or ""
+ return sep.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]))))
+
+ROOTFS_INSTALL_COMMAND_BEFORE_CLEAN += "image_install_localepurge_download"
+image_install_localepurge_download[weight] = "40"
+image_install_localepurge_download() {
+ sudo -E chroot '${ROOTFSDIR}' \
+ /usr/bin/apt-get ${ROOTFS_APT_ARGS} --download-only localepurge
+}
+
+ROOTFS_INSTALL_COMMAND += "image_install_localepurge_install"
+image_install_localepurge_install[weight] = "700"
+image_install_localepurge_install() {
+
+ # Generate locale and localepurge configuration:
+ cat<<__EOF__ > ${WORKDIR}/locale.gen
+${@get_locale_gen(d)}
+__EOF__
+ cat<<__EOF__ > ${WORKDIR}/locale.debconf
+locales locales/locales_to_be_generated multiselect ${@get_locale_gen(d, ', ')}
+locales locales/default_environment_locale select ${LOCALE_DEFAULT}
+__EOF__
+ cat<<__EOF__ > ${WORKDIR}/locale.default
+LANG=${LOCALE_DEFAULT}
+__EOF__
+ cat<<__EOF__ > ${WORKDIR}/locale.nopurge
+#USE_DPKG
+MANDELETE
+DONTBOTHERNEWLOCALE
+#SHOWFREEDSPACE
+#QUICKNDIRTYCALC
+#VERBOSE
+${@get_nopurge(d)}
+__EOF__
+
+ # Install configuration into image:
+ sudo -E -s <<'EOSUDO'
+ cat '${WORKDIR}/locale.gen' >> '${ROOTFSDIR}/etc/locale.gen'
+ cat '${WORKDIR}/locale.default' > '${ROOTFSDIR}/etc/default/locale'
+ cat '${WORKDIR}/locale.nopurge' > '${ROOTFSDIR}/etc/locale.nopurge'
+ cat '${WORKDIR}/locale.debconf' > '${ROOTFSDIR}/tmp/locale.debconf'
+
+ # Enter image and trigger locales config and localepurge:
+ chroot '${ROOTFSDIR}' /bin/sh <<'EOSH'
+ localepurge_state='i'
+ if dpkg -s localepurge 2>/dev/null >&2
+ then
+ echo 'localepurge was installed (leaving it installed later)'
+ else
+ localepurge_state='p'
+ echo 'localepurge was not installed (removing it later)'
+ apt-get ${ROOTFS_APT_ARGS} localepurge
+ fi
+
+ echo 'running locale debconf-set-selections'
+ debconf-set-selections /tmp/locale.debconf
+ rm -f '/tmp/locale.debconf'
+
+ echo 'reconfigure locales'
+ dpkg-reconfigure -f noninteractive locales
+
+ echo 'running localepurge'
+ localepurge
+
+ if [ "$localepurge_state" = 'p' ]
+ then
+ echo removing localepurge...
+ apt-get purge --yes localepurge
+ apt-get autoremove --purge --yes
+ fi
+EOSH
+EOSUDO
+}
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 89dc5e4..c1ae4f6 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -60,6 +60,7 @@ inherit image-sdk-extension
inherit image-cache-extension
inherit image-tools-extension
inherit image-postproc-extension
+inherit image-locales-extension
# Extra space for rootfs in MB
ROOTFS_EXTRA ?= "64"
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 0fc8ba8..5736eee 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -99,6 +99,7 @@ rootfs_install_pkgs_update() {
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0"
}
+
ROOTFS_INSTALL_COMMAND += "rootfs_install_resolvconf"
rootfs_install_resolvconf[weight] = "1"
rootfs_install_resolvconf() {
@@ -112,6 +113,9 @@ rootfs_install_pkgs_download() {
/usr/bin/apt-get ${ROOTFS_APT_ARGS} --download-only ${ROOTFS_PACKAGES}
}
+ROOTFS_INSTALL_COMMAND_BEFORE_CLEAN ??= ""
+ROOTFS_INSTALL_COMMAND += "${ROOTFS_INSTALL_COMMAND_BEFORE_CLEAN}"
+
ROOTFS_INSTALL_COMMAND += "${@ 'rootfs_install_clean_files' if (d.getVar('ROOTFS_CLEAN_FILES') or '').strip() else ''}"
rootfs_install_clean_files[weight] = "2"
rootfs_install_clean_files() {
--
2.20.1
next prev parent reply other threads:[~2019-04-18 11:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 11:25 [PATCH 0/6] pre-processing pipeline and transient package replacement claudius.heine.ext
2019-04-18 11:25 ` [PATCH 1/6] split up isar-bootstrap helper and implement pre-process pipeline claudius.heine.ext
2019-04-18 11:25 ` [PATCH 2/6] meta: remove transient package support claudius.heine.ext
2019-04-18 11:25 ` claudius.heine.ext [this message]
2019-04-18 11:25 ` [PATCH 4/6] meta/classes: add image-account-extension class claudius.heine.ext
2019-04-18 11:25 ` [PATCH 5/6] doc: update description of image customization claudius.heine.ext
2019-04-18 11:25 ` [PATCH 6/6] doc: some fixes claudius.heine.ext
2019-04-22 14:09 ` [PATCH 0/6] pre-processing pipeline and transient package replacement Maxim Yu. Osipov
2019-04-24 7:11 ` Claudius Heine
2019-04-24 8:18 ` Maxim Yu. Osipov
2019-04-24 8:38 ` Claudius Heine
2019-04-24 14:38 ` Baurzhan Ismagulov
2019-04-24 14:55 ` Claudius Heine
2019-04-25 10:06 ` Baurzhan Ismagulov
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=20190418112545.1201-4-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