diff options
Diffstat (limited to 'main/errors.c')
-rw-r--r-- | main/errors.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/main/errors.c b/main/errors.c new file mode 100644 index 000000000..b4064b2d9 --- /dev/null +++ b/main/errors.c @@ -0,0 +1,111 @@ +/* + * dpkg - main program for package management + * main.c - main program + * + * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <signal.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <errno.h> +#include <unistd.h> +#include <dirent.h> +#include <limits.h> +#include <ctype.h> + +#include "config.h" +#include "dpkg.h" +#include "dpkg-db.h" +#include "myopt.h" + +#include "main.h" + +int nerrs= 0; + +struct error_report { + struct error_report *next; + const char *what; +}; + +static struct error_report *reports=0; +static struct error_report **lastreport= &reports; +static struct error_report emergency; + +void print_error_perpackage(const char *emsg, const char *arg) { + struct error_report *nr; + + fprintf(stderr, DPKG ": error processing %s (--%s):\n %s\n", + arg, cipaction->olong, emsg); + nr= malloc(sizeof(struct error_report)); + if (!nr) { + perror(DPKG ": failed to allocate memory for new entry in list of failed packages."); + onerr_abort++; + nr= &emergency; + } + nr->what= arg; + nr->next= 0; + *lastreport= nr; + lastreport= &nr->next; + + if (nerrs++ < 20) return; + fprintf(stderr, DPKG ": too many errors, stopping\n"); + onerr_abort++; +} + +int reportbroken_retexitstatus(void) { + if (reports) { + fputs("Errors were encountered while processing:\n",stderr); + while (reports) { + fprintf(stderr," %s\n",reports->what); + reports= reports->next; + } + } + if (onerr_abort) { + fputs("Processing was halted because there were too many errors.\n",stderr); + } + return nerrs || onerr_abort ? 1 : 0; +} + +int skip_due_to_hold(struct pkginfo *pkg) { + if (!(pkg->eflag & eflagf_hold)) return 0; + if (fc_hold) { + fprintf(stderr, "Package %s was on hold, processing it anyway as you request\n", + pkg->name); + return 0; + } + printf("Package %s is on hold, not touching it. Use --force-hold to override.\n", + pkg->name); + return 1; +} + +void forcibleerr(int forceflag, const char *fmt, ...) { + va_list al; + va_start(al,fmt); + if (forceflag) { + fputs(DPKG " - warning, overriding problem because you used --force:\n ",stderr); + vfprintf(stderr,fmt,al); + fputc('\n',stderr); + } else { + ohshitv(fmt,al); + } + va_end(al); +} |