[1/1] image-locales-extension: Do localepurge configuration after installation

Message ID 20220410170229.6369-2-venkata.pyla@toshiba-tsip.com
State Accepted, archived
Headers show
Series Fix non-reproducible issue due to localepurge | expand

Commit Message

venkata.pyla@toshiba-tsip.com April 10, 2022, 9:02 a.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

The current seqence of copying the localepurge configuration first and
then  installing localepurge package is causing the debconf cache entry,
that is because the package postinstall script assume the configuration
is already present and checks for configuration change and updates the
debconf cache entry.

With the above sequence of steps it is causing unnecessary debconf cache
entry and which is causing non-reproducible system image creation.

To avoid this, the sequence is altered to install the package first and
then configure necessary locales to remove.

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 meta/classes/image-locales-extension.bbclass | 33 ++++++++++----------
 1 file changed, 17 insertions(+), 16 deletions(-)

Patch

diff --git a/meta/classes/image-locales-extension.bbclass b/meta/classes/image-locales-extension.bbclass
index 25af540..2db6d4a 100644
--- a/meta/classes/image-locales-extension.bbclass
+++ b/meta/classes/image-locales-extension.bbclass
@@ -60,6 +60,16 @@  __EOF__
     # Install configuration into image:
     sudo -E -s <<'EOSUDO'
         set -e
+        localepurge_state='i'
+        if chroot '${ROOTFSDIR}' 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)'
+            chroot '${ROOTFSDIR}' apt-get ${ROOTFS_APT_ARGS} localepurge
+        fi
+
         cat '${WORKDIR}/locale.gen' >> '${ROOTFSDIR}/etc/locale.gen'
         cat '${WORKDIR}/locale.default' > '${ROOTFSDIR}/etc/default/locale'
         cat '${WORKDIR}/locale.nopurge' > '${ROOTFSDIR}/etc/locale.nopurge'
@@ -67,15 +77,6 @@  __EOF__
 
         # 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
@@ -86,13 +87,13 @@  __EOF__
 
             echo 'running localepurge'
             localepurge
-
-            if [ "$localepurge_state" = 'p' ]
-            then
-                echo removing localepurge...
-                apt-get purge --yes localepurge 
-                apt-get autoremove --purge --yes
-            fi
 EOSH
+
+        if [ "$localepurge_state" = 'p' ]
+        then
+            echo removing localepurge...
+            chroot '${ROOTFSDIR}' apt-get purge --yes localepurge
+            chroot '${ROOTFSDIR}' apt-get autoremove --purge --yes
+        fi
 EOSUDO
 }