Bug#220868: Patch to implement a CLEARSEEN command
Hi,
The included (untested) patch implements a new CLEARSEEN command, which
should be called right before the module aborts. I don't really like adding
new debconf commands all the time, so I'm not committing it before somebody
else acks me on this :-)
/* Steinar */
--
Homepage: http://www.sesse.net/
? cdebconf-clearseen.diff
Index: src/commands.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/commands.c,v
retrieving revision 1.54
diff -u -r1.54 commands.c
--- src/commands.c 30 Sep 2003 20:23:07 -0000 1.54
+++ src/commands.c 16 Nov 2003 17:38:49 -0000
@@ -690,3 +690,20 @@
asprintf(&out, "%u OK", CMDSTATUS_SUCCESS);
return out;
}
+
+/*
+ * Clears the entire seen stack, so it will not be saved. Usually
+ * done when a user aborts configuration of a module, so he/she will
+ * be asked the same questions again when trying to configuring the
+ * module at a later stage.
+ */
+char *
+command_clearseen(struct confmodule *mod, char *arg)
+{
+ char *out;
+
+ mod->update_seen_questions(mod, STACK_SEEN_CLEAR);
+
+ asprintf(&out, "%u OK", CMDSTATUS_SUCCESS);
+ return out;
+}
Index: src/commands.h
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/commands.h,v
retrieving revision 1.10
diff -u -r1.10 commands.h
--- src/commands.h 3 Nov 2003 20:57:38 -0000 1.10
+++ src/commands.h 16 Nov 2003 17:38:49 -0000
@@ -205,4 +205,14 @@
*/
char *command_settitle(struct confmodule *mod, char *arg);
+/**
+ * @brief handler for the CLEARSEEN debconf command
+ *
+ * Clear the entire seen stack, usually used when aborting configuration
+ * of a module.
+ *
+ * @warning This is not in the debconf spec
+ */
+char *command_clearseen(struct confmodule *mod, char *arg);
+
#endif
Index: src/confmodule.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/confmodule.c,v
retrieving revision 1.28
diff -u -r1.28 confmodule.c
--- src/confmodule.c 27 Sep 2003 10:18:04 -0000 1.28
+++ src/confmodule.c 16 Nov 2003 17:38:49 -0000
@@ -38,6 +38,7 @@
{ "progress", command_progress },
{ "x_loadtemplatefile", command_x_loadtemplatefile },
{ "settitle", command_settitle },
+ { "clearseen", command_clearseen },
{ 0, 0 }
};
@@ -248,6 +249,7 @@
}
break;
case STACK_SEEN_SAVE:
+ case STACK_SEEN_CLEAR:
if (mod->seen_questions == NULL)
return DC_OK;
@@ -257,7 +259,8 @@
q = mod->questions->methods.get(mod->questions, *(mod->seen_questions+i));
if (q == NULL)
return DC_NOTOK;
- q->flags |= DC_QFLAG_SEEN;
+ if (action == STACK_SEEN_SAVE)
+ q->flags |= DC_QFLAG_SEEN;
DELETE(*(mod->seen_questions+i));
}
DELETE(mod->seen_questions);
Index: src/confmodule.h
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/confmodule.h,v
retrieving revision 1.10
diff -u -r1.10 confmodule.h
--- src/confmodule.h 18 Aug 2003 13:25:35 -0000 1.10
+++ src/confmodule.h 16 Nov 2003 17:38:49 -0000
@@ -18,8 +18,9 @@
enum seen_action {
STACK_SEEN_ADD, /* Add a question to the stack */
STACK_SEEN_REMOVE, /* Remove a question from the stack */
- STACK_SEEN_SAVE /* Questions are flagged as seen and
+ STACK_SEEN_SAVE, /* Questions are flagged as seen and
removed from the etack */
+ STACK_SEEN_CLEAR /* Clear the entire stack */
};
struct configuration;
Index: src/client/confmodule
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/client/confmodule,v
retrieving revision 1.4
diff -u -r1.4 confmodule
--- src/client/confmodule 27 Sep 2003 10:18:04 -0000 1.4
+++ src/client/confmodule 16 Nov 2003 17:38:49 -0000
@@ -34,8 +34,9 @@
# an upper-case function.
_old_opts="$@"
for i in "capb CAPB" "set SET" "reset RESET" "title TITLE" \
- "input INPUT" "beginblock BEGINBLOCK" "endblock ENDBLOCK" "go GO" \
- "get GET" "register REGISTER" "unregister UNREGISTER" "subst SUBST" \
+ "input INPUT" "beginblock BEGINBLOCK" "clearseen CLEARSEEN" \
+ "endblock ENDBLOCK" "go GO" "get GET" "register REGISTER" \
+ "unregister UNREGISTER" "subst SUBST" \
"previous_module PREVIOUS_MODULE" "fset FSET" "fget FGET" \
"purge PURGE" "metaget METAGET" "version VERSION" "clear CLEAR" \
"progress PROGRESS" "settitle SETTITLE"; do
Reply to: