[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] entropy plugin rework + support for the graphical installer



On Thu, Mar 13, 2008 at 11:42:24PM +0100, Max Vozeler wrote:
> The implementation looks fine from a quick glance. Please 
> feel free to add integrate it into cdebconf-entropy when
> you are happy with it.

Attached is a patchset which makes various changes to the current
cdebconf-entropy package in order to support other frontends than newt,
adds support for the GTK+ frontend, and update partman-crypto
accordingly.

> If directives weren't available, I would probably have 
> gone for a similar but slightly diffent solution - we could
> have partman-crypto provide a description fragment
> 
>   _Description: The encryption key for ${DEVICE} is now being created.
> 
> The different 'entropy' type frontend plugins would take
> the fragment and integrate it with the appropriate frontend-
> specific text to form a complete dialog. 

I finally choose this route instead of the more convoluted one I have
proposed earlier.

More comments related to translations on the proposed patchset:

 * AFAIK, the string displayed after gathering enough entropy was not
   translated before, as partman-crypto/entropy-text-success was not
   defined anywhere.  So please comment on the newly introduced
   partman-crypto/entropy-success.
 
 * debconf/entropy/success is the fallback template when SUCCESS has not
   been substituted to a more relevant template.  As it should not
   normally appear in d-i, I have put it under sublevel 5.  Please
   comment on the wording nevertheless. :)

 * No string changes actually happened, but as the previous
   partman-crypto/entropy-text content has been splitted between
   debconf/entropy/text/{action,help} and partman-crypto/entropy,
   I would be glad to know the best way to update po files directly
   instead of putting more burden on translators shoulders.

 * debconf/entropy/gtk/* are slights variations of
   debconf/entropy/text/* mentioning the mouse and might benefit from
   better wording as well.

I have tested these changes by putting the affected udebs directly in
netboot images, so I am unsure if the changes in dependencies and
dynamic retrieval of crypto packages are correct.  I would be glad if
someone could test that. :)

Cheers,
-- 
Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
commit 1b485b27b73c01d6d98cfbacac3f4ab994ee3a11
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 12:08:30 2008 +0100

    Rename newt entropy plugin from "entropy-text" to "entropy"
    
    There is no reason to have two sets of templates depending on which
    frontend is used to gather entropy, so let's rename the question type to
    "entropy".

diff --git a/packages/cdebconf-entropy/configure.ac b/packages/cdebconf-entropy/configure.ac
index ab450b3..dc895f4 100644
--- a/packages/cdebconf-entropy/configure.ac
+++ b/packages/cdebconf-entropy/configure.ac
@@ -1,5 +1,6 @@
-AC_INIT(newt-plugin-entropy-text.c)
-PACKAGE=entropy-text
+AC_INIT
+
+PACKAGE=entropy
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 
 AC_PROG_MAKE_SET
diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index bcef2fc..4e6602e 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -1,3 +1,9 @@
+cdebconf-entropy (0.7) UNRELEASED; urgency=low
+
+  * Rename newt entropy plugin from "entropy-text" to "entropy".
+
+ -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
+
 cdebconf-entropy (0.6) unstable; urgency=low
 
   * Switch the handler symbol to the "cdebconf_" namespace.
diff --git a/packages/cdebconf-entropy/newt-plugin-entropy-text.c b/packages/cdebconf-entropy/newt-plugin-entropy.c
similarity index 98%
rename from packages/cdebconf-entropy/newt-plugin-entropy-text.c
rename to packages/cdebconf-entropy/newt-plugin-entropy.c
index 722cae9..2cccdbf 100644
--- a/packages/cdebconf-entropy/newt-plugin-entropy-text.c
+++ b/packages/cdebconf-entropy/newt-plugin-entropy.c
@@ -74,7 +74,7 @@ help_text(struct frontend *obj)
 static const char *
 success_text(struct frontend *obj)
 {
-    return question_get_text(obj, "partman-crypto/entropy-text-success", 
+    return question_get_text(obj, "partman-crypto/entropy-success", 
       "Key data has been created successfully.");
 }
 
@@ -104,7 +104,7 @@ copy_byte(int in, int out)
 }
 
 int 
-cdebconf_newt_handler_entropy_text(struct frontend *obj, struct question *q)
+cdebconf_newt_handler_entropy(struct frontend *obj, struct question *q)
 {
     newtComponent form;
     struct newtExitStruct nstat;

commit fbf49b0796105f22424cfd72221e3b768e9d5a4d
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 12:23:08 2008 +0100

    Make newt entropy plugin able to use a different FIFO
    
    By specifying the FIFO template variable, a different FIFO than
    /var/run/random.fifo can now be used.  This is more practical for testing
    the plugin outside d-i.

diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 4e6602e..3348160 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -1,6 +1,8 @@
 cdebconf-entropy (0.7) UNRELEASED; urgency=low
 
   * Rename newt entropy plugin from "entropy-text" to "entropy".
+  * Make newt entropy plugin able to use a different FIFO through the "FIFO"
+    variable.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/newt-plugin-entropy.c b/packages/cdebconf-entropy/newt-plugin-entropy.c
index 2cccdbf..ba73eb2 100644
--- a/packages/cdebconf-entropy/newt-plugin-entropy.c
+++ b/packages/cdebconf-entropy/newt-plugin-entropy.c
@@ -111,18 +111,23 @@ cdebconf_newt_handler_entropy(struct frontend *obj, struct question *q)
     const char *p;
     int ret = DC_NOTOK;
     int keysize;
+    const char *fifo = NULL;
     int nwritten = 0;
     int want_data = 1;
     int randfd = 0;
     int fifofd = 0;
- 
+
     if (mlock(&rnd_byte, sizeof(rnd_byte)) < 0) {
         error("mlock failed: %s", strerror(errno));
         goto errout;
     }
-        
-    if (mkfifo(FIFO, 0600) < 0) {
-        error("mkfifo(%s): %s", FIFO, strerror(errno));
+
+    if (NULL == (fifo = question_get_variable(q, "FIFO"))) {
+        fifo = FIFO;
+    }
+
+    if (mkfifo(fifo, 0600) < 0) {
+        error("mkfifo(%s): %s", fifo, strerror(errno));
         goto errout;
     }
 
@@ -132,9 +137,9 @@ cdebconf_newt_handler_entropy(struct frontend *obj, struct question *q)
         goto errout;
     }
 
-    fifofd = open(FIFO, O_WRONLY);
+    fifofd = open(fifo, O_WRONLY);
     if (fifofd < 0) {
-        error("open(%s): %s", FIFO, strerror(errno));
+        error("open(%s): %s", fifo, strerror(errno));
         goto errout;
     }
    
@@ -195,8 +200,10 @@ errout:
         close(randfd);
     if (fifofd)
         close(fifofd);
-    
-    unlink(FIFO);
+   
+    if (NULL != fifo) {
+        unlink(fifo);
+    }
 
     munlock(&rnd_byte, sizeof(rnd_byte));
     return ret;

commit 4b22189ae849436d44876af3a4009de0ebe22547
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 12:26:44 2008 +0100

    Properly link the newt entropy plugin against libtextwrap

diff --git a/packages/cdebconf-entropy/Makefile.in b/packages/cdebconf-entropy/Makefile.in
index 18e128e..6962224 100644
--- a/packages/cdebconf-entropy/Makefile.in
+++ b/packages/cdebconf-entropy/Makefile.in
@@ -25,7 +25,7 @@ install: $(PLUGIN_MODULES)
 	done
 
 newt-plugin-$(PACKAGE).so: newt-plugin-$(PACKAGE).opic
-	$(CC) $(LDFLAGS) -shared -lnewt -o $@ newt-plugin-$(PACKAGE).opic
+	$(CC) $(LDFLAGS) -shared -lnewt -ltextwrap -o $@ newt-plugin-$(PACKAGE).opic
 
 clean:
 	rm -f $(PLUGIN_MODULES)
diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 3348160..ef8f74b 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -3,6 +3,7 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
   * Rename newt entropy plugin from "entropy-text" to "entropy".
   * Make newt entropy plugin able to use a different FIFO through the "FIFO"
     variable.
+  * Properly link the newt entropy plugin against libtextwrap.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 

commit 1b9b925c829b00d0e21fbc21eb5adee8613fc6bd
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 14:35:02 2008 +0000

    Do not link against the no longer used libdl

diff --git a/packages/cdebconf-entropy/Makefile.in b/packages/cdebconf-entropy/Makefile.in
index 6962224..466c3b1 100644
--- a/packages/cdebconf-entropy/Makefile.in
+++ b/packages/cdebconf-entropy/Makefile.in
@@ -11,7 +11,7 @@ incdir=${prefix}/include/cdebconf
 PACKAGE=@PACKAGE@
 CC=@CC@
 CFLAGS=@CFLAGS@ -I.
-LDFLAGS=@LDFLAGS@ -ldl
+LDFLAGS=@LDFLAGS@
 
 FRONTENDS=@FRONTENDS@
 PLUGIN_MODULES=$(addsuffix -plugin-$(PACKAGE).so,$(FRONTENDS))
diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index ef8f74b..76784ca 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -4,6 +4,8 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
   * Make newt entropy plugin able to use a different FIFO through the "FIFO"
     variable.
   * Properly link the newt entropy plugin against libtextwrap.
+  * Correctly link newt entropy plugin against libtextwrap.
+  * Do not link against the no longer used libdl.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 

commit c6880a8251ef832e83806ebde0ba529869922753
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 12:45:01 2008 +0100

    Allow success message to be read from a configurable template
    
    A new variable, SUCCESS, can be used to specify a template which text will
    be displayed when enough entropy has been gathered.

diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 76784ca..7c3a880 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -6,6 +6,8 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
   * Properly link the newt entropy plugin against libtextwrap.
   * Correctly link newt entropy plugin against libtextwrap.
   * Do not link against the no longer used libdl.
+  * Allow success message to be read from a configurable template through the
+    "SUCCESS" variable.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/newt-plugin-entropy.c b/packages/cdebconf-entropy/newt-plugin-entropy.c
index ba73eb2..d6cf346 100644
--- a/packages/cdebconf-entropy/newt-plugin-entropy.c
+++ b/packages/cdebconf-entropy/newt-plugin-entropy.c
@@ -72,9 +72,14 @@ help_text(struct frontend *obj)
 }
 
 static const char *
-success_text(struct frontend *obj)
+success_text(struct frontend *obj, struct question *q)
 {
-    return question_get_text(obj, "partman-crypto/entropy-success", 
+    const char *success;
+
+    if (NULL == (success = question_get_variable(q, "SUCCESS"))) {
+        success = "partman-crypto/entropy-success";
+    }
+    return question_get_text(obj, success, 
       "Key data has been created successfully.");
 }
 
@@ -187,7 +192,7 @@ cdebconf_newt_handler_entropy(struct frontend *obj, struct question *q)
 
             if (nwritten == keysize) {
                 /* Done - activate OK button */
-                newtTextboxSetText(textbox, success_text(obj));
+                newtTextboxSetText(textbox, success_text(obj, q));
                 newtComponentTakesFocus(bOK, 1);
                 newtFormSetCurrent(form, bOK);
                 want_data = 0;

commit 351006f14e41382a78e3088bc6462225758ccf01
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 15:03:54 2008 +0100

    Put strings relevant to the newt entropy plugin in new templates
    
    debconf/entropy/text/action and debconf/entropy/text/help, shipped in
    the cdebconf-newt-entropy package are now used by the plugin to get the
    strings that will be prompted by the user.
    
    The short description of the entropy question will now be prepended to the
    help text, thus removing the need to be specific on how to produce more
    entropy.

diff --git a/packages/cdebconf-entropy/debian/cdebconf-newt-entropy.templates b/packages/cdebconf-entropy/debian/cdebconf-newt-entropy.templates
new file mode 100644
index 0000000..17ef2e3
--- /dev/null
+++ b/packages/cdebconf-entropy/debian/cdebconf-newt-entropy.templates
@@ -0,0 +1,14 @@
+Template: debconf/entropy/text/action
+Type: text
+# :sl3:
+_Description: Enter random characters
+
+Template: debconf/entropy/text/help
+Type: text
+# :sl3:
+_Description: You can help speed up the process by entering random characters on the keyboard, or just wait until enough keydata has been collected. (NOTE: this can take a long time)
+
+Template: debconf/entropy/success
+Type: text
+# :sl5:
+_Description: Enough entropy has been gathered.
diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 7c3a880..49f5852 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -8,6 +8,8 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
   * Do not link against the no longer used libdl.
   * Allow success message to be read from a configurable template through the
     "SUCCESS" variable.
+  * Strings only relevant to the newt entropy plugin are now in templates
+    shipped with cdebconf-newt-entropy.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/debian/po/POTFILES.in b/packages/cdebconf-entropy/debian/po/POTFILES.in
new file mode 100644
index 0000000..af2b69d
--- /dev/null
+++ b/packages/cdebconf-entropy/debian/po/POTFILES.in
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] cdebconf-newt-entropy.templates
diff --git a/packages/cdebconf-entropy/debian/rules b/packages/cdebconf-entropy/debian/rules
index 72fa9c9..ad5a3ae 100755
--- a/packages/cdebconf-entropy/debian/rules
+++ b/packages/cdebconf-entropy/debian/rules
@@ -73,6 +73,7 @@ binary-arch: build install
 	dh_testroot
 	dh_installchangelogs 
 	dh_installdocs
+	dh_installdebconf
 	dh_install --sourcedir=debian/tmp
 	dh_link
 	dh_strip
diff --git a/packages/cdebconf-entropy/newt-plugin-entropy.c b/packages/cdebconf-entropy/newt-plugin-entropy.c
index d6cf346..964f290 100644
--- a/packages/cdebconf-entropy/newt-plugin-entropy.c
+++ b/packages/cdebconf-entropy/newt-plugin-entropy.c
@@ -8,6 +8,8 @@
  * 
  */ 
 
+#define _GNU_SOURCE
+
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/mman.h>
@@ -72,15 +74,30 @@ help_text(struct frontend *obj)
 }
 
 static const char *
+action_text(struct frontend *obj)
+{
+    return question_get_text(obj, "debconf/entropy/text/action", "Enter random characters");
+}
+
+static const char *
+entropy_help_text(struct frontend *obj)
+{
+    return question_get_text(obj, "debconf/entropy/text/help",
+        "You can help speed up the process by entering random characters on "
+        "the keyboard, or just wait until enough keydata has been collected. "
+        "(NOTE: this can take a long time)");
+}
+
+static const char *
 success_text(struct frontend *obj, struct question *q)
 {
     const char *success;
 
     if (NULL == (success = question_get_variable(q, "SUCCESS"))) {
-        success = "partman-crypto/entropy-success";
+        success = "debconf/entropy/success";
     }
     return question_get_text(obj, success, 
-      "Key data has been created successfully.");
+      "Enough entropy has been gathered.");
 }
 
 static int 
@@ -222,8 +239,7 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in
     int t_width, t_height;
     int t_width_buttons, t_width_title, t_width_scroll = 0;
     int win_width, win_height;
-    char *ext_description;
-    char *short_description;
+    char *description;
     const char *result;
 
 #ifdef HAVE_LIBTEXTWRAP
@@ -240,18 +256,18 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in
     /*  There are 5 characters for sigils, plus 4 for borders */
     strtruncate(obj->title, win_width-9);
 
-    ext_description = question_get_field((q), "", "extended_description");
-    short_description = question_get_field(q, "", "description");
+    asprintf(&description, "%s\n\n%s", question_get_field((q), "", "description"),
+        entropy_help_text(obj));
 
 #ifdef HAVE_LIBTEXTWRAP
     textwrap_init(&tw);
     textwrap_columns(&tw, win_width - 2 - 2*TEXT_PADDING);
-    wrappedtext = textwrap(&tw, ext_description);
-    free(ext_description);
-    ext_description = wrappedtext;
+    wrappedtext = textwrap(&tw, description);
+    free(description);
+    description = wrappedtext;
 #endif
 
-    t_height = cdebconf_newt_get_text_height(ext_description, win_width);
+    t_height = cdebconf_newt_get_text_height(description, win_width);
     if (t_height + 6 + 4 <= height-5)
         win_height = t_height + 6 + 4;
     else {
@@ -261,7 +277,7 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in
     }
 
     t_height = win_height - (6 + 4);
-    t_width = cdebconf_newt_get_text_width(ext_description);
+    t_width = cdebconf_newt_get_text_width(description);
     t_width_buttons = 2*BUTTON_PADDING;
     t_width_buttons += cdebconf_newt_get_text_width(goback_text(obj)) + 3;
     t_width_buttons += cdebconf_newt_get_text_width(continue_text(obj)) + 3;
@@ -292,10 +308,9 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in
     newtFormAddComponent(*form, bOK);
 
     newtScaleSet(scale, 0);
-    newtTextboxSetText(textbox, ext_description);
-    newtTextboxSetText(textbox2, short_description);
-    free(ext_description);
-    free(short_description);
+    newtTextboxSetText(textbox, description);
+    newtTextboxSetText(textbox2, action_text(obj));
+    free(description);
 }
 
 /* vim:set ts=4 sw=4 expandtab: */

commit 975d867a99e2be1b499618a65694601e7ccfb5ee
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 17:32:12 2008 +0100

    Properly handle the "backup" capability in the newt plugin
    
    The newt plugin now properly handles the "backup" capability: the "Go
    Back" button was previously always available.

diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 49f5852..fb1c1a2 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -10,6 +10,8 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
     "SUCCESS" variable.
   * Strings only relevant to the newt entropy plugin are now in templates
     shipped with cdebconf-newt-entropy.
+  * The newt plugin now properly handle the "backup" capability: the "Go Back"
+    button was previously always available.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/newt-plugin-entropy.c b/packages/cdebconf-entropy/newt-plugin-entropy.c
index 964f290..95afa4b 100644
--- a/packages/cdebconf-entropy/newt-plugin-entropy.c
+++ b/packages/cdebconf-entropy/newt-plugin-entropy.c
@@ -299,9 +299,14 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in
     scale = newtScale(TEXT_PADDING, 1+t_height+1, win_width-2*TEXT_PADDING, keysize);
     textbox2 = newtTextbox(TEXT_PADDING, 1+t_height+3, t_width, 1, tflags);
     entry = newtEntry(TEXT_PADDING, 1+t_height+5, "", t_width, &result, eflags);
-    bCancel = newtCompactButton((TEXT_PADDING + BUTTON_PADDING - 1), win_height-2, goback_text(obj));
 
-    newtFormAddComponents(*form, scale, textbox, textbox2, entry, bCancel, NULL);
+    newtFormAddComponents(*form, scale, textbox, textbox2, entry, NULL);
+    if (obj->methods.can_go_back(obj, q)) {
+        bCancel = newtCompactButton((TEXT_PADDING + BUTTON_PADDING - 1), win_height-2, goback_text(obj));
+        newtFormAddComponents(*form, bCancel, NULL);
+    } else {
+        bCancel = NULL;
+    }
 
     bOK = newtCompactButton((win_width - TEXT_PADDING - BUTTON_PADDING - strwidth(continue_text(obj))-3), win_height-2, continue_text(obj));
     newtComponentTakesFocus(bOK, 0);

commit 4eb9ff6e78c0bc6268da1aee3beee64486f75c3a
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 14:21:33 2008 +0000

    Make cdebconf-newt-entropy "Provides" cdebconf-entropy
    
    As different packages will be needed for the various frontends, having a
    cdebconf-entropy virtual package will allow more flexibility on the
    packages that will be loaded.

diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index fb1c1a2..3435c93 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -12,6 +12,7 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
     shipped with cdebconf-newt-entropy.
   * The newt plugin now properly handle the "backup" capability: the "Go Back"
     button was previously always available.
+  * Make cdebconf-newt-entropy "Provides" cdebconf-entropy.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/debian/control b/packages/cdebconf-entropy/debian/control
index ba654a4..1807ed4 100644
--- a/packages/cdebconf-entropy/debian/control
+++ b/packages/cdebconf-entropy/debian/control
@@ -11,6 +11,7 @@ Package: cdebconf-newt-entropy
 Architecture: any
 Section: debian-installer
 Depends: cdebconf-newt-udeb, ${shlibs:Depends}
+Provides: cdebconf-entropy
 XC-Package-Type: udeb
 Description: cdebconf newt plugin for reading from /dev/random
  cdebconf plugin to facilitate reading random data from /dev/random.

commit ec4c7b0f16b5023734b2f54949bac56600b42881
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 17:22:28 2008 +0100

    Add entropy plugin for the GTK+ frontend
    
    cdebconf-entropy now builds a new package, cdebconf-gtk-entropy, and thus
    Build-Depends on libgtk-directfb-2.0-dev.

diff --git a/packages/cdebconf-entropy/Makefile.in b/packages/cdebconf-entropy/Makefile.in
index 466c3b1..c02b298 100644
--- a/packages/cdebconf-entropy/Makefile.in
+++ b/packages/cdebconf-entropy/Makefile.in
@@ -12,6 +12,8 @@ PACKAGE=@PACKAGE@
 CC=@CC@
 CFLAGS=@CFLAGS@ -I.
 LDFLAGS=@LDFLAGS@
+GTK_CFLAGS=@GTK_CFLAGS@
+GTK_LIBS=@GTK_LIBS@
 
 FRONTENDS=@FRONTENDS@
 PLUGIN_MODULES=$(addsuffix -plugin-$(PACKAGE).so,$(FRONTENDS))
@@ -27,6 +29,9 @@ install: $(PLUGIN_MODULES)
 newt-plugin-$(PACKAGE).so: newt-plugin-$(PACKAGE).opic
 	$(CC) $(LDFLAGS) -shared -lnewt -ltextwrap -o $@ newt-plugin-$(PACKAGE).opic
 
+gtk-plugin-$(PACKAGE).so: gtk-plugin-$(PACKAGE).opic
+	$(CC) $(LDFLAGS) -shared -o $@ $^ $(GTK_LIBS)
+
 clean:
 	rm -f $(PLUGIN_MODULES)
 	rm -f *.opic
@@ -35,6 +40,10 @@ distclean: clean
 	rm -f config.log config.status
 	rm -f Makefile
 
+gtk-%.opic: gtk-%.c
+	@echo "Compiling $< to $@"
+	$(CC) $(CFLAGS) $(GTK_CFLAGS) -fPIC -o $@ -c $<
+
 %.opic: %.c
 	@echo "Compiling $< to $@"
 	$(CC) $(CFLAGS) -fPIC -o $@ -c $<
diff --git a/packages/cdebconf-entropy/configure.ac b/packages/cdebconf-entropy/configure.ac
index dc895f4..1e5695b 100644
--- a/packages/cdebconf-entropy/configure.ac
+++ b/packages/cdebconf-entropy/configure.ac
@@ -16,6 +16,12 @@ fi
 AC_CHECK_LIB(newt, newtInit, FRONTENDS="$FRONTENDS newt", echo
  "*** Cannot build Newt plugin ***")
 
+PKG_CHECK_MODULES(GTK, [gtk+-directfb-2.0],
+ FRONTENDS="$FRONTENDS gtk",
+ echo "*** Cannot build GTK+ plugin ***")
+
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
 AC_SUBST(FRONTENDS)
 AC_SUBST(PACKAGE)
 
diff --git a/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.install b/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.install
new file mode 100644
index 0000000..3a7472e
--- /dev/null
+++ b/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.install
@@ -0,0 +1 @@
+usr/lib/cdebconf/frontend/gtk
diff --git a/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.templates b/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.templates
new file mode 100644
index 0000000..a2ccfe7
--- /dev/null
+++ b/packages/cdebconf-entropy/debian/cdebconf-gtk-entropy.templates
@@ -0,0 +1,14 @@
+Template: debconf/entropy/gtk/action
+Type: text
+# :sl3:
+_Description: Enter random characters or random mouse movements
+
+Template: debconf/entropy/gtk/help
+Type: text
+# :sl3:
+_Description: You can help speed up the process by entering random characters on the keyboard or by moving the mouse randomly, or just wait until enough keydata has been collected. (NOTE: this can take a long time)
+
+Template: debconf/entropy/success
+Type: text
+# :sl5:
+_Description: Enough entropy has been gathered.
diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog
index 3435c93..16cbe1d 100644
--- a/packages/cdebconf-entropy/debian/changelog
+++ b/packages/cdebconf-entropy/debian/changelog
@@ -13,6 +13,9 @@ cdebconf-entropy (0.7) UNRELEASED; urgency=low
   * The newt plugin now properly handle the "backup" capability: the "Go Back"
     button was previously always available.
   * Make cdebconf-newt-entropy "Provides" cdebconf-entropy.
+  * Add an entropy plugin for the GTK+ frontend, shipped in
+    cdebconf-gtk-entropy.  This adds a Build-Depends on
+    libgtk-directfb-2.0-dev.
 
  -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 20:28:57 +0100
 
diff --git a/packages/cdebconf-entropy/debian/control b/packages/cdebconf-entropy/debian/control
index 1807ed4..95c9609 100644
--- a/packages/cdebconf-entropy/debian/control
+++ b/packages/cdebconf-entropy/debian/control
@@ -3,7 +3,7 @@ Priority: extra
 Section: debian-installer
 Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
 Uploaders: Max Vozeler <xam@debian.org>
-Build-Depends: debhelper (>= 4.2), libnewt-dev, libtextwrap-dev, libdebconfclient0-dev (>> 0.123)
+Build-Depends: debhelper (>= 4.2), libnewt-dev, libtextwrap-dev, libdebconfclient0-dev (>> 0.123), libgtk-directfb-2.0-dev
 Standards-Version: 3.7.2
 Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/cdebconf-entropy
 
@@ -17,3 +17,14 @@ Description: cdebconf newt plugin for reading from /dev/random
  cdebconf plugin to facilitate reading random data from /dev/random.
  Asks the user to enter random characters on the keyboard and shows a
  progressbar with percent-of-data read.
+
+Package: cdebconf-gtk-entropy
+Architecture: any
+Section: debian-installer
+Depends: cdebconf-gtk-udeb, ${shlibs:Depends}
+Provides: cdebconf-entropy
+XC-Package-Type: udeb
+Description: cdebconf gtk plugin for reading from /dev/random
+ cdebconf plugin to facilitate reading random data from /dev/random.
+ Asks the user to enter random characters on the keyboard and random mouse
+ movements while a progressbar shows the amount of entropy already gathered.
diff --git a/packages/cdebconf-entropy/debian/po/POTFILES.in b/packages/cdebconf-entropy/debian/po/POTFILES.in
index af2b69d..1e9e7c3 100644
--- a/packages/cdebconf-entropy/debian/po/POTFILES.in
+++ b/packages/cdebconf-entropy/debian/po/POTFILES.in
@@ -1 +1,2 @@
 [type: gettext/rfc822deb] cdebconf-newt-entropy.templates
+[type: gettext/rfc822deb] cdebconf-gtk-entropy.templates
diff --git a/packages/cdebconf-entropy/gtk-plugin-entropy.c b/packages/cdebconf-entropy/gtk-plugin-entropy.c
new file mode 100644
index 0000000..64094d6
--- /dev/null
+++ b/packages/cdebconf-entropy/gtk-plugin-entropy.c
@@ -0,0 +1,363 @@
+/*
+ * cdebconf gtk plugin to get random data
+ *
+ * Copyright © 2008 Jérémy Bobbio <lunar@debian.org>
+ * See debian/copyright for license.
+ *
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <cdebconf/frontend.h>
+#include <cdebconf/cdebconf_gtk.h>
+
+#include <gtk/gtk.h>
+
+#define MODULE "entropy"
+#define FIFO "/var/run/random.fifo"
+#define DEFAULT_KEYSIZE 2925
+
+/* Here's the plugin! */
+int cdebconf_gtk_handler_entropy(struct frontend * fe,
+                                 struct question * question,
+                                 GtkWidget * question_box);
+
+struct entropy {
+    struct frontend * fe;
+    GtkWidget * progress_bar;
+    GtkWidget * continue_button;
+    GtkWidget * entry;
+    guint64 keysize;
+    const char * fifo;
+    const char * success_template;
+    guint64 bytes_read;
+    int random_fd;
+    int fifo_fd;
+    guint8 random_byte;
+    GThread * gathering_thread;
+};
+
+static void handle_continue(GtkWidget * button, struct entropy * entropy_data)
+{
+    cdebconf_gtk_set_answer_ok(entropy_data->fe);
+}
+
+static gboolean add_help_text(struct entropy * entropy_data,
+                              GtkWidget * container)
+{
+    GtkWidget * label;
+    char * help_text;
+
+    help_text = cdebconf_gtk_get_text(
+        entropy_data->fe, "debconf/entropy/gtk/help",
+        "You can help speed up the process by entering random characters on "
+        "the keyboard or by moving the mouse randomly, or just wait until "
+        "enough keydata has been collected. (NOTE: this can take a long "
+        "time)");
+    label = gtk_label_new(help_text);
+    g_free(help_text);
+
+    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+    gtk_misc_set_alignment(GTK_MISC(label), 0 /* left */, 0 /* top */);
+    gtk_box_pack_start(GTK_BOX(container), label, FALSE /* no expand */,
+                       TRUE /* fill */, DEFAULT_PADDING);
+
+    return TRUE;
+}
+
+static gboolean add_action_text(struct entropy * entropy_data,
+                                GtkWidget * container)
+{
+    GtkWidget * label;
+    char * action_text;
+
+    action_text = cdebconf_gtk_get_text(
+        entropy_data->fe, "debconf/entropy/gtk/action",
+        "Enter random characters or random mouse movements");
+    label = gtk_label_new(action_text);
+    g_free(action_text);
+
+    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+    gtk_misc_set_alignment(GTK_MISC(label), 0 /* left */, 0 /* top */);
+    gtk_box_pack_start(GTK_BOX(container), label, FALSE /* no expand */,
+                       TRUE /* fill */, DEFAULT_PADDING);
+
+    return TRUE;
+}
+
+static GtkWidget * create_entropy_widget(struct entropy * entropy_data)
+{
+    GtkWidget * vbox;
+    GtkWidget * continue_button;
+    GtkWidget * progress_bar;
+    GtkWidget * entry;
+
+    continue_button = cdebconf_gtk_create_continue_button(entropy_data->fe);
+    if (NULL == continue_button) {
+        g_critical("cdebconf_gtk_create_continue_button failed.");
+        return NULL;
+    }
+    gtk_widget_set_sensitive(continue_button, FALSE);
+    g_signal_connect(continue_button, "clicked", G_CALLBACK(handle_continue),
+                     entropy_data);
+    g_object_ref(G_OBJECT(continue_button));
+    entropy_data->continue_button = continue_button;
+
+    vbox = gtk_vbox_new(FALSE /* not homogenous */, DEFAULT_PADDING);
+    if (NULL == vbox) {
+        g_critical("gtk_vbox_new failed.");
+        return NULL;
+    }
+
+    if (!add_help_text(entropy_data, vbox)) {
+        g_critical("add_help_text failed.");
+        return NULL;
+    }
+
+    if (NULL == (progress_bar = gtk_progress_bar_new())) {
+        g_critical("gtk_progress_bar_new failed.");
+        return NULL;
+    }
+    /* write a space to prepare progress bar height to receive the success
+     * confirmation at the end. */
+    gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), " ");
+    gtk_box_pack_start(GTK_BOX(vbox), progress_bar, FALSE /* no expand */,
+                       FALSE /* no fill */, DEFAULT_PADDING);
+    g_object_ref(G_OBJECT(progress_bar));
+    entropy_data->progress_bar = progress_bar;
+
+    if (!add_action_text(entropy_data, vbox)) {
+        g_critical("add_action_text failed.");
+        return NULL;
+    }
+
+    entry = gtk_entry_new();
+    if (NULL == entry) {
+        g_critical("gtk_entry_new failed.");
+        return NULL;
+    }
+    gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE /* password style */);
+    gtk_entry_set_activates_default(GTK_ENTRY(entry),
+                                    TRUE /* activate on Enter */);
+    gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE /* no expand */,
+                       FALSE /* no fill */, DEFAULT_PADDING);
+    g_object_ref(G_OBJECT(entry));
+    entropy_data->entry = entry;
+
+    return vbox;
+}
+
+static void refresh_progress_bar(struct entropy * entropy_data)
+{
+    gdk_threads_enter();
+    gtk_progress_bar_set_fraction(
+        GTK_PROGRESS_BAR(entropy_data->progress_bar),
+        (gdouble) entropy_data->bytes_read /
+        (gdouble) entropy_data->keysize);
+    gdk_threads_leave();
+}
+
+static gboolean move_byte(struct entropy * entropy_data)
+{
+    gssize n;
+
+    n = read(entropy_data->random_fd, &entropy_data->random_byte,
+             sizeof (guint8));
+    if (1 > n) {
+        g_critical("read failed: %s", strerror(errno));
+        return FALSE;
+    }
+    n = write(entropy_data->fifo_fd, &entropy_data->random_byte,
+              sizeof (guint8));
+    if (1 > n) {
+        g_critical("write failed: %s", strerror(errno));
+        return FALSE;
+    }
+    entropy_data->random_byte = 0;
+    return TRUE;
+}
+
+static void allow_continue(struct entropy * entropy_data)
+{
+    gchar * label;
+
+    label = cdebconf_gtk_get_text(
+        entropy_data->fe, entropy_data->success_template,
+        "Enough entropy has been gathered.");
+    gtk_progress_bar_set_text(
+        GTK_PROGRESS_BAR(entropy_data->progress_bar), label);
+    g_free(label);
+    gtk_widget_set_sensitive(entropy_data->continue_button, TRUE);
+}
+
+static void * gather_entropy(struct entropy * entropy_data)
+{
+    while (entropy_data->bytes_read < entropy_data->keysize) {
+        if (DC_NO_ANSWER != cdebconf_gtk_get_answer(entropy_data->fe)) {
+            /* answer set by others, let's quit */
+            return NULL;
+        }
+        if (!move_byte(entropy_data)) {
+            cdebconf_gtk_set_answer_notok(entropy_data->fe);
+            return NULL;
+        }
+        entropy_data->bytes_read++;
+        refresh_progress_bar(entropy_data);
+    }
+    allow_continue(entropy_data);
+    return NULL /* no one cares */;
+}
+
+static void destroy_entropy(struct entropy * entropy_data)
+{
+    if (NULL != entropy_data->gathering_thread) {
+        (void) g_thread_join(entropy_data->gathering_thread);
+    }
+    if (0 < entropy_data->fifo_fd) {
+        (void) close(entropy_data->fifo_fd);
+    }
+    if (NULL != entropy_data->fifo) {
+        (void) unlink(entropy_data->fifo);
+    }
+    if (0 < entropy_data->random_fd) {
+        (void) close(entropy_data->random_fd);
+    }
+    (void) munlock(&entropy_data->random_byte, sizeof (guint8));
+    if (NULL != entropy_data->progress_bar) {
+        g_object_unref(G_OBJECT(entropy_data->progress_bar));
+    }
+    if (NULL != entropy_data->entry) {
+        g_object_unref(G_OBJECT(entropy_data->entry));
+    }
+    if (NULL != entropy_data->continue_button) {
+        g_object_unref(G_OBJECT(entropy_data->continue_button));
+    }
+    g_free(entropy_data);
+}
+
+static struct entropy * init_entropy(struct frontend * fe,
+                                     struct question * question)
+{
+    struct entropy * entropy_data;
+
+    if (NULL == (entropy_data = g_malloc0(sizeof (struct entropy)))) {
+        g_critical("g_malloc0 failed.");
+        return NULL;
+    }
+    entropy_data->fe = fe;
+    if (-1 == mlock(&entropy_data->random_byte, sizeof (guint8))) {
+        g_critical("mlock failed: %s", strerror(errno));
+        goto failed;
+    }
+    entropy_data->success_template = question_get_variable(
+        question, "SUCCESS");
+    if (NULL == entropy_data->success_template) {
+        entropy_data->success_template = "debconf/entropy/success";
+    }
+    entropy_data->random_fd = open("/dev/random", O_RDONLY);
+    if (-1 == entropy_data->random_fd) {
+        g_critical("open random_fd failed: %s", strerror(errno));
+        goto failed;
+    }
+    entropy_data->fifo = question_get_variable(question, "FIFO");
+    if (NULL == entropy_data->fifo) {
+        entropy_data->fifo = FIFO;
+    }
+    if (-1 == mkfifo(entropy_data->fifo, 0600)) {
+        g_critical("mkfifo failed: %s", strerror(errno));
+        goto failed;
+    }
+    entropy_data->fifo_fd = open(entropy_data->fifo, O_WRONLY);
+    if (-1 == entropy_data->fifo_fd) {
+        g_critical("open fifo_fd failed: %s", strerror(errno));
+        goto failed;
+    }
+    return entropy_data;
+
+failed:
+    destroy_entropy(entropy_data);
+    return NULL;
+}
+
+static void cleanup(struct question * question, struct entropy * entropy_data)
+{
+    destroy_entropy(entropy_data);
+}
+
+static gboolean set_keysize(struct entropy * entropy_data,
+                            struct question * question) {
+    const char * keysize_string;
+
+    keysize_string = question_get_variable(question, "KEYSIZE");
+    if (NULL == keysize_string) {
+        entropy_data->keysize = DEFAULT_KEYSIZE;
+        return TRUE;
+    }
+    entropy_data->keysize = g_ascii_strtoull(
+        keysize_string, NULL /* don't get last parsed byte */,
+        0 /* default base */);
+    if (G_MAXUINT64 == entropy_data->keysize) {
+        g_critical("keysize out of range");
+        return FALSE;
+    }
+    if (0 == entropy_data->keysize) {
+        g_critical("can't parse KEYSIZE");
+        return FALSE;
+    }
+    return TRUE;
+}
+
+int cdebconf_gtk_handler_entropy(struct frontend * fe,
+                                 struct question * question,
+                                 GtkWidget * question_box)
+{
+    struct entropy * entropy_data;
+    GtkWidget * widget;
+
+    if (!IS_QUESTION_SINGLE(question)) {
+        g_critical("entropy plugin does not work alongside other questions.");
+        return DC_NOTOK;
+    }
+    if (NULL == (entropy_data = init_entropy(fe, question))) {
+        g_critical("init_entropy failed.");
+        return DC_NOTOK;
+    }
+    if (!set_keysize(entropy_data, question)) {
+        g_critical("set_keysize failed.");
+        goto failed;
+    }
+    if (NULL == (widget = create_entropy_widget(entropy_data))) {
+        g_critical("create_widget failed.");
+        goto failed;
+    }
+
+    entropy_data->gathering_thread = g_thread_create(
+        (GThreadFunc) gather_entropy, entropy_data,
+        TRUE /* joinable */, NULL /* no gerror */);
+    if (NULL == entropy_data->gathering_thread) {
+        g_critical("g_thread_create failed.");
+        goto failed;
+    }
+
+    cdebconf_gtk_add_common_layout(fe, question, question_box, widget);
+
+    gtk_widget_grab_focus(entropy_data->entry);
+
+    cdebconf_gtk_register_setter(fe, SETTER_FUNCTION(cleanup), question,
+                                 entropy_data);
+
+    return DC_OK;
+
+failed:
+    destroy_entropy(entropy_data);
+    return DC_NOTOK;
+}
+
+/* vim: et sw=4 si
+ */

commit 69c6b5d027db785161708c428ef3605e16844e25
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 14:10:28 2008 +0000

    Add a test suite for the entropy plugin

diff --git a/packages/cdebconf/src/test/entropy.config b/packages/cdebconf/src/test/entropy.config
new file mode 100755
index 0000000..fa8e641
--- /dev/null
+++ b/packages/cdebconf/src/test/entropy.config
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+randfifo=/tmp/random.fifo
+
+empty_fifo() {
+        while [ ! -p $randfifo ]; do
+                sleep 1
+        done
+        cat $randfifo >/dev/null
+}
+
+. ../client/confmodule
+
+db_capb backup
+echo "capb: $RET"
+if ! echo "$RET" | grep -w plugin-entropy; then
+        echo "entropy plugin not available"
+        exit 1
+fi
+
+empty_fifo & PID=$!
+
+db_subst test/entropy DEVICE /dev/sda1
+db_subst test/entropy FIFO $randfifo
+db_subst test/entropy SUCCESS test/success
+db_subst test/entropy KEYSIZE 128
+db_fset test/entropy seen false
+db_input high test/entropy
+db_go
+
+echo "$RET"
+
+kill $PID
+rm -f $randfifo
diff --git a/packages/cdebconf/src/test/entropy.templates b/packages/cdebconf/src/test/entropy.templates
new file mode 100644
index 0000000..c3a97f5
--- /dev/null
+++ b/packages/cdebconf/src/test/entropy.templates
@@ -0,0 +1,23 @@
+Template: test/entropy
+Type: entropy
+Description: The encryption key for ${DEVICE} is now being created.
+
+Template: test/success
+Type: text
+Description: Key data has been created successfully!
+
+Template: debconf/entropy/text/action
+Type: text
+Description: Enter random characters
+
+Template: debconf/entropy/text/help
+Type: text
+Description: You can help speed up the process by entering random characters on the keyboard, or just wait until enough keydata has been collected. (NOTE: this can take a long time)
+
+Template: debconf/entropy/gtk/action
+Type: text
+Description: Enter random characters or random mouse mouvements
+
+Template: debconf/entropy/gtk/help
+Type: text
+Description: You can help speed up the process by entering random characters on the keyboard or by moving the mouse randomly, or just wait until enough keydata has been collected. (NOTE: this can take a long time)

commit 8f788fb238f7f3a908dc14e4bbff050072cd39e0
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 21:53:26 2008 +0100

    Normalize case indentation in crypto-base.sh

diff --git a/packages/partman/partman-crypto/lib/crypto-base.sh b/packages/partman/partman-crypto/lib/crypto-base.sh
index 800b1a2..bff76aa 100644
--- a/packages/partman/partman-crypto/lib/crypto-base.sh
+++ b/packages/partman/partman-crypto/lib/crypto-base.sh
@@ -60,16 +60,16 @@ swap_is_safe () {
 
 	for swap in $(cat /proc/swaps); do
 		case $swap in
-		Filename*)
+		    Filename*)
 			continue
 			;;
-		/dev/loop*)
+		    /dev/loop*)
 			loop_is_safe ${swap%% *} || return 1
 			;;
-		/dev/mapper/*)
+		    /dev/mapper/*)
 			dm_is_safe ${swap%% *} || return 1
 			;;
-		*)
+		    *)
 			# Presume not safe
 			return 1
 			;;
@@ -119,11 +119,11 @@ setup_loopaes () {
 	[ -x /sbin/losetup-aes ] || return 1
 
 	case $keytype in
-	keyfile)
+	    keyfile)
 		opts="-K $keyfile"
 		pass="$keyfile.pass"
 		;;
-	random)
+	    random)
 		opts="-H random"
 		pass="/dev/null"
 		;;
@@ -206,7 +206,7 @@ setup_cryptdev () {
 	done
 
 	case $type in
-	dm-crypt)
+	    dm-crypt)
 		cryptdev=$(mapdevfs $realdev)
 		cryptdev="${cryptdev##*/}_crypt"
 		if [ -b "/dev/mapper/$cryptdev" ]; then
@@ -225,7 +225,7 @@ setup_cryptdev () {
 		cryptdev="/dev/mapper/$cryptdev"
 		;;
 
-	loop-AES)
+	    loop-AES)
 		cryptdev=$(get_free_loop);
 		if [ -z "$cryptdev" ]; then
 			return 1
@@ -549,14 +549,14 @@ crypto_set_defaults () {
 	[ -d $part ] || return 1
 
 	case $type in
-	dm-crypt)
+	    dm-crypt)
 		echo aes > $part/cipher
 		echo 256 > $part/keysize
 		echo cbc-essiv:sha256 > $part/ivalgorithm
 		echo passphrase > $part/keytype
 		echo sha256 > $part/keyhash
 		;;
-	loop-AES)
+	    loop-AES)
 		echo AES256 > $part/cipher
 		echo keyfile > $part/keytype
 		rm -f $part/keysize
@@ -576,13 +576,13 @@ crypto_prepare_method () {
 
 	[ -d $part ] || return 1
 	case $type in
-	dm-crypt)
+	    dm-crypt)
 		package="partman-crypto-dm"
 		;;
-	loop-AES)
+	    loop-AES)
 		package="partman-crypto-loop"
 		;;
-	*)
+	    *)
 		return 1
 		;;
 	esac
@@ -608,13 +608,13 @@ crypto_check_required_tools() {
 
 	tools="blockdev-keygen"
 	case $1 in
-	dm-crypt)
+	    dm-crypt)
 		tools="$tools dmsetup cryptsetup"
 		;;
-	loop-AES)
+	    loop-AES)
 		tools="$tools gpg base64"
 		;;
-	*)
+	    *)
 		return 1
 	esac
 
@@ -635,10 +635,10 @@ crypto_check_required_options() {
 	type=$2
 
 	case $type in
-	dm-crypt)
+	    dm-crypt)
 		options="cipher keytype keyhash ivalgorithm keysize"
 		;;
-	loop-AES)
+	    loop-AES)
 		options="cipher keytype"
 		;;
 	esac

commit 49ab88071991ae25c38874177f5ddde3790f6107
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sun Mar 23 14:26:45 2008 +0000

    Update partman-crypto for the new cdebconf-entropy usage
    
    This changes require cdebconf-entropy (>= 0.7).
    
    partman-crypto-dm and parman-crypto-loop now depend on the virtual
    cdebconf-entropy instead of cdebconf-newt-entropy to be independant of the
    frontend used.  The package with the relevant plugin is loaded dynamically
    in crypto_prepare_method.
    
    partman-crypto/entropy-success is a new template which will be be
    displayed when enough entropy has been gathered.
    
    The "entropy" question type is used instead of "entropy-text".
    
    The FIFO and SUCCESS variables are properly substituted before displaying
    partman-crypto/entropy.

diff --git a/packages/partman/partman-crypto/blockdev-keygen b/packages/partman/partman-crypto/blockdev-keygen
index d023ff4..3d727f6 100755
--- a/packages/partman/partman-crypto/blockdev-keygen
+++ b/packages/partman/partman-crypto/blockdev-keygen
@@ -95,30 +95,32 @@ have_entropy_plugin () {
 	db_capb
 	set -- $RET
 	for cap; do
-		if [ "$cap" = plugin-entropy-text ]; then
+		if [ "$cap" = plugin-entropy ]; then
 			return 0
 		fi
 	done
 	return 1
 }
 
+# Fifo provided by cdebconf-entropy plugins
+randfifo=/var/run/random.fifo
+
 call_entropy_plugin () {
 	local keybytes
 	keybytes=$1
 
-	templ=partman-crypto/entropy-text
+	templ=partman-crypto/entropy
 	db_fset $templ seen false
 	db_subst $templ DEVICE "$description"
+	db_subst $templ FIFO $randfifo
 	db_subst $templ KEYSIZE "$keybytes"
+	db_subst $templ SUCCESS partman-crypto/entropy-success
 	db_input critical $templ
 	db_go || return 1
 
 	return 0
 }
 
-# Fifo provided by cdebconf-entropy plugins
-randfifo=/var/run/random.fifo
-
 gnupg_encrypt () {
 	local keyfile passfifo gpgopts
 	keyfile=$1
diff --git a/packages/partman/partman-crypto/debian/changelog b/packages/partman/partman-crypto/debian/changelog
index 8c6f31e..be5042c 100644
--- a/packages/partman/partman-crypto/debian/changelog
+++ b/packages/partman/partman-crypto/debian/changelog
@@ -1,3 +1,16 @@
+partman-crypto (29) UNRELEASED; urgency=low
+
+  * Make partman-crypto-dm and parman-crypto-loop depends on the virtual
+    cdebconf-entropy instead of cdebconf-newt-entropy to be independant of the
+    frontend used.  Requires cdebconf-entropy (>= 0.7).
+  * Add partman-crypto/entropy-success template which will be be displayed
+    when enough entropy has been gathered.
+  * Use the "entropy" question type instead of "entropy-text".
+  * Substitute FIFO and SUCCESS variables before displaying
+    partman-crypto/entropy.
+
+ -- Jérémy Bobbio <lunar@debian.org>  Sun, 23 Mar 2008 14:22:31 +0000
+
 partman-crypto (28) unstable; urgency=low
 
   [ Max Vozeler ]
diff --git a/packages/partman/partman-crypto/debian/control b/packages/partman/partman-crypto/debian/control
index 3c3faa6..9340582 100644
--- a/packages/partman/partman-crypto/debian/control
+++ b/packages/partman/partman-crypto/debian/control
@@ -15,11 +15,11 @@ Description: Add to partman support for block device encryption
 Package: partman-crypto-dm
 XC-Package-Type: udeb
 Architecture: all
-Depends: partman-crypto, crypto-modules, cryptsetup-udeb, cdebconf-newt-entropy (>= 0.3)
+Depends: partman-crypto, crypto-modules, cryptsetup-udeb, cdebconf-entropy
 Description: Add to partman support for dm-crypt encryption
 
 Package: partman-crypto-loop
 XC-Package-Type: udeb
 Architecture: all
-Depends: partman-crypto, loop-aes-modules, mount-aes-udeb, gnupg-udeb, cdebconf-newt-entropy (>= 0.3)
+Depends: partman-crypto, loop-aes-modules, mount-aes-udeb, gnupg-udeb, cdebconf-entropy
 Description: Add to partman support for loop-AES encryption
diff --git a/packages/partman/partman-crypto/debian/partman-crypto.templates b/packages/partman/partman-crypto/debian/partman-crypto.templates
index 022f121..9fc32c6 100644
--- a/packages/partman/partman-crypto/debian/partman-crypto.templates
+++ b/packages/partman/partman-crypto/debian/partman-crypto.templates
@@ -353,15 +353,15 @@ _Description: Use weak passphrase?
  You entered a passphrase that consists of less than ${MINIMUM} characters,
  which is considered too weak. You should choose a stronger passphrase.
 
-Template: partman-crypto/entropy-text
-Type: entropy-text
+Template: partman-crypto/entropy
+Type: entropy
 # :sl3:
-_Description: Enter random characters
- The encryption key for ${DEVICE} is now being created.
- .
- You can help speed up the process by entering random characters on
- the keyboard, or just wait until enough keydata has been collected.
- (NOTE: this can take a long time)
+_Description: The encryption key for ${DEVICE} is now being created.
+
+Template: partman-crypto/entropy-success
+Type: text
+# :sl3:
+_Description: Key data has been created successfully.
 
 Template: partman-crypto/keyfile-problem
 Type: error
diff --git a/packages/partman/partman-crypto/lib/crypto-base.sh b/packages/partman/partman-crypto/lib/crypto-base.sh
index bff76aa..f620290 100644
--- a/packages/partman/partman-crypto/lib/crypto-base.sh
+++ b/packages/partman/partman-crypto/lib/crypto-base.sh
@@ -575,12 +575,17 @@ crypto_prepare_method () {
 	package=''
 
 	[ -d $part ] || return 1
+	case $DEBIAN_FRONTEND in
+	    newt|gtk)
+		package="cdebconf-$DEBIAN_FRONTEND-entropy"
+		;;
+	esac
 	case $type in
 	    dm-crypt)
-		package="partman-crypto-dm"
+		package="$package partman-crypto-dm"
 		;;
 	    loop-AES)
-		package="partman-crypto-loop"
+		package="$package partman-crypto-loop"
 		;;
 	    *)
 		return 1

Attachment: signature.asc
Description: Digital signature


Reply to: