tags 271260 + patch thanks On Sunday 12 September 2004 09:51, Christian Perrier wrote: > The cat_shortlist function in postinst is quite slow which results, on > slow systems, on a blue screen being displayed for a while before the > screen with the short list of countries being displayed. > > I think it would be worth adding a progress bar in the cat_shortlist > functionn in coutnrychooser's postinst. Instead of adding a progress bar, I think I have very much improved the efficiency of building the shortlist by changing the structure of the /etc/shortlists file combined with attached patch for postinst. I have now tested the patch for postinst during an installation. (bubulle: I had to make a few change from the first version I send to you!) Also attached are: - a patch for mkshort (untested!) that should generate the new /etc/shortlists file; - an example /etc/shortlists file in the new format.
--- mkshort 2004-06-14 18:11:43.000000000 +0200 +++ debian/new/mkshort 2004-09-12 18:05:21.000000000 +0200 @@ -35,9 +35,9 @@ if [ "$2" ]; then translation=$( (grep "^$2 " $tabfile || true) | sed -e 's/^.* //') if [ "$translation" ]; then - echo "$1 $translation" >> $outfile + echo -e "$1\t$translation" >> $outfile else - echo "$1 $2" >> $outfile + echo -e "$1\t$2" >> $outfile fi fi fi @@ -57,7 +57,10 @@ for file in debian/short-tmp/*.short; do lang=`basename $file .short` - echo ":$lang" >> $SHORTLISTS - cat $file >> $SHORTLISTS + echo -n "$lang" >> $SHORTLISTS + ( while read line; do + echo -en "\t$line" >> $SHORTLISTS + done + ) < $file + echo "" >> $SHORTLISTS done -
--- postinst 2004-09-12 23:34:52.000000000 +0200 +++ new/postinst 2004-09-13 15:25:59.000000000 +0200 @@ -62,31 +62,52 @@ fi } -cat_shortlist() { - (out="" - IFS=' -' - while read line; do - if $(echo "$line" | grep -q "^:$1\$"); then - out=1 - elif $(echo "$line" | grep -q "^:"); then - out="" - elif [ "$out" ]; then - echo "$line" +# This function performs several tasks: +# - Search in $COUNTRY_SHORTLIST for either a coutrycode or a countryname +# - Build a shortlist for the dialog +get_shortlist() { + OLD_IFS="$IFS" + IFS=$(echo -en "\t") + SLIST="" + count=0 + for value in $COUNTRY_SHORTLIST; do + count=$(($count+1)) + if [ "$(($count % 2))" -eq 1 ] ; then + CCODE=$value + else + CNAME=$value + case "$1" in + code) + if [ "$CNAME" = "$2" ] ; then + echo $CCODE + break + fi + ;; + name) + if [ "$CCODE" = "$2" ] ; then + echo $CNAME + break + fi + ;; + shortlist) + if [ ! -z "${SLIST}" ]; then + SLIST="${SLIST}, " + fi + SL_NAME=$(echo "${INDENT}${CNAME}" | sed -e 's/,/\\,/') + SLIST="${SLIST}${SL_NAME}" + ;; + esac fi done - ) < $SHORTLISTS + if [ "$1" = "shortlist" ] ; then + echo "$SLIST" + fi + IFS="$OLD_IFS" } loccountry2code() { COUNTRYNAME=$(echo "$1" | sed "s/^$INDENT//" | sed 's/\\,/,/g') - line=`cat_shortlist $2| grep "$COUNTRYNAME\$"` - if [ -n "$line" ]; then - set $line - if [ -n "$1" ]; then - echo "$1" - fi - fi + echo $(get_shortlist code "$COUNTRYNAME") } # First grab back the country we got from languagechooser @@ -133,9 +154,9 @@ FIRST_LANG=$(echo $LANGUAGELIST | sed -e 's/:.*$//') -if grep -q "^:$FIRST_LANG\$" $SHORTLISTS; then +if grep -q "^$FIRST_LANG" $SHORTLISTS; then use_lang=$FIRST_LANG -elif grep -q "^:$LANGUAGE\$" $SHORTLISTS; then +elif grep -q "^$LANGUAGE" $SHORTLISTS; then use_lang=$LANGUAGE else use_lang="" @@ -160,19 +181,10 @@ if [ "$use_lang" ]; then # Build a short list of supported locales for # the language. - OLD_IFS="$IFS" - IFS=' -' - COUNTRIES=$(cat_shortlist $use_lang | sed -e 's/^.* //'); - SHORTLIST="" - for name in $COUNTRIES; do - if [ ! -z "${SHORTLIST}" ]; then - SHORTLIST="${SHORTLIST}, " - fi - countryname=$(echo "${INDENT}${name}" | sed -e 's/,/\\,/') - SHORTLIST="${SHORTLIST}${countryname}" - done - IFS="$OLD_IFS" + COUNTRY_SHORTLIST=$(grep "^$use_lang[[:space:]]" $SHORTLISTS | \ + sed -e "s/^$use_lang[[:space:]]//") + SHORTLIST=$(get_shortlist shortlist $use_lang) + db_subst $shortlist SHORTLIST "${SHORTLIST}" db_subst $shortlist DEFAULTLOCALE "${DEFAULTLOCALE}" db_input $shortprio $shortlist || [ $? -eq 30 ]
Attachment:
shortlists
Description: Binary data