[Debconf-devel] [Fwd: Handling values with db_get in case of translation]

Colin Watson cjwatson at debian.org
Thu Feb 21 09:05:51 UTC 2008


On Wed, Feb 20, 2008 at 03:12:34PM +0100, Olivier Berger wrote:
> I'm wondering how would one write postinst script tests, in the case
> of "select" debconf configuration values, which are translated in the
> templates.
> 
> Let's say that a package's template contains something like :
> 
>  Template: sympa/db_authtype
>  Type: select
>  Choices: Ident-based, Password
>  ...
>  Choices-fr.UTF-8: Basée sur ident, Mot de passe
> 
> If issueing 'db_get sympa/db_authtype', and wanting to test the
> results, I would expect some code like the following to be correct :
> 
>  db_get sympa/db_authtype
>    if [ "$RET" = "Ident-based" ]; then
>    ...
> 
> However, it seems that the db_get results depend on the locale, and
> return "Basée sur ident" instead of "Ident-based" when with french
> locale...

That's odd; it's definitely supposed to be translated back to the
English text before being stored in the database, so GET should always
return the untranslated text from Choices rather than the translated
text from Choices-fr.UTF-8. I can't reproduce this with the sympa
package in unstable with LANG=fr_FR.UTF-8:

  debconf (developer): <-- INPUT medium sympa/db_authtype
  debconf (developer): --> 0 question will be asked
  debconf (developer): <-- GO
  debconf (developer): --> 0 ok
  debconf (developer): <-- GET sympa/db_authtype
  debconf (developer): --> 0 Ident-based

I did need the following patch to fix some broken code in the config
script before I could get anywhere, though. Racke, perhaps you could
apply this while we figure out the rest of it?

diff -u sympa-5.3.4/debian/config sympa-5.3.4/debian/config
--- sympa-5.3.4/debian/config
+++ sympa-5.3.4/debian/config
@@ -198,6 +198,8 @@
 if [ "$use_db" = "true" ]; then
     db_input high sympa/db_type || [ $? -eq 30 ]
     db_go
+    db_get sympa/db_type
+    db_type="$RET"
 
     db_input high sympa/db_hostname || [ $? -eq 30 ]
     db_go
@@ -222,7 +224,7 @@
 		db_go
 
 		db_get sympa/db_authtype
-		if [ "$RET" eq "Ident-based" ]; then
+		if [ "$RET" = "Ident-based" ]; then
 			IDENT=1
 		fi
 
@@ -280,8 +282,6 @@
     db_go
 
 	# Ask for the admin password
-	db_get sympa/db_type
-	db_type="$RET"
 	db_subst sympa/db_adminpasswd database "$db_type"
 
 	db_input critical sympa/db_adminpasswd || [ $? -eq 30 ]

Olivier, exactly which locale are you using (output of 'locale'), and
which debconf frontend are you using (output of 'echo GET
debconf/frontend | debconf-communicate')?

-- 
Colin Watson                                       [cjwatson at debian.org]



More information about the Debconf-devel mailing list