Bug#297880: [DPKG][CONFFILE] include support for conffile reporting on status-fd and useful error reporting
Package: dpkg
Version: 1.10.27
The attached patch adds the following information to the reports of
--status-fd (and updates the man-page):
Errors are reported as:
`status: $pkg : error : extend-error-message
Configuration file conflicts are reported as
`status: conffile-prompt: $conffile : 'current-conffile' 'new-conffile' useredited distedited`
This is usefull for GUI tools (like synaptic) that want to hide the
dpkg-messages and present nice status progress bar instead.
Cheers,
Michael
--- orig/main/configure.c
+++ mod/main/configure.c
@@ -53,6 +53,9 @@
const char* realnew, int useredited, int distedited,
enum conffopt what);
+extern struct pipef *status_pipes;
+
+
void deferred_configure(struct pkginfo *pkg) {
/* The algorithm for deciding what to configure first is as follows:
* Loop through all packages doing a `try 1' until we've been round
@@ -215,7 +218,7 @@
debug(dbg_conff,
"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);
switch (what & ~cfof_isnew) {
@@ -525,6 +528,27 @@
if (!(what&cfof_prompt))
return what;
+ /* if there is a status pipe, send conffile-prompt there */
+ if (status_pipes) {
+ static struct varbuf *status= NULL;
+ struct pipef *pipef= status_pipes;
+ int r;
+ if (status == NULL) {
+ status = nfmalloc(sizeof(struct varbuf));
+ varbufinit(status);
+ } else
+ varbufreset(status);
+
+ r= varbufprintf(status, "status: %s : %s : '%s' '%s' %i %i \n",
+ cfgfile, "conffile-prompt",
+ realold, realnew, useredited, distedited);
+ while (pipef) {
+ write(pipef->fd, status->buf, r);
+ pipef= pipef->next;
+ }
+ }
+
+
do {
fprintf(stderr, _("\nConfiguration file `%s'"), cfgfile);
if (strcmp(cfgfile, realold))
--- orig/main/dpkg.8
+++ mod/main/dpkg.8
@@ -477,6 +477,9 @@
\fB\-\-status\-fd \fP\fI<n>\fP
Send package status info to file descriptor \fI<n>\fP. This can be given
multiple times. Status updates are of the form `status: <pkg>: <pkg qstate>'.
+Errors are reported as `status: <pkg>: error: extend-error-message'.
+Configuration file conflicts are reported as
+`status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited'
.SH FILES
.TP
.I /etc/dpkg/dpkg.cfg
--- orig/main/errors.c
+++ mod/main/errors.c
@@ -50,11 +50,32 @@
static struct error_report **lastreport= &reports;
static struct error_report emergency;
+extern struct pipef *status_pipes;
+
void print_error_perpackage(const char *emsg, const char *arg) {
struct error_report *nr;
fprintf(stderr, _("%s: error processing %s (--%s):\n %s\n"),
DPKG, arg, cipaction->olong, emsg);
+
+ if (status_pipes) {
+ static struct varbuf *status= NULL;
+ struct pipef *pipef= status_pipes;
+ int r;
+ if (status == NULL) {
+ status = nfmalloc(sizeof(struct varbuf));
+ varbufinit(status);
+ } else
+ varbufreset(status);
+
+ r= varbufprintf(status, "status: %s : %s : %s\n", arg, "error",emsg);
+ while (pipef) {
+ write(pipef->fd, status->buf, r);
+ pipef= pipef->next;
+ }
+ }
+
+
nr= malloc(sizeof(struct error_report));
if (!nr) {
perror(_("dpkg: failed to allocate memory for new entry in list of failed packages."));
--- orig/man/en/dpkg.8.sgml
+++ mod/man/en/dpkg.8.sgml
@@ -1329,11 +1329,15 @@
</cmdsynopsis>
</term>
- <listitem><para>
+ <listitem><para>
Send package status info to file descriptor
<option><n></option>. This can be given multiple times.
Status updates are of the form
<screen>`status: <pkg>: <pkg qstate>'</screen>
+ Errors are reported as
+ <screen>`status: <pkg> : error : extend-error-message`</screen>
+ Configuration file conflicts are reported as
+ <screen>`status: conffile-prompt:<conffile> : 'current-conffile' 'new-conffile' useredited distedited`</screen>
</para></listitem>
</varlistentry>
</variablelist>
Reply to: