Просмотр исходного кода

dpkg: untangle onerr_abort from too many errors condition

Give the “too many errors” while processing packages or archives
condition a different flag than the more serious onerr_abort condition
from unrecoverable fatal errors.

This is needed so that we can do a proper abort and stop dpkg completely
in case of an actual fatal error, without affecting the normal loop
processing error handling.
Guillem Jover лет назад: 17
Родитель
Сommit
c8d175fd55
6 измененных файлов с 27 добавлено и 6 удалено
  1. 11 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 2 1
      src/archives.c
  4. 5 4
      src/errors.c
  5. 1 0
      src/main.h
  6. 4 1
      src/packages.c

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+2008-11-14  Guillem Jover  <guillem@debian.org>
+
+	* src/main.h (abort_processing): New variable declaration.
+	* src/errors.c (abort_processing): New variable definition.
+	* src/archives.c (print_error_perpackage): Use abort_processing
+	instead of onerr_abort for non fatal errors.
+	(reportbroken_retexitstatus): Likewise. Do not check onerr_abort
+	for the exit value as it should not have reached this function.
+	* src/packages.c (process_queue): Likewise. Return on entering if
+	it should abort processing.
+
 2008-11-14  Guillem Jover  <guillem@debian.org>
 
 	* lib/ehandle.c (run_error_handler): New function.

+ 4 - 0
debian/changelog

@@ -8,6 +8,10 @@ dpkg (1.14.23) UNRELEASED; urgency=low
     the including file.
   * Fix Dpkg::Version comparison code. Closes: #504135
 
+  [ Guillem Jover ]
+  * Untangle fatal abort condition from the “too many errors” one in the
+    archives and packages processing loop.
+
   [ Updated dpkg translations ]
   * Catalan (Jordi Mallach).
   * Greek (Emmanuel Galatoulas). Closes: #498585

+ 2 - 1
src/archives.c

@@ -1187,7 +1187,8 @@ void archivefiles(const char *const *argv) {
   while ((thisarg = *argp++) != NULL) {
     if (setjmp(ejbuf)) {
       error_unwind(ehflag_bombout);
-      if (onerr_abort > 0) break;
+      if (abort_processing)
+        break;
       continue;
     }
     push_error_handler(&ejbuf,print_error_perpackage,thisarg);

+ 5 - 4
src/errors.c

@@ -39,6 +39,7 @@
 
 #include "main.h"
 
+int abort_processing = 0;
 int nerrs= 0;
 
 struct error_report {
@@ -61,7 +62,7 @@ void print_error_perpackage(const char *emsg, const char *arg) {
   nr= malloc(sizeof(struct error_report));
   if (!nr) {
     perror(_("dpkg: failed to allocate memory for new entry in list of failed packages."));
-    onerr_abort++;
+    abort_processing = 1;
     nr= &emergency;
   }
   nr->what= arg;
@@ -71,7 +72,7 @@ void print_error_perpackage(const char *emsg, const char *arg) {
     
   if (nerrs++ < errabort) return;
   fprintf(stderr, _("dpkg: too many errors, stopping\n"));
-  onerr_abort++;
+  abort_processing = 1;
 }
 
 int reportbroken_retexitstatus(void) {
@@ -82,10 +83,10 @@ int reportbroken_retexitstatus(void) {
       reports= reports->next;
     }
   }
-  if (onerr_abort) {
+  if (abort_processing) {
     fputs(_("Processing was halted because there were too many errors.\n"),stderr);
   }
-  return nerrs || onerr_abort ? 1 : 0;
+  return nerrs ? 1 : 0;
 }
 
 int skip_due_to_hold(struct pkginfo *pkg) {

+ 1 - 0
src/main.h

@@ -102,6 +102,7 @@ extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
 extern int fc_conff_old, fc_conff_def;
 extern int fc_badverify;
 
+extern int abort_processing;
 extern int errabort;
 extern const char *admindir;
 extern const char *instdir;

+ 4 - 1
src/packages.c

@@ -170,6 +170,9 @@ void process_queue(void) {
   jmp_buf ejbuf;
   enum istobes istobe= itb_normal;
   
+  if (abort_processing)
+    return;
+
   clear_istobes();
 
   switch (cipaction->arg) {
@@ -228,7 +231,7 @@ void process_queue(void) {
       /* give up on it from the point of view of other packages, ie reset istobe */
       pkg->clientdata->istobe= itb_normal;
       error_unwind(ehflag_bombout);
-      if (onerr_abort > 0)
+      if (abort_processing)
         return;
       continue;
     }