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

Switch to new notice() output function

This switches all ad-hoc stderr printing for error notices to the
notice() function.
Guillem Jover лет назад: 14
Родитель
Сommit
5a5203e9aa
15 измененных файлов с 80 добавлено и 103 удалено
  1. 2 3
      dpkg-deb/extract.c
  2. 2 3
      dpkg-deb/info.c
  3. 2 2
      lib/dpkg/log.c
  4. 37 44
      src/archives.c
  5. 4 6
      src/configure.c
  6. 1 1
      src/enquiry.c
  7. 6 8
      src/errors.c
  8. 3 4
      src/packages.c
  9. 5 6
      src/processarc.c
  10. 9 11
      src/querycmd.c
  11. 2 4
      src/remove.c
  12. 2 3
      src/script.c
  13. 1 1
      src/select.c
  14. 2 4
      src/trigcmd.c
  15. 2 3
      src/trigproc.c

+ 2 - 3
dpkg-deb/extract.c

@@ -255,9 +255,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
     }
   } else {
     if (strncmp(versionbuf, "!<arch>", 7) == 0) {
-      fprintf(stderr,
-              _("dpkg-deb: file looks like it might be an archive which has been\n"
-                "dpkg-deb:    corrupted by being downloaded in ASCII mode\n"));
+      notice(_("file looks like it might be an archive which has been\n"
+               " corrupted by being downloaded in ASCII mode"));
     }
 
     ohshit(_("`%.255s' is not a debian format archive"),debar);

+ 2 - 3
dpkg-deb/info.c

@@ -109,9 +109,8 @@ info_spew(const char *debar, const char *dir, const char *const *argv)
                controlfile.buf, debar, err.str);
       close(fd);
     } else if (errno == ENOENT) {
-      fprintf(stderr,
-              _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"),
-              debar, component);
+      notice(_("'%.255s' contains no control component '%.255s'"),
+             debar, component);
       re++;
     } else {
       ohshite(_("open component `%.255s' (in %.255s) failed in an unexpected way"),

+ 2 - 2
lib/dpkg/log.c

@@ -50,8 +50,8 @@ log_message(const char *fmt, ...)
 	if (!logfd) {
 		logfd = fopen(log_file, "a");
 		if (!logfd) {
-			fprintf(stderr, _("couldn't open log `%s': %s\n"),
-			        log_file, strerror(errno));
+			notice(_("could not open log '%s': %s"),
+			       log_file, strerror(errno));
 			log_file = NULL;
 			return;
 		}

+ 37 - 44
src/archives.c

@@ -1257,17 +1257,17 @@ try_deconfigure_can(bool (*force_p)(struct deppossi *), struct pkginfo *pkg,
                   " package %s, to enable %s."),
                 pkg_name(pkg, pnaw_nonambig), action);
       } else {
-        fprintf(stderr, _("dpkg: no, %s is essential, will not deconfigure\n"
-                          " it in order to enable %s.\n"),
-                pkg_name(pkg, pnaw_nonambig), action);
+        notice(_("no, %s is essential, will not deconfigure\n"
+                 " it in order to enable %s"),
+               pkg_name(pkg, pnaw_nonambig), action);
         return 0;
       }
     }
     enqueue_deconfigure(pkg, removal);
     return 1;
   } else {
-    fprintf(stderr, _("dpkg: no, cannot proceed with %s (--auto-deconfigure will help):\n%s"),
-            action, why);
+    notice(_("no, cannot proceed with %s (--auto-deconfigure will help):\n%s"),
+           action, why);
     return 0;
   }
 }
@@ -1303,21 +1303,19 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
 
     sprintf(action, _("installation of %.250s"),
             pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
-    fprintf(stderr, _("dpkg: considering deconfiguration of %s,"
-                      " which would be broken by %s ...\n"),
-            pkg_name(fixbydeconf, pnaw_nonambig), action);
+    notice(_("considering deconfiguration of %s, which would be broken by %s ..."),
+           pkg_name(fixbydeconf, pnaw_nonambig), action);
 
     ok= try_deconfigure_can(force_breaks, fixbydeconf, dep->list,
                             action, NULL, why.buf);
     if (ok == 1) {
-      fprintf(stderr, _("dpkg: yes, will deconfigure %s (broken by %s).\n"),
-              pkg_name(fixbydeconf, pnaw_nonambig),
-              pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
+      notice(_("yes, will deconfigure %s (broken by %s)"),
+             pkg_name(fixbydeconf, pnaw_nonambig),
+             pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
     }
   } else {
-    fprintf(stderr, _("dpkg: regarding %s containing %s:\n%s"),
-            pfilename, pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
-            why.buf);
+    notice(_("regarding %s containing %s:\n%s"), pfilename,
+           pkgbin_name(pkg, &pkg->available, pnaw_nonambig), why.buf);
     ok= 0;
   }
   varbuf_destroy(&why);
@@ -1364,15 +1362,14 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
           (!fixbyrm->installed.essential || fc_removeessential)))) {
       assert(fixbyrm->clientdata->istobe == itb_normal || fixbyrm->clientdata->istobe == itb_deconfigure);
       fixbyrm->clientdata->istobe= itb_remove;
-      fprintf(stderr, _("dpkg: considering removing %s in favour of %s ...\n"),
-              pkg_name(fixbyrm, pnaw_nonambig),
-              pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
+      notice(_("considering removing %s in favour of %s ..."),
+             pkg_name(fixbyrm, pnaw_nonambig),
+             pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
       if (!(fixbyrm->status == stat_installed ||
             fixbyrm->status == stat_triggerspending ||
             fixbyrm->status == stat_triggersawaited)) {
-        fprintf(stderr,
-                _("%s is not properly installed - ignoring any dependencies on it.\n"),
-                pkg_name(fixbyrm, pnaw_nonambig));
+        notice(_("%s is not properly installed; ignoring any dependencies on it"),
+               pkg_name(fixbyrm, pnaw_nonambig));
         pdep = NULL;
       } else {
         for (pdep = fixbyrm->set->depended.installed;
@@ -1400,10 +1397,9 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
               if (depisok(pdep->up, &removalwhy, NULL, NULL, false))
                 continue;
               varbuf_end_str(&removalwhy);
-              fprintf(stderr, _("dpkg"
-                      ": may have trouble removing %s, as it provides %s ...\n"),
-                      pkg_name(fixbyrm, pnaw_nonambig),
-                      providecheck->list->ed->name);
+              notice(_("may have trouble removing %s, as it provides %s ..."),
+                     pkg_name(fixbyrm, pnaw_nonambig),
+                     providecheck->list->ed->name);
               if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
                 goto break_from_both_loops_at_once;
             }
@@ -1416,12 +1412,12 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
       }
       if (!pdep && (fixbyrm->eflag & eflag_reinstreq)) {
         if (fc_removereinstreq) {
-          fprintf(stderr, _("dpkg: package %s requires reinstallation, but will"
-                  " remove anyway as you requested.\n"),
-                  pkg_name(fixbyrm, pnaw_nonambig));
+          notice(_("package %s requires reinstallation, but will "
+                   "remove anyway as you requested"),
+                 pkg_name(fixbyrm, pnaw_nonambig));
         } else {
-          fprintf(stderr, _("dpkg: package %s requires reinstallation, "
-                  "will not remove.\n"), pkg_name(fixbyrm, pnaw_nonambig));
+          notice(_("package %s requires reinstallation, will not remove"),
+                 pkg_name(fixbyrm, pnaw_nonambig));
           pdep= &flagdeppossi;
         }
       }
@@ -1429,9 +1425,9 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
         /* This conflict is OK - we'll remove the conflictor. */
         enqueue_conflictor(pkg, fixbyrm);
         varbuf_destroy(&conflictwhy); varbuf_destroy(&removalwhy);
-        fprintf(stderr, _("dpkg: yes, will remove %s in favour of %s.\n"),
-                pkg_name(fixbyrm, pnaw_nonambig),
-                pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
+        notice(_("yes, will remove %s in favour of %s"),
+               pkg_name(fixbyrm, pnaw_nonambig),
+               pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
         return;
       }
       /* Put it back. */
@@ -1439,9 +1435,8 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
     }
   }
   varbuf_end_str(&conflictwhy);
-  fprintf(stderr, _("dpkg: regarding %s containing %s:\n%s"),
-          pfilename, pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
-          conflictwhy.buf);
+  notice(_("regarding %s containing %s:\n%s"), pfilename,
+         pkgbin_name(pkg, &pkg->available, pnaw_nonambig), conflictwhy.buf);
   if (!force_conflicts(dep->list))
     ohshit(_("conflicting packages - not installing %.250s"),
            pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
@@ -1645,10 +1640,9 @@ wanttoinstall(struct pkginfo *pkg)
   } else if (r == 0) {
     /* Same version fully installed. */
     if (f_skipsame) {
-      fprintf(stderr, _("Version %.250s of %.250s already installed, "
-                        "skipping.\n"),
-              versiondescribe(&pkg->installed.version, vdew_nonambig),
-              pkg_name(pkg, pnaw_nonambig));
+      notice(_("version %.250s of %.250s already installed, skipping"),
+             versiondescribe(&pkg->installed.version, vdew_nonambig),
+             pkg_name(pkg, pnaw_nonambig));
       return false;
     } else {
       return true;
@@ -1661,11 +1655,10 @@ wanttoinstall(struct pkginfo *pkg)
               versiondescribe(&pkg->available.version, vdew_nonambig));
       return true;
     } else {
-      fprintf(stderr, _("Will not downgrade %.250s from version %.250s "
-                        "to %.250s, skipping.\n"),
-              pkg_name(pkg, pnaw_nonambig),
-              versiondescribe(&pkg->installed.version, vdew_nonambig),
-              versiondescribe(&pkg->available.version, vdew_nonambig));
+      notice(_("will not downgrade %.250s from %.250s to %.250s, skipping"),
+             pkg_name(pkg, pnaw_nonambig),
+             versiondescribe(&pkg->installed.version, vdew_nonambig),
+             versiondescribe(&pkg->available.version, vdew_nonambig));
       return false;
     }
   }

+ 4 - 6
src/configure.c

@@ -344,16 +344,14 @@ deferred_configure(struct pkginfo *pkg)
 	if (ok == dep_check_halt) {
 		sincenothing = 0;
 		varbuf_end_str(&aemsgs);
-		fprintf(stderr,
-		        _("dpkg: dependency problems prevent configuration of %s:\n%s"),
-		        pkg_name(pkg, pnaw_nonambig), aemsgs.buf);
+		notice(_("dependency problems prevent configuration of %s:\n%s"),
+		       pkg_name(pkg, pnaw_nonambig), aemsgs.buf);
 		varbuf_destroy(&aemsgs);
 		ohshit(_("dependency problems - leaving unconfigured"));
 	} else if (aemsgs.used) {
 		varbuf_end_str(&aemsgs);
-		fprintf(stderr,
-		        _("dpkg: %s: dependency problems, but configuring anyway as you requested:\n%s"),
-		        pkg_name(pkg, pnaw_nonambig), aemsgs.buf);
+		notice(_("%s: dependency problems, but configuring anyway as you requested:\n%s"),
+		       pkg_name(pkg, pnaw_nonambig), aemsgs.buf);
 	}
 	varbuf_destroy(&aemsgs);
 	sincenothing = 0;

+ 1 - 1
src/enquiry.c

@@ -507,7 +507,7 @@ predeppackage(const char *const *argv)
       varbuf_reset(&vb);
       describedepcon(&vb,dep);
       varbuf_end_str(&vb);
-      fprintf(stderr, _("dpkg: cannot see how to satisfy pre-dependency:\n %s\n"),vb.buf);
+      notice(_("cannot see how to satisfy pre-dependency:\n %s"), vb.buf);
       ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to %.250s)"),
              pkgbin_name(dep->up, &dep->up->available, pnaw_nonambig),
              pkgbin_name(startpkg, &startpkg->available, pnaw_nonambig));

+ 6 - 8
src/errors.c

@@ -57,16 +57,14 @@ static struct error_report emergency;
 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_get_progname(), arg, cipaction->olong, emsg);
+  notice(_("error processing %s (--%s):\n %s"), arg, cipaction->olong, emsg);
 
   statusfd_send("status: %s : %s : %s", arg, "error", emsg);
 
   nr= malloc(sizeof(struct error_report));
   if (!nr) {
-    fprintf(stderr,
-            _("%s: failed to allocate memory for new entry in list of failed packages: %s"),
-            dpkg_get_progname(), strerror(errno));
+    notice(_("failed to allocate memory for new entry in list of failed packages: %s"),
+           strerror(errno));
     abort_processing = true;
     nr= &emergency;
   }
@@ -76,7 +74,7 @@ void print_error_perpackage(const char *emsg, const char *arg) {
   lastreport= &nr->next;
 
   if (nerrs++ < errabort) return;
-  fprintf(stderr, _("%s: too many errors, stopping\n"), dpkg_get_progname());
+  notice(_("too many errors, stopping"));
   abort_processing = true;
 }
 
@@ -102,8 +100,8 @@ skip_due_to_hold(struct pkginfo *pkg)
   if (pkg->want != want_hold)
     return false;
   if (fc_hold) {
-    fprintf(stderr, _("Package %s was on hold, processing it anyway as you requested\n"),
-            pkg_name(pkg, pnaw_nonambig));
+    notice(_("package %s was on hold, processing it anyway as you requested"),
+           pkg_name(pkg, pnaw_nonambig));
     return false;
   }
   printf(_("Package %s is on hold, not touching it.  Use --force-hold to override.\n"),

+ 3 - 4
src/packages.c

@@ -416,10 +416,9 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby,
     } else if (!removing && fc_configureany &&
                !skip_due_to_hold(possdependee) &&
                !(possdependee->status == stat_halfconfigured)) {
-      fprintf(stderr,
-              _("dpkg: also configuring `%s' (required by `%s')\n"),
-              pkg_name(possdependee, pnaw_nonambig),
-              pkg_name(requiredby, pnaw_nonambig));
+      notice(_("also configuring '%s' (required by '%s')"),
+             pkg_name(possdependee, pnaw_nonambig),
+             pkg_name(requiredby, pnaw_nonambig));
       add_to_queue(possdependee);
       sincenothing = 0;
       return found_defer;

+ 5 - 6
src/processarc.c

@@ -149,9 +149,8 @@ deb_verify(const char *filename)
       if (!fc_badverify)
         ohshit(_("Verification on package %s failed!"), filename);
       else
-        fprintf(stderr, _("Verification on package %s failed,\n"
-                          "but installing anyway as you requested.\n"),
-                filename);
+        notice(_("verification on package %s failed; "
+                 "but installing anyway as you requested"), filename);
     } else {
       printf(_("passed\n"));
     }
@@ -577,9 +576,9 @@ void process_archive(const char *filename) {
             trigproc(fixbytrigaw->trigaw.head->pend);
         } else {
           varbuf_end_str(&depprobwhy);
-          fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
-                  pfilename, pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
-                  depprobwhy.buf);
+          notice(_("regarding %s containing %s, pre-dependency problem:\n%s"),
+                 pfilename, pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
+                 depprobwhy.buf);
           if (!force_depends(dsearch->list))
             ohshit(_("pre-dependency problem - not installing %.250s"),
                    pkgbin_name(pkg, &pkg->available, pnaw_nonambig));

+ 9 - 11
src/querycmd.c

@@ -262,7 +262,7 @@ listpackages(const char *const *argv)
      * after their super-patterns, due to us skipping on first match. */
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
-        fprintf(stderr, _("No packages found matching %s.\n"), argv[ip]);
+        notice(_("no packages found matching %s"), argv[ip]);
         failures++;
       }
       pkg_spec_destroy(&ps[ip]);
@@ -370,8 +370,7 @@ searchfiles(const char *const *argv)
       files_db_iter_free(iter);
     }
     if (!found) {
-      fprintf(stderr, _("%s: no path found matching pattern %s.\n"),
-              dpkg_get_progname(), thisarg);
+      notice(_("no path found matching pattern %s"), thisarg);
       failures++;
       m_output(stderr, _("<standard error>"));
     } else {
@@ -418,9 +417,8 @@ enqperpackage(const char *const *argv)
           !pkg->files &&
           pkg->want == want_unknown &&
           !pkg_is_informative(pkg, &pkg->installed)) {
-        fprintf(stderr,
-                _("Package `%s' is not installed and no info is available.\n"),
-                pkg_name(pkg, pnaw_nonambig));
+        notice(_("package '%s' is not installed and no information is available"),
+               pkg_name(pkg, pnaw_nonambig));
         failures++;
       } else {
         writerecord(stdout, _("<standard output>"), pkg, &pkg->installed);
@@ -428,8 +426,8 @@ enqperpackage(const char *const *argv)
       break;
     case act_printavail:
       if (!pkg_is_informative(pkg, &pkg->available)) {
-        fprintf(stderr, _("Package `%s' is not available.\n"),
-                pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
+        notice(_("package '%s' is not available"),
+               pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
         failures++;
       } else {
         writerecord(stdout, _("<standard output>"), pkg, &pkg->available);
@@ -438,8 +436,8 @@ enqperpackage(const char *const *argv)
     case act_listfiles:
       switch (pkg->status) {
       case stat_notinstalled:
-        fprintf(stderr, _("Package `%s' is not installed.\n"),
-                pkg_name(pkg, pnaw_nonambig));
+        notice(_("package '%s' is not installed"),
+               pkg_name(pkg, pnaw_nonambig));
         failures++;
         break;
       default:
@@ -551,7 +549,7 @@ showpackages(const char *const *argv)
      * after their super-patterns, due to us skipping on first match. */
     for (ip = 0; ip < argc; ip++) {
       if (!found[ip]) {
-        fprintf(stderr, _("No packages found matching %s.\n"), argv[ip]);
+        notice(_("no packages found matching %s"), argv[ip]);
         failures++;
       }
       pkg_spec_destroy(&ps[ip]);

+ 2 - 4
src/remove.c

@@ -135,14 +135,12 @@ void deferred_remove(struct pkginfo *pkg) {
   } else if (rok == 0) {
     sincenothing= 0;
     varbuf_end_str(&raemsgs);
-    fprintf(stderr,
-            _("dpkg: dependency problems prevent removal of %s:\n%s"),
+    notice(_("dependency problems prevent removal of %s:\n%s"),
             pkg_name(pkg, pnaw_nonambig), raemsgs.buf);
     ohshit(_("dependency problems - not removing"));
   } else if (raemsgs.used) {
     varbuf_end_str(&raemsgs);
-    fprintf(stderr,
-            _("dpkg: %s: dependency problems, but removing anyway as you requested:\n%s"),
+    notice(_("%s: dependency problems, but removing anyway as you requested:\n%s"),
             pkg_name(pkg, pnaw_nonambig), raemsgs.buf);
   }
   varbuf_destroy(&raemsgs);

+ 2 - 3
src/script.c

@@ -311,8 +311,7 @@ maintainer_script_alternative(struct pkginfo *pkg,
 			return 1;
 		}
 	}
-	fprintf(stderr,
-	        _("dpkg - trying script from the new package instead ...\n"));
+	notice(_("trying script from the new package instead ..."));
 
 	strcpy(cidirrest, scriptname);
 	sprintf(buf, _("new %s script"), desc);
@@ -332,7 +331,7 @@ maintainer_script_alternative(struct pkginfo *pkg,
 	}
 
 	do_script(pkg, &pkg->available, &cmd, &stab, 0);
-	fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
+	notice(_("... it looks like that went OK"));
 
 	command_destroy(&cmd);
 	post_script_tasks();

+ 1 - 1
src/select.c

@@ -90,7 +90,7 @@ getselections(const char *const *argv)
         getsel1package(pkg); found++;
       }
       if (!found)
-        fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
+        notice(_("no packages found matching %s"), thisarg);
 
       pkg_spec_destroy(&pkgspec);
     }

+ 2 - 4
src/trigcmd.c

@@ -180,12 +180,10 @@ do_check(void)
 	uf = trigdef_update_start(tduf_nolockok);
 	switch (uf) {
 	case tdus_error_no_dir:
-		fprintf(stderr, _("%s: triggers data directory not yet created\n"),
-		        dpkg_get_progname());
+		notice(_("triggers data directory not yet created"));
 		exit(1);
 	case tdus_error_no_deferred:
-		fprintf(stderr, _("%s: trigger records not yet in existence\n"),
-		        dpkg_get_progname());
+		notice(_("trigger records not yet in existence"));
 		exit(1);
 	case tdus_ok:
 	case tdus_error_empty_deferred:

+ 2 - 3
src/trigproc.c

@@ -259,9 +259,8 @@ check_trigger_cycle(struct pkginfo *processing_now)
 	}
 	/* Oh dear. hare is a superset of tortoise. We are making no
 	 * progress. */
-	fprintf(stderr, _("%s: cycle found while processing triggers:\n chain of"
-	        " packages whose triggers are or may be responsible:\n"),
-	        dpkg_get_progname());
+	notice(_("cycle found while processing triggers:\n"
+	         " chain of packages whose triggers are or may be responsible:"));
 	sep = "  ";
 	for (tcn = tortoise; tcn; tcn = tcn->next) {
 		fprintf(stderr, "%s%s", sep,