Check-in [0c1a1fe45e]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:0c1a1fe45e404c7d303e4b49fc99f01cb787cd13
Date: 2012-03-31 23:31:15
User: BarryK
Comment:quicksetup, lang2initrd: fix correct change of language in initrd

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/sbin/lang2initrd

@@ -1,9 +1,10 @@
 #!/bin/sh
 #(c) Copyright Barry Kauler 2012. License: GPL3 (/usr/share/doc/legal)
 #this script called from /usr/sbin/quicksetup, /usr/bin/wmreboot, wmpoweroff.
 #passed in params: $NEWLANG
+#120401 change logic to modify init (see also quicksetup).
 
 export TEXTDOMAIN=lang2initrd
 export OUTPUT_CHARSET=UTF-8
 . gettext.sh
 
@@ -16,21 +17,33 @@
 #various reasons for not doing it...
 case $PDEV1 in
  sr*) exit 1 ;;
 esac
 [ "$DEV1FS" = "iso9660" ] && exit 1
-[ "$LANG1" = "en" ] && exit 1
+if [ "$PLANG" ];then #120401
+ PLANG1="${PLANG%_*}" #defined in PUPSTATE by initrd. ex: de
+ PLANG12="${PLANG%.*}" #ex: de_DE
+ [ "$PLANG" = "$NEWLANG" ] && exit 1 #initrd already in this language.
+else
+ [ "$LANG1" = "en" ] && exit 1
+fi
 [ ! -d /initrd ] && exit 1 #dir exists, then puppy booted up with an initrd.
 INITRANS=''
 [ -f /usr/share/sss/initrd_strings/initrd_strings.${LANG12} ] && INITRANS="/usr/share/sss/initrd_strings/initrd_strings.${LANG12}"
 [ ! "$INITRANS" ] && [ -f /usr/share/sss/initrd_strings/initrd_strings.${LANG1} ] && INITRANS="/usr/share/sss/initrd_strings/initrd_strings.${LANG1}"
-[ ! "$INITRANS" ] && exit 1
+[ "$INITRANS" ] && TRANSLANG="`echo -n "$INITRANS" | rev | cut -f 1 -d '.' | rev`" #120401
+[ "$LANG1" != "en" ] && [ ! "$INITRANS" ] && exit 1 #120401
+[ "$LANG1" = "en" ] && TRANSLANG='en' #120401
 
 if [ "$DISPLAY" ];then
- pupdialog --background '#FF80FF' --colors --backtitle "$(gettext 'Early boot messages')" --yesno "$(gettext 'Do you want to translate the early boot messages? These are in what is known as the initrd or initramfs, when the Linux operating system (kernel) is first loading. It is usually good to answer yes here.')" 0 0
+ pupdialog --background '#FF80FF' --colors --backtitle "$(gettext 'Early boot messages')" --yesno "$(gettext 'Do you want to translate the early boot messages? These are in what is known as the initrd or initramfs, when the Linux operating system (kernel) is first loading. It is usually good to answer yes here.')
+
+$(gettext 'They will be translated to:') ${NEWLANG}" 0 0
 else
- dialog --yesno "$(gettext 'Do you want to translate the early boot messages? These are in what is known as the initrd or initramfs, when the Linux operating system (kernel) is first loading. It is usually good to answer yes here.')" 0 0 >/dev/console
+ dialog --yesno "$(gettext 'Do you want to translate the early boot messages? These are in what is known as the initrd or initramfs, when the Linux operating system (kernel) is first loading. It is usually good to answer yes here.')
+
+$(gettext 'They will be translated to:') ${NEWLANG}" 0 0 >/dev/console
 fi
 if [ $? -ne 0 ];then
  echo "DECLINED ${DISTRO_IDSTRING}" >> /var/local/lang2initrd.log #variable in /etc/DISTRO_SPECS
  exit 2
 fi
@@ -61,24 +74,29 @@
   cd /root
   gunzip initrd.gz
   if [ $? -eq 0 ];then
    cd initrd-tree
    cat ../initrd | cpio -i -d -m
-   echo -n "$NEWLANG" > PUPPYLANG #file /PUPPYLANG in initrd sets default LANG.
-   [ -f /etc/keymap ] && cat /etc/keymap > PUPPYKEYMAP #120216 also useful in initrd.
-   #might need to update the translation files in initrd also (was done by 3builddistro)...
-   INITRDTRANSFILES="`find /usr/share/sss/initrd_strings -mindepth 1 -maxdepth 1 -type f -name 'initrd_strings.*'`"
-   if [ "$INITRDTRANSFILES" ];then
-    for ATRANS in $INITRDTRANSFILES
-    do
-     ENDBIT="`echo -n "$ATRANS" | rev | cut -f 1 -d '.' | rev`" #ex: de (from initrd_strings.de)
-     mkdir -p locale/${ENDBIT}
-     #only supporting translating the init script for now...
-     sPTN="/^\[init\]/,/^$/p" #this is a multi-line block find expression.
-     CODEBLOCK="`sed -n "$sPTN" ${ATRANS} | sed -e '/^#/d' -e '/%%/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
-     echo "$CODEBLOCK" > locale/${ENDBIT}/init #translation file, read by /init script in initrd.
-    done
+   if [ "$TRANSLANG" = "en" ];then #120401
+    rm -f PUPPYLANG
+    rm -f PUPPYKEYMAP
+   else
+    echo -n "$NEWLANG" > PUPPYLANG #file /PUPPYLANG in initrd sets default LANG.
+    [ -f /etc/keymap ] && cat /etc/keymap > PUPPYKEYMAP #120216 also useful in initrd.
+    #might need to update the translation files in initrd also (was done by 3builddistro)...
+    INITRDTRANSFILES="`find /usr/share/sss/initrd_strings -mindepth 1 -maxdepth 1 -type f -name 'initrd_strings.*'`"
+    if [ "$INITRDTRANSFILES" ];then
+     for ATRANS in $INITRDTRANSFILES
+     do
+      ENDBIT="`echo -n "$ATRANS" | rev | cut -f 1 -d '.' | rev`" #ex: de (from initrd_strings.de)
+      mkdir -p locale/${ENDBIT}
+      #only supporting translating the init script for now...
+      sPTN="/^\[init\]/,/^$/p" #this is a multi-line block find expression.
+      CODEBLOCK="`sed -n "$sPTN" ${ATRANS} | sed -e '/^#/d' -e '/%%/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
+      echo "$CODEBLOCK" > locale/${ENDBIT}/init #translation file, read by /init script in initrd.
+     done
+    fi
    fi
    sync
    #now put the initrd.gz back together again...
    rm -f ../initrd
    find . | cpio -o -H newc | gzip -9 > ../initrd.gz

Changes to woof-code/rootfs-skeleton/usr/sbin/quicksetup

@@ -36,10 +36,11 @@
 #120313 hardcode translations for popup if user changes locale.
 #120313 restrict network frame to only be in main quicksetup window.
 #120315 dutch (nl) hardcode translation for locale-change popup. added pt, es, it.
 #120328 have rewritten rc.country, try to make chooselocale compatible. 120330 bugfix.
 #120331 added Polish (pl) hardcoded translation.
+#120401 change logic to call lang2initrd.
 
 [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}
 
 export TEXTDOMAIN=quicksetup
 export OUTPUT_CHARSET=UTF-8
@@ -1038,14 +1039,24 @@
    fi
 
    #120215 offer to translate initrd... 120216 moved to separate script (so universal installer can also do it)...
    GIVEITAGO='yes'
    NEWLANG1=${NEWLANG%_*} #ex: en
+   #120401 change logic to call lang2initrd...
+   PLANG1=""
+   [ "PLANG" ] && PLANG1="${PLANG%_*}" #defined in PUPSTATE by initrd.
    [ "$NEWLANG1" = "en" ] && GIVEITAGO='no'
    if [ -f /var/local/lang2initrd.log ];then #read log from /usr/sbin/lang2initrd
     [ "`grep "^DECLINED ${DISTRO_IDSTRING}" /var/local/lang2initrd.log`" != "" ] && GIVEITAGO='no'
     [ "`grep "^SUCCESS ${DISTRO_IDSTRING}" /var/local/lang2initrd.log`" != "" ] && GIVEITAGO='no'
+   fi
+   if [ "$PLANG1" ];then #120401
+    [ "$PLANG" != "$NEWLANG" ] && GIVEITAGO='yes' #catch case of user only changing UTF-8 checkbox.
+    if [ "$PLANG1" != "$NEWLANG1" ];then
+     GIVEITAGO='yes'
+     [ "$NEWLANG1" != "en" ] && echo -n "" > /var/local/lang2initrd.log #so wmpoweroff/wmreboot can run lang2initrd after langpack installed.
+    fi
    fi
    [ "$GIVEITAGO" = "yes" ] && /usr/sbin/lang2initrd $NEWLANG #note, script has more tests, then asks if want translate initrd.
 
    #120209 scripts fixdesk and fixmenus translate files to new language (as specified in /usr/share/sss/menu_strings and desk_strings).
    #so need to call them here...