[Lunar-commits] r26113 - moonbase/branches/crater/libs/glibc-new

Moritz Heiber moe at lunar-linux.org
Mon Oct 8 01:18:49 CEST 2007


Author: moe
Date: 2007-10-08 01:18:49 +0200 (Mon, 08 Oct 2007)
New Revision: 26113

Modified:
   moonbase/branches/crater/libs/glibc-new/CONFIGURE
Log:
This is the new chooser .. (C) Jannis



Modified: moonbase/branches/crater/libs/glibc-new/CONFIGURE
===================================================================
--- moonbase/branches/crater/libs/glibc-new/CONFIGURE	2007-10-07 22:38:08 UTC (rev 26112)
+++ moonbase/branches/crater/libs/glibc-new/CONFIGURE	2007-10-07 23:18:49 UTC (rev 26113)
@@ -1,31 +1,62 @@
+LOCALE_FILE="$SOURCE_DIRECTORY/supported-locales"
 
-select_locales()  {
+make_locales_checklist() {
+  # Copy and modify the supported locales file so we can treat it like 
+  # a normal bash script
+  cp $SOURCE_DIRECTORY/localedata/SUPPORTED $LOCALE_FILE &&
+  sed -i -e 's/SUPPORTED-LOCALES=/SUPPORTED_LOCALES="/g' $LOCALE_FILE &&
+  echo '"' >> $LOCALE_FILE &&
+  
+  # Execute the modified supported locales file to get a list of 
+  # supported variables in the $SUPPORTED_LOCALES variable
+  . locales &&
+  
+  # For each locale, extract name, title and encoding information
+  for line in $SUPPORTED_LOCALES; do
+    locale=$(echo $line | sed -e 's:\/.*$::g')
+
+    # This is a bit tricky and slow but it does the job
+    if [[ -e $SOURCE_DIRECTORY/localedata/locales/${locale/.*/} ]]; then
+      title=$(cat $SOURCE_DIRECTORY/localedata/locales/${locale/.*/} | grep ^title)
+      title=$(echo $title | awk -F"\"" '{ $1 = ""; print }')
+      title=$(echo $title | sed -e 's/^[ \t]*//;s/[ \t]*$//')
+    else
+      title=""
+    fi
+  
+    # Echo locale/encoding, title and status to be passed to the 
+    # dialog checklist
+    echo "\"$line\" \"$title\" \"off\" "
+  done
+}
+
+select_locales() {
   BACKTITLE="Glibc Configuration"
       TITLE="Locale Selection"
        HELP="Translated messages are automatically installed, but the locale database that controls other behavior is not.  Please select desired locale or locales.  If none are selected then all will be installed."
-
   make_locales_checklist | xargs \
-  dialog  --backtitle  "$BACKTITLE"  \
-          --title      "$TITLE"      \
-          --stdout                   \
-          --separate-output          \
-          --checklist  "$HELP"       \
-          0 0 0
+  dialog --backtitle "$BACKTITLE" \
+         --title     "$TITLE"     \
+         --stdout                 \
+         --separate-output        \
+         --checklist "$HELP"      \
+         0 0 0
 }
 
-if  !  grep  -q  CONFIGURED  $MODULE_CONFIG;  then
+if ! grep -q CONFIGURED $MODULE_CONFIG; then
+  if grep -q "GLIBC_LOCALES=" $MODULE_CONFIG; then
+    message "Selecting locales is optional"
+  fi
 
-   if    grep  -q  "GLIBC_LOCALES="  $MODULE_CONFIG
-      then  message  "Selecting locales is optional"
-   fi
+  if query "Would you like to select locales? (if not selected, all locales will be installed)" y; then
 
-   if  query  "Would you like to select locales? (if not selected, all locales will be installed)" n ; then
-     GLIBC_LOCALES=`select_locales`
-     TEMP=`grep  -v  "GLIBC_LOCALES="             $MODULE_CONFIG`
-     echo  "$TEMP"                             >  $MODULE_CONFIG
-     echo  "GLIBC_LOCALES=\"$GLIBC_LOCALES\""  >> $MODULE_CONFIG
-   fi
+    GLIBC_LOCALES=`select_locales`
+    TEMP=`grep -v "GLIBC_LOCALES=" $MODULE_CONFIG`
 
-   echo "OPTS=\"\$OPTS $OPTS\""                >> $MODULE_CONFIG
-   echo "CONFIGURED=y"                         >> $MODULE_CONFIG
+    echo "$TEMP"                             > $MODULE_CONFIG
+    echo "GLIBC_LOCALES=\"$GLIBC_LOCALES\"" >> $MODULE_CONFIG
+  fi
+
+  echo "OPTS=\"\$OPTS $OPTS\"" >> $MODULE_CONFIG
+  echo "CONFIGURED=y"          >> $MODULE_CONFIG
 fi



More information about the Lunar-commits mailing list