[PATCH] add package name and centralize "reason" printing in promptconfaction()
the promptconfaction() function now takes a first parameter of the package
name. in a future debconf interface, it may be helpful to have this (if
we decide to register the questions per package/conffile). at the least,
it can provide a little more information to the user via debconf, where
the possible lack of terminal output would make things a little more
ambiguous.
additionally, the previous system used fprintf to stderr with some
some rather unintuitive (?:) expressions for which "reason" was printed
explaining the conflict to the user. while the (?:) expressions remain in
place, they are not directly printed but instead stored in a const char*,
which is then passed to a single fprintf call. this allows the reason
to be shared with a future debconf frontend much more cleanly.
---
src/configure.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/configure.c b/src/configure.c
index 9c73f8d..c6cba8e 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -51,10 +51,9 @@ static void md5hash(struct pkginfo *pkg, char **hashbuf, const char *fn);
static void copyfileperm(const char* source, const char* target);
static void showdiff(const char* old, const char* new);
static void suspend(void);
-static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
- const char* realnew, int useredited, int distedited,
- enum conffopt what);
-
+static enum conffopt promptconfaction(const char* package, const char* cfgfile,
+ const char* realold, const char* realnew, int useredited,
+ int distedited, enum conffopt what);
void deferred_configure(struct pkginfo *pkg) {
/* The algorithm for deciding what to configure first is as follows:
@@ -223,7 +222,7 @@ void deferred_configure(struct pkginfo *pkg) {
"deferred_configure `%s' (= `%s') useredited=%d distedited=%d what=%o",
conff->name, cdr.buf, useredited, distedited, what);
- what=promptconfaction(conff->name, cdr.buf, cdr2.buf, useredited, distedited, what);
+ what=promptconfaction(pkg->name, conff->name, cdr.buf, cdr2.buf, useredited, distedited, what);
switch (what & ~(cfof_isnew|cfof_userrmd)) {
case cfo_keep | cfof_backup:
@@ -522,10 +521,10 @@ static void suspend(void) {
/* Select what to do with a configuration file.
*/
-static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
+static enum conffopt promptconfaction(const char* package, const char* cfgfile, const char* realold,
const char* realnew, int useredited, int distedited,
enum conffopt what) {
- const char *s;
+ const char *s, *reason;
int c, cc;
if (!(what&cfof_prompt))
@@ -561,12 +560,12 @@ static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
fprintf(stderr,_(" (actually `%s')"), realold);
if (what & cfof_isnew) {
- fprintf(stderr,
+ reason = (
_("\n"
" ==> File on system created by you or by a script.\n"
" ==> File also in package provided by package maintainer.\n"));
} else {
- fprintf(stderr, !useredited ?
+ reason = ( !useredited ?
_("\n Not modified since installation.\n") :
!(what & cfof_userrmd) ?
_("\n ==> Modified (by you or by a script) since installation.\n") :
@@ -576,6 +575,7 @@ static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
_(" ==> Package distributor has shipped an updated version.\n") :
_(" Version in package is the same as at last installation.\n"));
}
+ fprintf(stderr, "%s", reason);
/* No --force-confdef but a forcible situtation */
/* TODO: check if this condition can not be simplified to just !fc_conff_def */
--
1.5.4.3
Reply to: