Skip to contentSkip to conversation

dracut: setup English locales for Dracut build script

PATCH In review Amadeusz Żołnowski 4 participants 7 messages Jun 18, 2010 – Jun 22, 2010 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dracut: setup English locales for Dracut build script

Dracut rely upon programs' output like ldd's "not a dynamic executable". Assume user sets up Polish locales and then ldd prints
"nie jest dynamicznym programem wykonywalnym". The patch prevents this.

---
 dracut |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
dracut +15 -0
index 3be4989..1437625 100755
@@ -71,6 +71,17 @@ Creates initial ramdisk images for preloading modules
 "
 }
 
+# Change locales and language leaving existing suffix (.utf8 or similar).
+# $1 = language (e.g. en_US)
+change_locales() {
+    local lang=(${LANG/./ })
+    lang[0]=$1                                                                        
+    lang=${lang[@]}
+    LANG=${lang/ /.}
+    LC_ALL=${LANG}
+    export LANG LC_ALL
+}
+
 while (($# > 0)); do
     case $1 in
 	-f|--force) force=yes;;
@@ -107,6 +118,10 @@ done
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH
+# We rely upon programs' output like ldd's "not found", so we have to
+# set up English locales.
+change_locales en_US
+
 
 [[ $debug ]] && { 
     export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
Signature · 1 line
1.7.1
#2 lore raw
In reply to a message not in the archive

2010/6/18 Amadeusz Żołnowski <[email protected]>:

Quoted 12 lines

Dracut rely upon programs' output like ldd's "not a dynamic executable". Assume user sets up Polish locales and then ldd prints
"nie jest dynamicznym programem wykonywalnym".  The patch prevents this.
---
 dracut |   15 +++++++++++++++

 1 files changed, 15 insertions(+), 0 deletions(-)
dracut +0 -0
index 3be4989..1437625 100755
@@ -71,6 +71,17 @@ Creates initial ramdisk images for preloading modules
Quoted 2 lines

 "
 }

Hmmm... The usual way to do this is to run the program in the C locale by setting
LC_ALL=C

Quoted 28 lines
dracut +11 -0
+# Change locales and language leaving existing suffix (.utf8 or similar).
+# $1 = language (e.g. en_US)
+change_locales() {
+    local lang=(${LANG/./ })
+    lang[0]=$1
+    lang=${lang[@]}
+    LANG=${lang/ /.}
+    LC_ALL=${LANG}
+    export LANG LC_ALL
+}
+

 while (($# > 0)); do
    case $1 in
       -f|--force) force=yes;;

dracut +0 -0
@@ -107,6 +118,10 @@ done
 

 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH

dracut +4 -0
+# We rely upon programs' output like ldd's "not found", so we have to
+# set up English locales.
+change_locales en_US
+

 [[ $debug ]] && {
    export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; --
1.7.1

#5 lore raw
In reply to a message not in the archive
Quoted 12 lines · On Friday 18 Jun 2010 12:38:41 Amadeusz Żołnowski wrote:

Dracut rely upon programs' output like ldd's "not a dynamic executable". Assume user sets up Polish locales and then ldd prints
"nie jest dynamicznym programem wykonywalnym". The patch prevents this.

---
 dracut |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
dracut +0 -0
index 3be4989..1437625 100755

dracut done · line 127

Quoted 10 lines
dracut +4 -0
@@ -107,6 +118,10 @@ done
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH
+# We rely upon programs' output like ldd's "not found", so we have to
+# set up English locales.
+change_locales en_US
+
 
 [[ $debug ]] && {
     export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';

I don't have any en_US locales installed on my system. Not sure why a Pole would either. You'd probably be better off with the "C" locale, IMHO.

Adam

#4 lore raw
In reply to a message not in the archive

Victor Lowther <[email protected]>:

Quoted 3 lines

Hmmm... The usual way to do this is to run the program in the C locale by setting
LC_ALL=C

You mean we should prefix every call which output we rely or just setup:
export LC_ALL=C in place I pointed? Hm… to think about it the first option would be more elgant.

Signature · 1 line
PGP key: 1024D/C284750D
#8 lore raw
In reply to a message not in the archive
Quoted 30 lines · Amadeusz Żołnowski

Dracut rely upon programs' output like ldd's "not a dynamic executable". Assume user sets up Polish locales and then ldd prints
"nie jest dynamicznym programem wykonywalnym". The patch prevents this.

---
  dracut |   15 +++++++++++++++
  1 files changed, 15 insertions(+), 0 deletions(-)
dracut +11 -0
index 3be4989..1437625 100755
@@ -71,6 +71,17 @@ Creates initial ramdisk images for preloading modules
  "
  }
 
+# Change locales and language leaving existing suffix (.utf8 or similar).
+# $1 = language (e.g. en_US)
+change_locales() {
+    local lang=(${LANG/./ })
+    lang[0]=$1
+    lang=${lang[@]}
+    LANG=${lang/ /.}
+    LC_ALL=${LANG}
+    export LANG LC_ALL
+}
+
  while (($#>  0)); do
      case $1 in
  	-f|--force) force=yes;;

dracut done · line 127

Quoted 10 lines
dracut +4 -0
@@ -107,6 +118,10 @@ done
 
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  export PATH
+# We rely upon programs' output like ldd's "not found", so we have to
+# set up English locales.
+change_locales en_US
+
 
  [[ $debug ]]&&  {
      export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';

Hmm, we probably should prefix every call to an app, where we parse the output with LANG=C like this:

LANG=C ldd $file | grep -q "not found"

#7 lore raw
In reply to a message not in the archive

Thank you all for comments. Right, C is better. :-)

I reviewed the code and it looks that only ldd is “affected” by locales, although there some other commands the output is parsed, but it's not localized. Should we prefix them anyway “just for sure” or leave as is?

Cheers,
Amadeusz Żołnowski

Signature · 1 line
PGP key: 1024D/C284750D