2 * dpkg - main program for package management
3 * errors.c - per package error handling
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2007-2014 Guillem Jover <guillem@debian.org>
8 * This is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 #include <sys/types.h>
37 #include <dpkg/i18n.h>
38 #include <dpkg/dpkg.h>
39 #include <dpkg/dpkg-db.h>
40 #include <dpkg/options.h>
44 bool abort_processing
= false;
49 struct error_report
*next
;
53 static struct error_report
*reports
= NULL
;
54 static struct error_report
**lastreport
= &reports
;
55 static struct error_report emergency
;
58 enqueue_error_report(const char *arg
)
60 struct error_report
*nr
;
62 nr
= malloc(sizeof(*nr
));
64 notice(_("failed to allocate memory for new entry in list of failed packages: %s"),
66 abort_processing
= true;
69 nr
->what
= m_strdup(arg
);
72 lastreport
= &nr
->next
;
74 if (++nerrs
< errabort
)
76 notice(_("too many errors, stopping"));
77 abort_processing
= true;
81 print_error_perpackage(const char *emsg
, const void *data
)
83 const char *pkgname
= data
;
85 notice(_("error processing package %s (--%s):\n %s"),
86 pkgname
, cipaction
->olong
, emsg
);
88 statusfd_send("status: %s : %s : %s", pkgname
, "error", emsg
);
90 enqueue_error_report(pkgname
);
94 print_error_perarchive(const char *emsg
, const void *data
)
96 const char *filename
= data
;
98 notice(_("error processing archive %s (--%s):\n %s"),
99 filename
, cipaction
->olong
, emsg
);
101 statusfd_send("status: %s : %s : %s", filename
, "error", emsg
);
103 enqueue_error_report(filename
);
107 reportbroken_retexitstatus(int ret
)
110 fputs(_("Errors were encountered while processing:\n"),stderr
);
112 fprintf(stderr
," %s\n",reports
->what
);
114 reports
= reports
->next
;
117 if (abort_processing
) {
118 fputs(_("Processing was halted because there were too many errors.\n"),stderr
);
120 return nerrs
? 1 : ret
;
124 skip_due_to_hold(struct pkginfo
*pkg
)
126 if (pkg
->want
!= PKG_WANT_HOLD
)
128 if (in_force(FORCE_HOLD
)) {
129 notice(_("package %s was on hold, processing it anyway as you requested"),
130 pkg_name(pkg
, pnaw_nonambig
));
133 printf(_("Package %s is on hold, not touching it. Use --force-hold to override.\n"),
134 pkg_name(pkg
, pnaw_nonambig
));