[PATCH 3/3] meta-isar/isar-image-base: switch use isar-cfg-localepurge

9 views
Skip to first unread message

claudius....@siemens.com

unread,
May 23, 2018, 8:18:06 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../images/files/debian-configscript.sh | 30 -------------------
.../images/files/raspbian-configscript.sh | 29 ------------------
.../recipes-core/images/isar-image-base.bb | 6 ++--
3 files changed, 3 insertions(+), 62 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 0ff2f0f..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,33 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-cat >> /etc/default/locale << EOF
-LANG=en_US.UTF-8
-LANGUAGE=en_US.UTF-8
-LC_ALL=C
-LC_CTYPE=C
-EOF
-
-## Configuration file for localepurge(8)
-cat > /etc/locale.nopurge << EOF
-
-# Remove localized man pages
-MANDELETE
-
-# Delete new locales which appear on the system without bothering you
-DONTBOTHERNEWLOCALE
-
-# Keep these locales after package installations via apt-get(8)
-en
-en_US
-en_US.UTF-8
-EOF
-
-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -59,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 47c9c37..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -10,33 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-cat >> /etc/default/locale << EOF
-LANG=en_US.UTF-8
-LANGUAGE=en_US.UTF-8
-LC_ALL=C
-LC_CTYPE=C
-EOF
-
-## Configuration file for localepurge(8)
-cat > /etc/locale.nopurge << EOF
-
-# Remove localized man pages
-MANDELETE
-
-# Delete new locales which appear on the system without bothering you
-DONTBOTHERNEWLOCALE
-
-# Keep these locales after package installations via apt-get(8)
-en
-en_US
-en_US.UTF-8
-EOF
-
-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -60,5 +33,3 @@ KERNEL_IMAGE=`ls /boot | grep vmlinuz`
cat > /boot/config.txt << EOF
kernel=$KERNEL_IMAGE
EOF
-
-localepurge
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index baac531..beb6f14 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -16,11 +16,11 @@ PV = "1.0"
inherit image
inherit isar-bootstrap-helper

-DEPENDS += "${IMAGE_INSTALL}"
+DEPENDS += "${IMAGE_INSTALL} ${IMAGE_CFG_PACKAGE}"

IMAGE_PREINSTALL += "apt \
- dbus \
- localepurge"
+ dbus"
+IMAGE_CFG_PACKAGE += "isar-cfg-localepurge"

WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"

--
2.17.0

claudius....@siemens.com

unread,
May 23, 2018, 8:18:06 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

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

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
4 files changed, 62 insertions(+)
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
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/locale.debconf b/meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
new file mode 100644
index 0000000..169c071
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
@@ -0,0 +1,12 @@
+locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
+locales locales/default_environment_locale select en_US.UTF-8
+
+localepurge localepurge/dontbothernew boolean true
+localepurge localepurge/nopurge multiselect en, en_US, en_US.UTF-8
+localepurge localepurge/use-dpkg-feature boolean false
+localepurge localepurge/verbose boolean false
+localepurge localepurge/showfreedspace boolean false
+localepurge localepurge/none_selected boolean false
+localepurge localepurge/mandelete boolean true
+localepurge localepurge/quickndirtycalc boolean false
+localepurge localepurge/remove_no note
diff --git a/meta/recipes-support/isar-cfg-localepurge/files/locale.gen b/meta/recipes-support/isar-cfg-localepurge/files/locale.gen
new file mode 100644
index 0000000..a66d814
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/files/locale.gen
@@ -0,0 +1 @@
+en_US.UTF-8 UTF-8
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..3ef93cd
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/files/postinst
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+
+cat /usr/local/etc/isar-cfg-localepurge/locale.gen \
+ >> /etc/locale.gen
+
+debconf-set-selections /usr/local/etc/isar-cfg-localepurge/locale.debconf
+
+# locale.nopurge needs to be removed before localepurge is reconfigured.
+# Otherwise it would set the debconf to the values from the locale.nopurge
+# file again.
+rm -rf /etc/locale.nopurge
+dpkg-reconfigure -f noninteractive locales localepurge
+
+# When /etc/locale.nopurge was removed before dpkg-reconfigure, it writes
+# the new configuration with the '.ucf-dist' postfix
+mv /etc/locale.nopurge.ucf-dist /etc/locale.nopurge
+
+# Now reconfigure it localpurge again, because otherwise it would complain:
+# Some new locales have appeared on your system:
+#
+# bal be@latin en@boldquot en@quot sr@latin
+#
+# They will not be touched until you reconfigure localepurge
+# with the following command:
+#
+# dpkg-reconfigure localepurge
+dpkg-reconfigure -f noninteractive localepurge
+
+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..b68a6d0
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb
@@ -0,0 +1,19 @@
+# This software is a part of ISAR.
+
+DESCRIPTION = "Isar configuration package for locale and localepurge"
+MAINTAINER = "isar-users <isar-...@googlegroups.com>"
+DEBIAN_DEPENDS = "localepurge"
+
+SRC_URI = "file://locale.debconf \
+ file://locale.gen \
+ file://postinst"
+
+inherit dpkg-raw
+
+do_install() {
+ install -v -d ${D}/usr/local/etc/${PN}
+ install -v -m 644 ${WORKDIR}/locale.debconf \
+ ${D}/usr/local/etc/${PN}/locale.debconf
+ install -v -m 644 ${WORKDIR}/locale.gen \
+ ${D}/usr/local/etc/${PN}/locale.gen
+}
--
2.17.0

claudius....@siemens.com

unread,
May 23, 2018, 8:18:06 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

here is my implementation of one-shot packages.

I also implemented a packages that does the localepurge step.

Claudius

Claudius Heine (3):
isar-bootstrap|configscript: implement one shot config option
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge

.../images/files/debian-configscript.sh | 31 -------------------
.../images/files/raspbian-configscript.sh | 30 ------------------
.../recipes-core/images/isar-image-base.bb | 6 ++--
meta/classes/isar-bootstrap-helper.bbclass | 23 +++++++++++---
.../isar-cfg-localepurge/files/locale.debconf | 12 +++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 ++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
8 files changed, 84 insertions(+), 68 deletions(-)
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

--
2.17.0

claudius....@siemens.com

unread,
May 23, 2018, 8:18:06 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Some configuration tasks on the image require certain other packages,
but those packages might not be required on the final image.

One way to solve this is use a special package that is installed to the
image and then removed again. When installing it makes certain that all
required packages are installed to the image as well. Then the image
can be configured in the postinst hook. When this package is removed and
all unused dependencies are removed as well, no not required packages
used by this package should remain on the image.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../images/files/debian-configscript.sh | 1 -
.../images/files/raspbian-configscript.sh | 1 -
meta/classes/isar-bootstrap-helper.bbclass | 23 +++++++++++++++----
3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 042b530..0ff2f0f 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -62,4 +62,3 @@ fi

# Purge unused locale and installed packages' .deb files
localepurge
-apt-get clean
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index ec05a6b..47c9c37 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -62,4 +62,3 @@ kernel=$KERNEL_IMAGE
EOF

localepurge
-apt-get clean
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 4284d02..76e20f6 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -5,15 +5,17 @@
#
# SPDX-License-Identifier: MIT

+IMAGE_CFG_PACKAGE ??= ""
+
setup_root_file_system() {
ROOTFSDIR="$1"
- CLEANHOSTLEAK="$2"
+ CLEAN="$2"
shift
shift
PACKAGES="$@"
APT_ARGS="install --yes --allow-unauthenticated \
-o Debug::pkgProblemResolver=yes"
- CLEANHOSTLEAK_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
+ CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"

sudo cp -Trpfx \
"${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
@@ -41,8 +43,21 @@ setup_root_file_system() {
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0"
sudo -E chroot "$ROOTFSDIR" \
- /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES
- [ "clean" = ${CLEANHOSTLEAK} ] && sudo rm -f ${CLEANHOSTLEAK_FILES}
+ /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \
+ ${IMAGE_CFG_PACKAGE}
+ [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES}
sudo -E chroot "$ROOTFSDIR" \
/usr/bin/apt-get ${APT_ARGS} $PACKAGES
+ if [ -n "${IMAGE_CFG_PACKAGE}" ]; then
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get ${APT_ARGS} ${IMAGE_CFG_PACKAGE}
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get purge -y ${IMAGE_CFG_PACKAGE}
+ fi
+ if [ "clean" = ${CLEAN} ]; then
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get autoremove --purge -y
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get clean
+ fi
}
--
2.17.0

Claudius Heine

unread,
May 23, 2018, 8:56:22 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
Hi.

I apparently need to do a v2 for this, since Alex 'Last fixes for
locales' patchset was on the fast lane and has gone to next and
simultaneously to master without any time to review it.

Claudius
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: c...@denx.de

claudius....@siemens.com

unread,
May 23, 2018, 9:12:54 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../recipes-core/images/files/debian-configscript.sh | 8 --------
.../recipes-core/images/files/raspbian-configscript.sh | 7 -------
meta-isar/recipes-core/images/isar-image-base.bb | 6 +++---
meta/recipes-core/isar-bootstrap/files/locale.nopurge | 10 ----------
meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 4 +---
5 files changed, 4 insertions(+), 31 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 9b3ff30..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -37,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 448dea5..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -38,5 +33,3 @@ KERNEL_IMAGE=`ls /boot | grep vmlinuz`
cat > /boot/config.txt << EOF
kernel=$KERNEL_IMAGE
EOF
-
-localepurge
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index baac531..beb6f14 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -16,11 +16,11 @@ PV = "1.0"
inherit image
inherit isar-bootstrap-helper

-DEPENDS += "${IMAGE_INSTALL}"
+DEPENDS += "${IMAGE_INSTALL} ${IMAGE_CFG_PACKAGE}"

IMAGE_PREINSTALL += "apt \
- dbus \
- localepurge"
+ dbus"
+IMAGE_CFG_PACKAGE += "isar-cfg-localepurge"

WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"

diff --git a/meta/recipes-core/isar-bootstrap/files/locale.nopurge b/meta/recipes-core/isar-bootstrap/files/locale.nopurge
deleted file mode 100644
index 510d40c..0000000
--- a/meta/recipes-core/isar-bootstrap/files/locale.nopurge
+++ /dev/null
@@ -1,10 +0,0 @@
-# Remove localized man pages
-MANDELETE
-
-# Delete new locales which appear on the system without bothering you
-DONTBOTHERNEWLOCALE
-
-# Keep these locales after package installations via apt-get(8)
-en
-en_US
-en_US.UTF-8
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb b/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb
index f894821..bb3992b 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb
@@ -13,8 +13,7 @@ FILESPATH_prepend := "${THISDIR}/files:"
SRC_URI = " \
file://isar-apt.conf \
file://isar-apt-fallback.conf \
- file://locale \
- file://locale.nopurge"
+ file://locale"
PV = "1.0"

WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
@@ -196,7 +195,6 @@ addtask bootstrap before do_build after do_generate_keyring

do_set_locale() {
sudo install -v -m644 "${WORKDIR}/locale" "${ROOTFSDIR}/etc/locale"
- sudo install -v -m644 "${WORKDIR}/locale.nopurge" "${ROOTFSDIR}/etc/locale.nopurge"

sudo sed -i '/en_US.UTF-8 UTF-8/s/^#//g' "${ROOTFSDIR}/etc/locale.gen"
sudo -E chroot "${ROOTFSDIR}" /usr/sbin/locale-gen
--
2.17.0

claudius....@siemens.com

unread,
May 23, 2018, 9:12:54 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

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

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
4 files changed, 62 insertions(+)
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

claudius....@siemens.com

unread,
May 23, 2018, 9:12:54 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Some configuration tasks on the image require certain other packages,
but those packages might not be required on the final image.

One way to solve this is use a special package that is installed to the
image and then removed again. When installing it makes certain that all
required packages are installed to the image as well. Then the image
can be configured in the postinst hook. When this package is removed and
all unused dependencies are removed as well, no not required packages
used by this package should remain on the image.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../images/files/debian-configscript.sh | 1 -
.../images/files/raspbian-configscript.sh | 1 -
meta/classes/isar-bootstrap-helper.bbclass | 23 +++++++++++++++----
3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 7ca0562..9b3ff30 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -40,4 +40,3 @@ fi

# Purge unused locale and installed packages' .deb files
localepurge
-apt-get clean
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index b240de9..448dea5 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -40,4 +40,3 @@ kernel=$KERNEL_IMAGE

claudius....@siemens.com

unread,
May 23, 2018, 9:12:54 AM5/23/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

here is the rebased patchset that removes the issue with the global
localepurge configuration as well.

Claudius

Changes from v1:
- rebased to current next
- removed locale.nopurge setup in isar-bootstrap

Claudius Heine (3):
isar-bootstrap|configscript: implement one shot config option
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge

.../images/files/debian-configscript.sh | 9 ------
.../images/files/raspbian-configscript.sh | 8 -----
.../recipes-core/images/isar-image-base.bb | 6 ++--
meta/classes/isar-bootstrap-helper.bbclass | 23 +++++++++++---
.../isar-bootstrap/files/locale.nopurge | 10 -------
.../isar-bootstrap/isar-bootstrap.bb | 4 +--
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
10 files changed, 85 insertions(+), 37 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

--
2.17.0

Alexander Smirnov

unread,
May 23, 2018, 9:16:32 AM5/23/18
to Claudius Heine, isar-...@googlegroups.com, Claudius Heine


Claudius Heine <claudius....@siemens.com> 23 мая 2018 г. 15:56:29
написал:

> Hi.
>
> I apparently need to do a v2 for this, since Alex 'Last fixes for
> locales' patchset was on the fast lane and has gone to next and
> simultaneously to master without any time to review it.

1. The patches were sent on May 15 and pushed on May 18 in the evening. In
my opinion 3 days is quite enough to perform the review. So no fast lane
for my patches.

2. Master branch merged after next branch becomes green.

Probably you assume that git commit date represents actual repository
pushing, what is wrong. It represents git am date.

Alex
> --
> 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+...@googlegroups.com.
> To post to this group, send email to isar-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/isar-users/bf3f2835-98b0-1ee0-1b88-5609af44bef6%40siemens.com.
> For more options, visit https://groups.google.com/d/optout.



Claudius Heine

unread,
May 23, 2018, 9:34:56 AM5/23/18
to Alexander Smirnov, isar-...@googlegroups.com, Claudius Heine
Hi Alex,

On 2018-05-23 15:16, Alexander Smirnov wrote:
>
>
> Claudius Heine <claudius....@siemens.com> 23 мая 2018 г. 15:56:29
> написал:
>
>> Hi.
>>
>> I apparently need to do a v2 for this, since Alex 'Last fixes for
>> locales' patchset was on the fast lane and has gone to next and
>> simultaneously to master without any time to review it.
>
> 1. The patches were sent on May 15 and pushed on May 18 in the evening.
> In my opinion 3 days is quite enough to perform the review. So no fast
> lane for my patches.

Ok, then its just my experience that patches are on the list for longer,
even if they aren't commented on. (I also was on vacation for this
period, so I couldn't review it in time and it might seemed shorter for
me. But that is my issue :)

>
> 2. Master branch merged after next branch becomes green.
>
> Probably you assume that git commit date represents actual repository
> pushing, what is wrong. It represents git am date.

I was mainly missing the 'merged' confirmation on the Mailinglist. I
normally use that to know if I need to rebase or review.

Claudius

Alexander Smirnov

unread,
May 23, 2018, 9:43:55 AM5/23/18
to Claudius Heine, isar-...@googlegroups.com, Claudius Heine


Claudius Heine <claudius....@siemens.com> 23 мая 2018 г. 16:34:59
написал:

> Hi Alex,
>
> On 2018-05-23 15:16, Alexander Smirnov wrote:
>>
>>
>> Claudius Heine <claudius....@siemens.com> 23 мая 2018 г. 15:56:29
>> написал:
>>
>>> Hi.
>>>
>>> I apparently need to do a v2 for this, since Alex 'Last fixes for
>>> locales' patchset was on the fast lane and has gone to next and
>>> simultaneously to master without any time to review it.
>>
>> 1. The patches were sent on May 15 and pushed on May 18 in the evening.
>> In my opinion 3 days is quite enough to perform the review. So no fast
>> lane for my patches.
>
> Ok, then its just my experience that patches are on the list for longer,
> even if they aren't commented on. (I also was on vacation for this
> period, so I couldn't review it in time and it might seemed shorter for
> me. But that is my issue :)
>
>>
>> 2. Master branch merged after next branch becomes green.
>>
>> Probably you assume that git commit date represents actual repository
>> pushing, what is wrong. It represents git am date.
>
> I was mainly missing the 'merged' confirmation on the Mailinglist. I
> normally use that to know if I need to rebase or review.

That's actualy my fault, no comments here. I thought I did it. :-(

Alex

Henning Schild

unread,
May 23, 2018, 10:03:30 AM5/23/18
to [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com, Claudius Heine
Nice patchset. It follows the "everything that enters the rootfs should
come from a package" approach. And it introduced a nice hack to execute
scripts in the "last package", switching from the chrootable folder to
the image.
Things like removing qemu, resolv.conf etc could also be done in such a
"final" package postrm.

Henning

Am Wed, 23 May 2018 15:12:45 +0200
schrieb "[ext] claudius....@siemens.com"
<claudius....@siemens.com>:

Henning Schild

unread,
May 23, 2018, 10:06:08 AM5/23/18
to [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com, Claudius Heine
Am Wed, 23 May 2018 15:12:46 +0200
schrieb "[ext] claudius....@siemens.com"
<claudius....@siemens.com>:
I guess if you take the "install" out you can reuse that a few more
times.

> - CLEANHOSTLEAK_FILES="${ROOTFSDIR}/etc/hostname
> ${ROOTFSDIR}/etc/resolv.conf"
> + CLEAN_FILES="${ROOTFSDIR}/etc/hostname
> ${ROOTFSDIR}/etc/resolv.conf"
> sudo cp -Trpfx \
> "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/"
> \ @@ -41,8 +43,21 @@ setup_root_file_system() {
> -o Dir::Etc::sourceparts="-" \
> -o APT::Get::List-Cleanup="0"
> sudo -E chroot "$ROOTFSDIR" \
> - /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES
> - [ "clean" = ${CLEANHOSTLEAK} ] && sudo rm -f
> ${CLEANHOSTLEAK_FILES}
> + /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \
> + ${IMAGE_CFG_PACKAGE}
> + [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES}
> sudo -E chroot "$ROOTFSDIR" \
> /usr/bin/apt-get ${APT_ARGS} $PACKAGES
> + if [ -n "${IMAGE_CFG_PACKAGE}" ]; then
> + sudo -E chroot "$ROOTFSDIR" \
> + /usr/bin/apt-get ${APT_ARGS} ${IMAGE_CFG_PACKAGE}

Say we have multiple packages here, are we sure apt-get will get the
order right?
Would it make sense to use a loop to deal with potential lists and
their order?

Henning

Henning Schild

unread,
May 23, 2018, 10:16:10 AM5/23/18
to [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com, Claudius Heine
Am Wed, 23 May 2018 15:12:47 +0200
schrieb "[ext] claudius....@siemens.com"
<claudius....@siemens.com>:
All of this is pretty evil. This package is installed last, so if i had
any package before it dealing with locales ... Would i need to remember
to clear IMAGE_CFG_PACKAGE?
I guess some checking should be done before proceeding here.

And thinking about it, do we not need to set the locales very early? I
remember all the perl warning in buildchroot.
/usr/local/ suggests that we are not under package manager regime here,
i googled it for a similar need and came to the conclusion
that /usr/lib/${PN} would be the right place for such files. Or pack
them into postinst as self extracting tar to gain a "staging area". In
your case the package gets removed so you do not have to worry about
potential copies. Still the location should not be /usr/local/...

Henning

Claudius Heine

unread,
May 23, 2018, 10:39:17 AM5/23/18
to Henning Schild, isar-...@googlegroups.com, Claudius Heine
Hi Henning,
I would still like to set the base locale in isar-bootstrap like its
done in Alexs patchset. This avoids perl warnings. But that should just
be a 'default' locale. The final locale should be done in a package like
this.

Maybe we can generate some these settings by bitbake variables.
Otherwise you could just overwrite the postinst script in your own
bbappend to this recipe.

All your other suggestions are good and I will prepare a v2 with them.

Thanks a lot!
Claudius

Claudius Heine

unread,
May 24, 2018, 3:06:58 AM5/24/18
to Henning Schild, isar-...@googlegroups.com, Claudius Heine
Hi Henning,
Where? I only see purge and autoremove that doesn't use it already.
Replaceing '-y' with '${APT_ARGS}' there does seem like an overkill,
does it not? The other options in it don't do much for purge and
autoremove AFAIK.

If you think of this as a general improvement to have the command
outside of the 'APT_ARGS' variable for readability reasons, then I
agree, but that would be a different patch.

Claudius Heine

unread,
May 24, 2018, 4:38:50 AM5/24/18
to Henning Schild, isar-...@googlegroups.com, Claudius Heine
Hi Henning,

On 2018-05-23 16:03, Henning Schild wrote:
> Nice patchset. It follows the "everything that enters the rootfs should
> come from a package" approach. And it introduced a nice hack to execute
> scripts in the "last package", switching from the chrootable folder to
> the image.
> Things like removing qemu, resolv.conf etc could also be done in such a
> "final" package postrm.

I initially liked the idea about removing qemu with a package, but I
don't think that is possible. After removal of this binary no commands
can be executed in the chroot environment, and we still need to purge
the package and cleanup the dependencies/cache etc. AFAIK it needs to be
done from outside.

For removal of for hostname and resolv.conf I am not so sure. IMO that
should be done before any custom package is installed. This way the
deployment of those files can be done by any package and those files are
managed by dpkg.

I currently cannot think of anything that should/could be
installed/executed/removed this way apart from localepurge. But there
might be more administrative tasks that could be done this way.

I thought about moving the locale config outside the
isar-cfg-localepurge package, but since I don't actually deploy any
locale config files, and just modify the debconf + reconfigure the
locales package its ok here IMO. And it might be useful to have the
whole locales configuration in one place.

Claudius

Henning Schild

unread,
May 24, 2018, 4:57:50 AM5/24/18
to Claudius Heine, isar-...@googlegroups.com, Claudius Heine
Am Thu, 24 May 2018 09:06:56 +0200
schrieb Claudius Heine <claudius....@siemens.com>:
I did not check whether the rest is usefull for purge etc. In that case
i would suggest to stick with "--yes" instead of "-y" just for
consistency.

Henning

claudius....@siemens.com

unread,
May 24, 2018, 10:26:39 AM5/24/18
to isar-...@googlegroups.com, Claudius Heine
index 4284d02..1d21831 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -5,15 +5,17 @@
#
# SPDX-License-Identifier: MIT

+IMAGE_CFG_PACKAGE ??= ""
+
setup_root_file_system() {
ROOTFSDIR="$1"
- CLEANHOSTLEAK="$2"
+ CLEAN="$2"
shift
shift
PACKAGES="$@"
APT_ARGS="install --yes --allow-unauthenticated \
-o Debug::pkgProblemResolver=yes"
- CLEANHOSTLEAK_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
+ CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"

sudo cp -Trpfx \
"${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
@@ -41,8 +43,21 @@ setup_root_file_system() {
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0"
sudo -E chroot "$ROOTFSDIR" \
- /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES
- [ "clean" = ${CLEANHOSTLEAK} ] && sudo rm -f ${CLEANHOSTLEAK_FILES}
+ /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \
+ ${IMAGE_CFG_PACKAGE}
+ [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES}
sudo -E chroot "$ROOTFSDIR" \
/usr/bin/apt-get ${APT_ARGS} $PACKAGES
+ for pkg in ${IMAGE_CFG_PACKAGE}; do
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get ${APT_ARGS} $pkg
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get purge --yes $pkg
+ done
+ if [ "clean" = ${CLEAN} ]; then
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get autoremove --purge --yes
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get clean
+ fi
}
--
2.17.0

claudius....@siemens.com

unread,
May 24, 2018, 10:26:40 AM5/24/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

here is the new version of this patchset. I integrated most of Hennings
suggestions.

Claudius

Changes from v2:
- Install one-shot package with a loop
- Rename '-y' apt parameter to '--yes'
- Move isar-cfg-localepurge files from /usr/local/etc to /usr/lib/

Changes from v1:
- rebased to current next
- removed locale.nopurge setup in isar-bootstrap

Claudius Heine (3):
isar-bootstrap|configscript: implement one shot config option
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge

.../images/files/debian-configscript.sh | 9 ------
.../images/files/raspbian-configscript.sh | 8 -----
.../recipes-core/images/isar-image-base.bb | 6 ++--
meta/classes/isar-bootstrap-helper.bbclass | 23 +++++++++++---
.../isar-bootstrap/files/locale.nopurge | 10 -------
.../isar-bootstrap/isar-bootstrap.bb | 4 +--
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
10 files changed, 85 insertions(+), 37 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

--
2.17.0

claudius....@siemens.com

unread,
May 24, 2018, 10:26:40 AM5/24/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../recipes-core/images/files/debian-configscript.sh | 8 --------
.../recipes-core/images/files/raspbian-configscript.sh | 7 -------
meta-isar/recipes-core/images/isar-image-base.bb | 6 +++---
meta/recipes-core/isar-bootstrap/files/locale.nopurge | 10 ----------
meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 4 +---
5 files changed, 4 insertions(+), 31 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 9b3ff30..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -37,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 448dea5..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -38,5 +33,3 @@ KERNEL_IMAGE=`ls /boot | grep vmlinuz`
cat > /boot/config.txt << EOF
kernel=$KERNEL_IMAGE
EOF
-
-localepurge
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index 1239f72..0d46d74 100644

claudius....@siemens.com

unread,
May 24, 2018, 10:26:41 AM5/24/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

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

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
4 files changed, 62 insertions(+)
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

index 0000000..092f12e
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/files/postinst
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+
+cat /usr/lib/isar-cfg-localepurge/locale.gen \
+ >> /etc/locale.gen
+
+debconf-set-selections /usr/lib/isar-cfg-localepurge/locale.debconf
index 0000000..d2cf1f3
--- /dev/null
+++ b/meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb
@@ -0,0 +1,19 @@
+# This software is a part of ISAR.
+
+DESCRIPTION = "Isar configuration package for locale and localepurge"
+MAINTAINER = "isar-users <isar-...@googlegroups.com>"
+DEBIAN_DEPENDS = "localepurge"
+
+SRC_URI = "file://locale.debconf \
+ file://locale.gen \
+ file://postinst"
+
+inherit dpkg-raw
+
+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
+}
--
2.17.0

Henning Schild

unread,
May 24, 2018, 11:45:32 AM5/24/18
to [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com, Claudius Heine
Am Thu, 24 May 2018 16:26:33 +0200
schrieb "[ext] claudius....@siemens.com"
<claudius....@siemens.com>:
Sorry for not pointing that out the first time. But if we loop we
should probably do that twice, on the purge in reverse order.

Henning

Maxim Yu. Osipov

unread,
May 25, 2018, 8:26:01 AM5/25/18
to Henning Schild, [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com, Claudius Heine
Hi Claudius,

I've a short question and suggestion before I can start procedure of
testing/applying this patch set to the tree.

Are you going to correct looping order when purging (as Henning pointed
out see his email below) in the next version of series or provide this
later as a separate patch?

In any case it would be better to rename IMAGE_CFG_PACKAGE to
IMAGE_CFG_PACKAGES and add short description (like purpose of this
variable) to definition of IMAGE_CFG_PACKAGE(S) in
isar-bootstrap-helper.bbclass. Let's improve code readability for other
people.

Kind regards,
Maxim.
--
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mos...@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov

Claudius Heine

unread,
May 25, 2018, 1:17:56 PM5/25/18
to Maxim Yu. Osipov, Henning Schild, [ext] claudius.heine.ext@siemens.com, isar-...@googlegroups.com
Hi Maxim,

On Fri, 2018-05-25 at 14:25 +0200, Maxim Yu. Osipov wrote:
> Hi Claudius,
>
> I've a short question and suggestion before I can start procedure of
> testing/applying this patch set to the tree.
>
> Are you going to correct looping order when purging (as Henning
> pointed
> out see his email below) in the next version of series or provide
> this
> later as a separate patch?

Yes I planned to do that next week.

>
> In any case it would be better to rename IMAGE_CFG_PACKAGE to
> IMAGE_CFG_PACKAGES and add short description (like purpose of this
> variable) to definition of IMAGE_CFG_PACKAGE(S) in
> isar-bootstrap-helper.bbclass. Let's improve code readability for
> other
> people.

Yes I can do that as well. Thanks for the suggestion!

Claudius

P.S.: Also, please avoid top posting in mailing lists and prefer
interleaved style.
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: c...@denx.de

PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
Keyserver: hkp://pool.sks-keyservers.net
signature.asc

claudius....@siemens.com

unread,
May 28, 2018, 6:56:49 AM5/28/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Some configuration tasks on the image require certain other packages,
but those packages might not be required on the final image.

One way to solve this is use a special package that is installed to the
image and then removed again. When installing it makes certain that all
required packages are installed to the image as well. Then the image
can be configured in the postinst hook. When this package is removed and
all unused dependencies are removed as well, no not required packages
used by this package should remain on the image.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../images/files/debian-configscript.sh | 1 -
.../images/files/raspbian-configscript.sh | 1 -
meta/classes/isar-bootstrap-helper.bbclass | 32 ++++++++++++++++---
3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 7ca0562..9b3ff30 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -40,4 +40,3 @@ fi

# Purge unused locale and installed packages' .deb files
localepurge
-apt-get clean
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index b240de9..448dea5 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -40,4 +40,3 @@ kernel=$KERNEL_IMAGE
EOF

localepurge
-apt-get clean
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 4284d02..b87c94e 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -5,15 +5,24 @@
#
# SPDX-License-Identifier: MIT

+IMAGE_CFG_PACKAGE ??= ""
+
+def reverse_bb_array(d, varname):
+ array = d.getVar(varname, True)
+ if array is None:
+ return None
+ array = reversed(array.split())
+ return " ".join(i for i in array)
+
setup_root_file_system() {
ROOTFSDIR="$1"
- CLEANHOSTLEAK="$2"
+ CLEAN="$2"
shift
shift
PACKAGES="$@"
APT_ARGS="install --yes --allow-unauthenticated \
-o Debug::pkgProblemResolver=yes"
- CLEANHOSTLEAK_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
+ CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"

sudo cp -Trpfx \
"${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
@@ -41,8 +50,23 @@ setup_root_file_system() {
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0"
sudo -E chroot "$ROOTFSDIR" \
- /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES
- [ "clean" = ${CLEANHOSTLEAK} ] && sudo rm -f ${CLEANHOSTLEAK_FILES}
+ /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \
+ ${IMAGE_CFG_PACKAGE}
+ [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES}
sudo -E chroot "$ROOTFSDIR" \
/usr/bin/apt-get ${APT_ARGS} $PACKAGES
+ for pkg in ${IMAGE_CFG_PACKAGE}; do
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get ${APT_ARGS} $pkg
+ done
+ for pkg in ${@reverse_bb_array(d, "IMAGE_CFG_PACKAGE") or ""}; do
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get purge --yes $pkg
+ done
+ if [ "clean" = ${CLEAN} ]; then
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get autoremove --purge --yes
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get clean
+ fi
}
--
2.17.0

claudius....@siemens.com

unread,
May 28, 2018, 6:56:49 AM5/28/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

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

Signed-off-by: Claudius Heine <c...@denx.de>
---

claudius....@siemens.com

unread,
May 28, 2018, 6:56:50 AM5/28/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

I implemented Hennings suggestion to purge the one-shot packages in the
reverse order of the installation.

Claudius

Changes from v3:
- Purge one-shot packages in reverse order

Changes from v2:
- Install one-shot package with a loop
- Rename '-y' apt parameter to '--yes'
- Move isar-cfg-localepurge files from /usr/local/etc to /usr/lib/

Changes from v1:
- rebased to current next
- removed locale.nopurge setup in isar-bootstrap

Claudius Heine (3):
isar-bootstrap|configscript: implement one shot config option
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge

.../images/files/debian-configscript.sh | 9 ------
.../images/files/raspbian-configscript.sh | 8 -----
.../recipes-core/images/isar-image-base.bb | 6 ++--
meta/classes/isar-bootstrap-helper.bbclass | 32 ++++++++++++++++---
.../isar-bootstrap/files/locale.nopurge | 10 ------
.../isar-bootstrap/isar-bootstrap.bb | 4 +--
.../isar-cfg-localepurge/files/locale.debconf | 12 +++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++
.../isar-cfg-localepurge.bb | 19 +++++++++++
10 files changed, 94 insertions(+), 37 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

--
2.17.0

claudius....@siemens.com

unread,
May 28, 2018, 6:56:50 AM5/28/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../recipes-core/images/files/debian-configscript.sh | 8 --------
.../recipes-core/images/files/raspbian-configscript.sh | 7 -------
meta-isar/recipes-core/images/isar-image-base.bb | 6 +++---
meta/recipes-core/isar-bootstrap/files/locale.nopurge | 10 ----------
meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 4 +---
5 files changed, 4 insertions(+), 31 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 9b3ff30..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -37,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 448dea5..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh

Maxim Yu. Osipov

unread,
May 29, 2018, 3:58:46 AM5/29/18
to claudius....@siemens.com, isar-...@googlegroups.com, Claudius Heine
Hi Claudius,
Are you going to rename this variable to IMAGE_CFG_PACKAGES
and add a comment it in a separate patch?

Kind regards,
Maxim.

Baurzhan Ismagulov

unread,
May 29, 2018, 4:00:15 AM5/29/18
to isar-...@googlegroups.com
Hello Claudius,

this is a useful feature that is also user-visible. Would you like to provide a
patch to doc/user_manual.md? I think we should provide a recommendation for the
user how to do customizations. I'd be especially interested in your vision
where to provide what, e.g.: One or many customization packages? If many, how
to split customizations between packages? Or just describe the mechanism and
leave the splitting decision to the user? In the latter case, would that mean
that in Isar, we'll by default provide only one package for all customizations?

With kind regards,
Baurzhan.

Claudius Heine

unread,
May 29, 2018, 4:20:46 AM5/29/18
to Maxim Yu. Osipov, isar-...@googlegroups.com, Claudius Heine
Hi Maxim,
Oh, sorry. Forgot about that. I will prepare v5.

Claudius

Claudius Heine

unread,
May 29, 2018, 5:30:02 AM5/29/18
to isar-...@googlegroups.com
Hi Baurzhan,

On 2018-05-29 10:00, Baurzhan Ismagulov wrote:
> Hello Claudius,
>
> this is a useful feature that is also user-visible. Would you like to provide a
> patch to doc/user_manual.md?

I will do that and send a v5. But I answer your questions here as well.
For me its easier to explain something in a dialog that just writing
docs to someone unknown. :)

> I think we should provide a recommendation for the
> user how to do customizations. I'd be especially interested in your vision
> where to provide what, e.g.: One or many customization packages?

Currently I cannot think of anything else that could be done with those
one-shot packages apart from localepurge. Is generally only useful if
someone needs a tool to customize the root file system that shouldn't be
part of the image later. Normal customization packages that just change
or add some configuration files should not be one-shot packages, they
don't require special tools and therefor its not use purging them to
remove their dependencies.

I don't even know if it makes really sense to allow multiple packages as
one-shot packages, but I did it because it might be useful in some
strange corner cases for someone and wasn't a big effort to do.

> If many, how
> to split customizations between packages?

All the customization, apart from locale configuration should be in
normal packages, however the user choose to do this. locale
configuration should be done with overwriting isar-cfg-localepurge
package or its files.

Maybe the name of that package is choosen poorly. I don't know.

> Or just describe the mechanism and leave the splitting decision to the user?

Yes. That would be useful. The user might want to mix and match
different configuration fragments contained in multiple configuration
packages.

> In the latter case, would that mean
> that in Isar, we'll by default provide only one package for all customizations?

I would think so. Maybe move the customization to a isar-cfg-example
package?

Claudius

Claudius Heine

unread,
May 29, 2018, 6:56:11 AM5/29/18
to Maxim Yu. Osipov, isar-...@googlegroups.com, Claudius Heine
On 2018-05-29 10:20, [ext] Claudius Heine wrote:
>>>   # SPDX-License-Identifier: MIT
>>> +IMAGE_CFG_PACKAGE ??= ""
>>
>> Are you going to rename this variable to IMAGE_CFG_PACKAGES
>> and add a comment it in a separate patch?
>
> Oh, sorry. Forgot about that. I will prepare v5.

I have thought on this and I think that 'IMAGE_CFG_PACKAGES' is a bad
variable name, since it implies to be the variable to put all
configuration packages into.
How about 'IMAGE_ONESHOT_PACKAGES', 'IMAGE_VOLATILE_PACKAGES' or
'IMAGE_TEMPORARY_PACKAGES'?

Claudius

Maxim Yu. Osipov

unread,
May 29, 2018, 7:18:29 AM5/29/18
to Claudius Heine, isar-...@googlegroups.com, Claudius Heine
On 05/29/2018 12:56 PM, Claudius Heine wrote:
> On 2018-05-29 10:20, [ext] Claudius Heine wrote:
>>>>   # SPDX-License-Identifier: MIT
>>>> +IMAGE_CFG_PACKAGE ??= ""
>>>
>>> Are you going to rename this variable to IMAGE_CFG_PACKAGES
>>> and add a comment it in a separate patch?
>>
>> Oh, sorry. Forgot about that. I will prepare v5.
>
> I have thought on this and I think that 'IMAGE_CFG_PACKAGES' is a bad
> variable name, since it implies to be the variable to put all
> configuration packages into.
> How about 'IMAGE_ONESHOT_PACKAGES', 'IMAGE_VOLATILE_PACKAGES' or
> 'IMAGE_TEMPORARY_PACKAGES'?

The purpose of these packages is to do image post configuration (or
tweaking)...
May be IMAGE_POSTCONFIG_PACKAGES or IMAGE_TWEAK_PACKAGES?

Maxim.

Claudius Heine

unread,
May 29, 2018, 7:38:36 AM5/29/18
to Maxim Yu. Osipov, isar-...@googlegroups.com, Claudius Heine
Hi Maxim,

On 2018-05-29 13:18, Maxim Yu. Osipov wrote:
> On 05/29/2018 12:56 PM, Claudius Heine wrote:
>> On 2018-05-29 10:20, [ext] Claudius Heine wrote:
>>>>>   # SPDX-License-Identifier: MIT
>>>>> +IMAGE_CFG_PACKAGE ??= ""
>>>>
>>>> Are you going to rename this variable to IMAGE_CFG_PACKAGES
>>>> and add a comment it in a separate patch?
>>>
>>> Oh, sorry. Forgot about that. I will prepare v5.
>>
>> I have thought on this and I think that 'IMAGE_CFG_PACKAGES' is a bad
>> variable name, since it implies to be the variable to put all
>> configuration packages into.
>> How about 'IMAGE_ONESHOT_PACKAGES', 'IMAGE_VOLATILE_PACKAGES' or
>> 'IMAGE_TEMPORARY_PACKAGES'?
>
> The purpose of these packages is to do image post configuration (or
> tweaking)...
> May be IMAGE_POSTCONFIG_PACKAGES or IMAGE_TWEAK_PACKAGES?

Thanks for your suggestions!
I started with `IMAGE_TRANSIENT_PACKAGES` and quite like that.

My problem with names like `IMAGE_CFG_PACKAGES` or your suggestions is
that it explains what kind of packages might make sense to be put there
instead of how those packages are handled.

This variable is not the right one for all configuration packages, since
a configuration package might deploy a configuration file not in a
package script, but part of the package files. Then this file would be
removed from the image it that package was added to this variable.

So instead I try to explain what will happen to those packages. "one
shot" doesn't explain it good enough, while 'volatile' and 'temporary'
might be misunderstood. 'Transient' however explains quite well IMO.

regards,

claudius....@siemens.com

unread,
May 29, 2018, 8:14:30 AM5/29/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package as a
transient package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../recipes-core/images/files/debian-configscript.sh | 8 --------
.../recipes-core/images/files/raspbian-configscript.sh | 7 -------
meta-isar/recipes-core/images/isar-image-base.bb | 6 +++---
meta/recipes-core/isar-bootstrap/files/locale.nopurge | 10 ----------
meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 4 +---
5 files changed, 4 insertions(+), 31 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 9b3ff30..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -37,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 448dea5..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -38,5 +33,3 @@ KERNEL_IMAGE=`ls /boot | grep vmlinuz`
cat > /boot/config.txt << EOF
kernel=$KERNEL_IMAGE
EOF
-
-localepurge
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index 1239f72..f91dfb0 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -16,11 +16,11 @@ PV = "1.0"
inherit image
inherit isar-bootstrap-helper

-DEPENDS += "${IMAGE_INSTALL}"
+DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}"

IMAGE_PREINSTALL += "apt \
- dbus \
- localepurge"
+ dbus"
+IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"

claudius....@siemens.com

unread,
May 29, 2018, 8:14:31 AM5/29/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

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

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../isar-cfg-localepurge/files/locale.debconf | 12 ++++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++++
.../isar-cfg-localepurge.bb | 19 ++++++++++++
4 files changed, 62 insertions(+)
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

claudius....@siemens.com

unread,
May 29, 2018, 8:14:31 AM5/29/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

here is the new version of this patchset. I renamed the variable and
added some documentation.

Hopefully this is now less confusing.

Thanks,
Claudius

Changes from v4:
- added documentation
- renamed `IMAGE_CFG_PACKAGE` to `IMAGE_TRANSIENT_PACKAGES`

Changes from v3:
- Purge one-shot packages in reverse order

Changes from v2:
- Install one-shot package with a loop
- Rename '-y' apt parameter to '--yes'
- Move isar-cfg-localepurge files from /usr/local/etc to /usr/lib/

Changes from v1:
- rebased to current next
- removed locale.nopurge setup in isar-bootstrap

Claudius Heine (4):
isar-bootstrap|configscript: implement one transient packages
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge
doc: added description of `IMAGE_TRANSIENT_PACKAGES`

doc/user_manual.md | 16 ++++++++++
.../images/files/debian-configscript.sh | 9 ------
.../images/files/raspbian-configscript.sh | 8 -----
.../recipes-core/images/isar-image-base.bb | 6 ++--
meta/classes/isar-bootstrap-helper.bbclass | 32 ++++++++++++++++---
.../isar-bootstrap/files/locale.nopurge | 10 ------
.../isar-bootstrap/isar-bootstrap.bb | 4 +--
.../isar-cfg-localepurge/files/locale.debconf | 12 +++++++
.../isar-cfg-localepurge/files/locale.gen | 1 +
.../isar-cfg-localepurge/files/postinst | 30 +++++++++++++++++
.../isar-cfg-localepurge.bb | 19 +++++++++++
11 files changed, 110 insertions(+), 37 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.debconf
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/locale.gen
create mode 100644 meta/recipes-support/isar-cfg-localepurge/files/postinst
create mode 100644 meta/recipes-support/isar-cfg-localepurge/isar-cfg-localepurge.bb

--
2.17.0

claudius....@siemens.com

unread,
May 30, 2018, 7:50:09 AM5/30/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Hi,

I decided to merge the isar-cfg-localpurge improvement patch series with
this one, since they touch the same code basis.

With this change the isar-cfg-localepurge package code is pretty much
done from stretch. The configuration now depends on bitbake internal
variables, so now its possible to set the desired locale without need to
overwrite any recipes, just by setting the `LOCALE_GEN` and
`LOCALE_DEFAULT` variables.

I also removed the debconf configuration of localepurge. This part is
pretty broken in that package. Now '/etc/locale.nopurge' is just
generated and placed by bitbake and the postinst script.

Claudius

Changes from v5:
- reworked isar-cfg-localepurge package

Changes from v4:
- added documentation
- renamed `IMAGE_CFG_PACKAGE` to `IMAGE_TRANSIENT_PACKAGES`

Changes from v3:
- Purge one-shot packages in reverse order

Changes from v2:
- Install one-shot package with a loop
- Rename '-y' apt parameter to '--yes'
- Move isar-cfg-localepurge files from /usr/local/etc to /usr/lib/

Changes from v1:
- rebased to current next
- removed locale.nopurge setup in isar-bootstrap

Claudius Heine (4):
isar-bootstrap|configscript: implement one transient packages
meta/isar-cfg-localepurge: added locale purge recipe
meta-isar/isar-image-base: switch use isar-cfg-localepurge
doc: added description of `IMAGE_TRANSIENT_PACKAGES` and locale vars

doc/user_manual.md | 18 +++++
.../images/files/debian-configscript.sh | 9 ---
.../images/files/raspbian-configscript.sh | 8 ---
.../recipes-core/images/isar-image-base.bb | 6 +-
meta/classes/isar-bootstrap-helper.bbclass | 32 +++++++--
.../isar-bootstrap/files/locale.nopurge | 10 ---
.../isar-bootstrap/isar-bootstrap.bb | 4 +-
.../isar-cfg-localepurge/files/postinst | 13 ++++
.../isar-cfg-localepurge.bb | 65 +++++++++++++++++++
9 files changed, 128 insertions(+), 37 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

claudius....@siemens.com

unread,
May 30, 2018, 7:50:09 AM5/30/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

Some configuration tasks on the image require certain other packages,
but those packages might not be required on the final image.

One way to solve this is use a special package that is installed to the
image and then removed again. When installing it makes certain that all
required packages are installed to the image as well. Then the image
can be configured in the postinst hook. When this package is removed and
all unused dependencies are removed as well, no not required packages
used by this package should remain on the image.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../images/files/debian-configscript.sh | 1 -
.../images/files/raspbian-configscript.sh | 1 -
meta/classes/isar-bootstrap-helper.bbclass | 32 ++++++++++++++++---
3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 7ca0562..9b3ff30 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -40,4 +40,3 @@ fi

# Purge unused locale and installed packages' .deb files
localepurge
-apt-get clean
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index b240de9..448dea5 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -40,4 +40,3 @@ kernel=$KERNEL_IMAGE
EOF

localepurge
-apt-get clean
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 4284d02..d6b2a26 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -5,15 +5,24 @@
#
# SPDX-License-Identifier: MIT

+IMAGE_TRANSIENT_PACKAGES ??= ""
+ ${IMAGE_TRANSIENT_PACKAGES}
+ [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES}
sudo -E chroot "$ROOTFSDIR" \
/usr/bin/apt-get ${APT_ARGS} $PACKAGES
+ for pkg in ${IMAGE_TRANSIENT_PACKAGES}; do
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get ${APT_ARGS} $pkg
+ done
+ for pkg in ${@reverse_bb_array(d, "IMAGE_TRANSIENT_PACKAGES") or ""}; do
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get purge --yes $pkg
+ done
+ if [ "clean" = ${CLEAN} ]; then
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get autoremove --purge --yes
+ sudo -E chroot "$ROOTFSDIR" \
+ /usr/bin/apt-get clean
+ fi
}
--
2.17.0

claudius....@siemens.com

unread,
May 30, 2018, 7:50:10 AM5/30/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@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 <c...@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-...@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

claudius....@siemens.com

unread,
May 30, 2018, 7:50:10 AM5/30/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

This patch removes the locale setting from the *-configscripts and
instead uses the isar-cfg-localepurge configuration package as a
transient package.

The advantange is that the package 'localepurge' is no longer installed
on every image and locale settings is done in a central place.

Signed-off-by: Claudius Heine <c...@denx.de>
---
.../recipes-core/images/files/debian-configscript.sh | 8 --------
.../recipes-core/images/files/raspbian-configscript.sh | 7 -------
meta-isar/recipes-core/images/isar-image-base.bb | 6 +++---
meta/recipes-core/isar-bootstrap/files/locale.nopurge | 10 ----------
meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 4 +---
5 files changed, 4 insertions(+), 31 deletions(-)
delete mode 100644 meta/recipes-core/isar-bootstrap/files/locale.nopurge

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 9b3ff30..136918c 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -10,11 +10,6 @@ readonly BAUDRATE_TTY="$2"
readonly ROOTFS_DEV="$3"
readonly ROOTFS_TYPE="$4"

-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
cat > /etc/fstab << EOF
# Begin /etc/fstab
/dev/$ROOTFS_DEV / $ROOTFS_TYPE defaults 1 1
@@ -37,6 +32,3 @@ if [ -f /etc/inittab ]; then
echo "T0:23:respawn:/sbin/getty -L $MACHINE_SERIAL $BAUDRATE_TTY vt100" \
>> /etc/inittab
fi
-
-# Purge unused locale and installed packages' .deb files
-localepurge
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 448dea5..04ea571 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh

claudius....@siemens.com

unread,
May 30, 2018, 7:50:10 AM5/30/18
to isar-...@googlegroups.com, Claudius Heine
From: Claudius Heine <c...@denx.de>

---
doc/user_manual.md | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index a2f4b92..9921f3a 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -318,6 +318,8 @@ Some other variables include:

- `IMAGE_INSTALL` - The list of custom packages to build and install to target image, please refer to relative chapter for more information.
- `BB_NUMBER_THREADS` - The number of `bitbake` jobs that can be run in parallel. Please set this option according your host CPU cores number.
+ - `LOCALE_GEN` - A `\n` seperated list of `/etc/locale.gen` entries desired on the target.
+ - `LOCALE_DEFAULT` - The default locale used for the `LANG` and `LANGUAGE` variable in `/etc/locale`.

---

@@ -481,6 +483,22 @@ Isar contains two image type classes that can be used as reference:

---

+## Customize and configure image
+
+Customization and configuration of an image should be done via packages, see below.
+
+Adding those configuration packages to the image can be done in two ways:
+
+ 1. Simply adding the package to `IMAGE_INSTALL`, like any other isar created package, or
+ 2. Adding the package to `IMAGE_TRANSIENT_PACKAGES`.
+
+In most cases adding the configuration package to `IMAGE_INSTALL` is the right option.
+
+In cases were the configuration script of the package has some external dependencies, that should not be part of the final image, then `IMAGE_TRANSIENT_PACKAGES` is the right option.
+Packages in the `IMAGE_TRANSIENT_PACKAGES` variable are installed to the image and purged in the next step. If such a configuration package deploys file as part of their content, then those files will be removed as well.
+
+---
+
## Add a Custom Application

Before creating a new recipe it's highly recommended to take a look into the BitBake user manual mentioned in Terms and Definitions section.
--
2.17.0

Maxim Yu. Osipov

unread,
Jun 1, 2018, 3:44:59 AM6/1/18
to claudius....@siemens.com, isar-...@googlegroups.com, Claudius Heine
Applied to next, thanks.

Claudius Heine

unread,
Jun 1, 2018, 4:13:31 AM6/1/18
to Maxim Yu. Osipov, claudius....@siemens.com, isar-...@googlegroups.com
Hi Maxim,
Did you apply the v5 or the v6?

Claudius

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: c...@denx.de

signature.asc

Maxim Yu. Osipov

unread,
Jun 1, 2018, 4:44:02 AM6/1/18
to Claudius Heine, claudius....@siemens.com, isar-...@googlegroups.com
Hi Claudius,
Of course the latest series - V6.
My apologies for confusion.

Kind regards,
Reply all
Reply to author
Forward
0 new messages