tags 493720 + patch
thanks
On Tue, Aug 05, 2008 at 01:11:44AM +0200, Jérémy Bobbio wrote:
> As far as I have been able to track down this issue, it is related to
> the change which happened in cdebconf 0.132. The default value for
> select questions that are noninteractive must since be in the possible
> choices.
>
> After trying to come up with a patch to solve this, I see two different
> possibilities to fix this:
> […]
> * Detect if console-keymaps-$KEYBOARD/keymap has been seen, and
> if so, directly set the keymap to its value.
The attached patch implement this last option.
I'll be waiting a few more days for other opinions before commiting.
Cheers,
--
Jérémy Bobbio .''`.
lunar@debian.org : :Ⓐ : # apt-get install anarchism
`. `'`
`-
commit 4ebdf75e9dbb3678b530d77adf760a7ae1d7c792
Author: Jérémy Bobbio <lunar@debian.org>
Date: Tue Aug 5 15:07:05 2008 +0200
Fix console-keymaps-$KEYBOARD/keymap preseeding
Since cdebconf 0.132, the default value needs to be in the select list
otherwise the default value is selected. So we now skip asking
console-keymaps-$KEYBOARD/keymap completely if it has been previously
seen in order to allow preseeding for keymaps not among the possible
choices of the select.
(Closes: #493720)
diff --git a/packages/kbd-chooser/debian/changelog b/packages/kbd-chooser/debian/changelog
index 728fec4..413837e 100644
--- a/packages/kbd-chooser/debian/changelog
+++ b/packages/kbd-chooser/debian/changelog
@@ -1,3 +1,14 @@
+kbd-chooser (1.45) UNRELEASED; urgency=low
+
+ [ Jérémy Bobbio ]
+ * Since cdebconf 0.132, the default value needs to be in the select list
+ otherwise the default value is selected. So we now skip asking
+ console-keymaps-$KEYBOARD/keymap completely if it has been previously
+ seen in order to allow preseeding for keymaps not among the possible
+ choices of the select. (Closes: #493720)
+
+ -- Jérémy Bobbio <lunar@debian.org> Tue, 05 Aug 2008 00:51:45 +0200
+
kbd-chooser (1.44) unstable; urgency=low
[ Frans Pop ]
diff --git a/packages/kbd-chooser/debian/postinst b/packages/kbd-chooser/debian/postinst
index af93524..6b521d1 100644
--- a/packages/kbd-chooser/debian/postinst
+++ b/packages/kbd-chooser/debian/postinst
@@ -4,4 +4,24 @@ set -e
. /usr/share/debconf/confmodule
+# Replace preseed value by the real keymap name if needed
+for keyboard in @@KEYBOARDS@@; do
+ if ! db_get console-keymaps-$keyboard/keymap; then
+ continue
+ fi
+ keymap="$RET"
+ while read alternatives canonical full_name; do
+ old_ifs="$IFS"
+ IFS=:
+ for alternative in $alternatives; do
+ IFS="$old_ifs"
+ if [ "$keymap" = "$alternative" ]; then
+ db_set console-keymaps-$keyboard/keymap $canonical
+ break 2
+ fi
+ IFS=:
+ done
+ done < /usr/share/console/lists/console-keymaps-$arch
+done
+
exec kbd-chooser
diff --git a/packages/kbd-chooser/kbd-chooser.c b/packages/kbd-chooser/kbd-chooser.c
index ae7a169..82cb692 100644
--- a/packages/kbd-chooser/kbd-chooser.c
+++ b/packages/kbd-chooser/kbd-chooser.c
@@ -74,6 +74,27 @@ mydebconf_default_set (char *template, char *value)
return res;
}
+/**
+ * @brief Get a default value for a question if it has already been seen
+ */
+int
+mydebconf_get (char *template, char **result)
+{
+ int res = 0;
+ struct debconfclient *client = mydebconf_client ();
+ debconf_fget (client, template, "seen");
+ if (0 == strcmp (client->value, "false")) {
+ return !CMD_SUCCESS;
+ }
+ if ((res = debconf_get (client, template)))
+ return res;
+
+ if (client->value != NULL && strlen (client->value) > 0) {
+ *result = client->value;
+ return CMD_SUCCESS;
+ }
+ return !CMD_SUCCESS;
+}
/**
* @brief Ensure a directory is present (and readable)
@@ -717,16 +738,18 @@ keymap_select (char *arch, char *keymap)
di_error ("Keyboard not found\n");
exit (7);
}
- // If there is a default keymap for this keyboard, select it
- // This is set if we can actually read preferred type from keyboard,
- // and shouldn't have to ask the question.
- if (kb->deflt) {
- def = keymap_get (maplist_get (arch), kb->deflt, NULL);
- mydebconf_default_set (template, kb->deflt);
+ if (CMD_SUCCESS != mydebconf_get (template, &ptr)) {
+ // If there is a default keymap for this keyboard, select it
+ // This is set if we can actually read preferred type from keyboard,
+ // and shouldn't have to ask the question.
+ if (kb->deflt) {
+ def = keymap_get (maplist_get (arch), kb->deflt, NULL);
+ mydebconf_default_set (template, kb->deflt);
+ }
+ res = mydebconf_ask ( kb->deflt ? "low" : "high", template, &ptr);
+ if (res != CMD_SUCCESS)
+ return res;
}
- res = mydebconf_ask ( kb->deflt ? "low" : "high", template, &ptr);
- if (res != CMD_SUCCESS)
- return res;
strcpy (keymap, (strlen (ptr) == 0) ? "skip-config" : ptr);
return CMD_SUCCESS;
Attachment:
signature.asc
Description: Digital signature