The following commit has been merged in the master branch:
commit b56f46bba29e6a369105d75428ceffc3b79de346
Author: Guillem Jover <[EMAIL PROTECTED]>
Date: Fri Dec 5 08:11:59 2008 +0200
Use the warning function instead of hand-coded print calls
diff --git a/ChangeLog b/ChangeLog
index b88bc59..3d5576b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2008-12-05 Guillem Jover <[EMAIL PROTECTED]>
+ * lib/ehandle.c (warning): Print the current program name and a
+ 'warning' string.
+ * lib/mlib.c (checksubprocerr): Use warning() instead of a print
+ function.
+ * src/archives.c (try_deconfigure_can): Likewise.
+ (check_breaks): Likewise.
+ (check_conflict): Likewise.
+ (wanttoinstall): Likewise.
+ * src/configure.c (deferred_configure): Likewise.
+ (conffderef): Likewise.
+ (md5hash): Likewise.
+ * src/errors.c (forcibleerr): Likewise.
+ * src/filesdb.c (ensure_packagefiles_available): Likewise.
+ * src/help.c (maintainer_script_alternative): Likewise.
+ * src/processarc.c (process_archive): Likewise.
+ * src/remove.c (deferred_remove): Likewise.
+ (removal_bulk_remove_leftover_dirs): Likewise.
+ * dpkg-deb/build.c (do_build): Likewise.
+
+2008-12-05 Guillem Jover <[EMAIL PROTECTED]>
+
* lib/ehandle.c (warning): Do not implicitly print the errno string.
* lib/myopt.c (myfileopt): Print the errno string in the warning.
diff --git a/debian/changelog b/debian/changelog
index 56e8b7e..40320c4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -36,6 +36,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low
* Use a troff special character for the copyright symbol on man pages.
* Mark program names in dpkg-trigger.1 in bold.
* Unmark dselect debug messages for translation.
+ * Use a the warning function to uniformly print all warning messages.
[ Raphael Hertzog ]
* Enhance dpkg-shlibdeps's error message when a library can't be found to
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 458361b..cea3303 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -225,8 +225,8 @@ void do_build(const char *const *argv) {
if (nocheckflag) {
if (subdir)
ohshit(_("target is directory - cannot skip control file check"));
- printf(_("dpkg-deb: warning, not checking contents of control area.\n"
- "dpkg-deb: building an unknown package in `%s'.\n"), debar);
+ warning(_("not checking contents of control area."));
+ printf(_("dpkg-deb: building an unknown package in '%s'.\n"), debar);
} else {
controlfile= m_malloc(strlen(directory) + sizeof(BUILDCONTROLDIR) +
sizeof(CONTROLFILE) + sizeof(CONFFILESFILE) +
@@ -245,7 +245,7 @@ void do_build(const char *const *argv) {
!= strlen(checkedinfo->name))
ohshit(_("package name has characters that aren't lowercase alphanums or
`-+.'"));
if (checkedinfo->priority == pri_other) {
- fprintf(stderr, _("warning, `%s' contains user-defined Priority value
`%s'\n"),
+ warning(_("'%s' contains user-defined Priority value '%s'"),
controlfile, checkedinfo->otherpriority);
warns++;
}
@@ -253,7 +253,7 @@ void do_build(const char *const *argv) {
if (known_arbitrary_field(field))
continue;
- fprintf(stderr, _("warning, `%s' contains user-defined field `%s'\n"),
+ warning(_("'%s' contains user-defined field '%s'"),
controlfile, field->name);
warns++;
}
@@ -307,7 +307,7 @@ void do_build(const char *const *argv) {
n= strlen(conffilename);
if (!n) ohshite(_("empty string from fgets reading conffiles"));
if (conffilename[n-1] != '\n') {
- fprintf(stderr, _("warning, conffile name `%.50s...' is too long, or
missing final newline\n"),
+ warning(_("conffile name '%.50s...' is too long, or missing final
newline"),
conffilename);
warns++;
while ((c= getc(cf)) != EOF && c != '\n');
@@ -320,14 +320,13 @@ void do_build(const char *const *argv) {
if (lstat(controlfile,&controlstab)) {
if (errno == ENOENT) {
if((n > 1) && isspace(conffilename[n-2]))
- fprintf(stderr, _("warning, "
- "conffile filename `%s' contains trailing white
spaces\n"), conffilename);
+ warning(_("conffile filename '%s' contains trailing white
spaces"),
+ conffilename);
ohshit(_("conffile `%.250s' does not appear in package"),
conffilename);
} else
ohshite(_("conffile `%.250s' is not stattable"), conffilename);
} else if (!S_ISREG(controlstab.st_mode)) {
- fprintf(stderr, _("warning, conffile `%s'"
- " is not a plain file\n"), conffilename);
+ warning(_("conffile '%s' is not a plain file"), conffilename);
warns++;
}
}
diff --git a/lib/ehandle.c b/lib/ehandle.c
index ec963b3..84f510c 100644
--- a/lib/ehandle.c
+++ b/lib/ehandle.c
@@ -299,7 +299,7 @@ warning(const char *fmt, ...)
vsnprintf(buf,sizeof(buf),fmt,al);
va_end(al);
- fprintf(stderr, "%s\n", buf);
+ fprintf(stderr, _("%s: warning: %s\n"), thisname, buf);
}
void badusage(const char *fmt, ...) {
diff --git a/lib/mlib.c b/lib/mlib.c
index 9fde251..2d7136e 100644
--- a/lib/mlib.c
+++ b/lib/mlib.c
@@ -125,14 +125,13 @@ int checksubprocerr(int status, const char *description,
int flags) {
if (flags & PROCNOERR)
return -1;
if (flags & PROCWARN)
- fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),
- description, n);
+ warning(_("%s returned error exit status %d"), description, n);
else
ohshit(_("subprocess %s returned error exit status %d"), description, n);
} else if (WIFSIGNALED(status)) {
n= WTERMSIG(status); if (!n || ((flags & PROCPIPE) && n==SIGPIPE)) return
0;
if (flags & PROCWARN)
- fprintf(stderr, _("dpkg: warning - %s killed by signal (%s)%s\n"),
+ warning(_("%s killed by signal (%s)%s"),
description, strsignal(n), WCOREDUMP(status) ? _(", core
dumped") : "");
else
ohshit(_("subprocess %s killed by signal (%s)%s"),
diff --git a/src/archives.c b/src/archives.c
index 9f9e3a1..80f2d80 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -876,16 +876,13 @@ static int try_deconfigure_can(int (*force_p)(struct
deppossi*),
struct pkg_deconf_list *newdeconf;
if (force_p && force_p(pdep)) {
- fprintf(stderr, _("dpkg: warning - "
- "ignoring dependency problem with %s:\n%s"),
- action, why);
+ warning(_("ignoring dependency problem with %s:\n%s"), action, why);
return 2;
} else if (f_autodeconf) {
if (pkg->installed.essential) {
if (fc_removeessential) {
- fprintf(stderr, _("dpkg: warning - considering deconfiguration of
essential\n"
- " package %s, to enable %s.\n"),
- pkg->name, action);
+ warning(_("considering deconfiguration of essential\n"
+ " package %s, to enable %s."), pkg->name, action);
} else {
fprintf(stderr, _("dpkg: no, %s is essential, will not deconfigure\n"
" it in order to enable %s.\n"),
@@ -956,8 +953,7 @@ void check_breaks(struct dependency *dep, struct pkginfo
*pkg,
if (ok > 0) return;
if (force_breaks(dep->list)) {
- fprintf(stderr, _("dpkg: warning - ignoring breakage,"
- " may proceed anyway !\n"));
+ warning(_("ignoring breakage, may proceed anyway!"));
return;
}
@@ -1074,7 +1070,7 @@ void check_conflict(struct dependency *dep, struct
pkginfo *pkg,
pfilename, pkg->name, conflictwhy.buf);
if (!force_conflicts(dep->list))
ohshit(_("conflicting packages - not installing %.250s"),pkg->name);
- fprintf(stderr, _("dpkg: warning - ignoring conflict, may proceed anyway
!\n"));
+ warning(_("ignoring conflict, may proceed anyway!"));
varbuffree(&conflictwhy);
return;
@@ -1287,8 +1283,8 @@ int wanttoinstall(struct pkginfo *pkg, const struct
versionrevision *ver, int sa
}
} else {
if (fc_downgrade) {
- if (saywhy) fprintf(stderr, _("%s - warning: downgrading %.250s "
- "from %.250s to %.250s.\n"), DPKG, pkg->name,
+ if (saywhy)
+ warning(_("downgrading %.250s from %.250s to %.250s."), pkg->name,
versiondescribe(&pkg->installed.version, vdew_nonambig),
versiondescribe(&pkg->available.version, vdew_nonambig));
return 1;
diff --git a/src/configure.c b/src/configure.c
index c57f947..65744ba 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -251,44 +251,38 @@ void deferred_configure(struct pkginfo *pkg) {
case cfo_keep | cfof_backup:
strcpy(cdr2rest,DPKGOLDEXT);
if (unlink(cdr2.buf) && errno != ENOENT)
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to remove old backup `%.250s': %s\n"),
- pkg->name,
cdr2.buf, strerror(errno));
+ warning(_("%s: failed to remove
old backup '%.250s': %s"),
+ pkg->name, cdr2.buf,
strerror(errno));
cdr.used--;
varbufaddstr(&cdr,DPKGDISTEXT);
varbufaddc(&cdr,0);
strcpy(cdr2rest,DPKGNEWEXT);
trig_file_activate(usenode, pkg);
if (rename(cdr2.buf,cdr.buf))
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to rename `%.250s' to `%.250s': %s\n"),
- pkg->name,
cdr2.buf, cdr.buf, strerror(errno));
+ warning(_("%s: failed to rename
'%.250s' to '%.250s': %s"),
+ pkg->name, cdr2.buf,
cdr.buf, strerror(errno));
break;
case cfo_keep:
strcpy(cdr2rest,DPKGNEWEXT);
if (unlink(cdr2.buf))
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to remove `%.250s': %s\n"),
- pkg->name,
cdr2.buf, strerror(errno));
+ warning(_("%s: failed to remove
'%.250s': %s"),
+ pkg->name, cdr2.buf,
strerror(errno));
break;
case cfo_install | cfof_backup:
strcpy(cdr2rest,DPKGDISTEXT);
if (unlink(cdr2.buf) && errno != ENOENT)
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to remove old distrib version `%.250s': %s\n"),
- pkg->name,
cdr2.buf, strerror(errno));
+ warning(_("%s: failed to remove
old distrib version '%.250s': %s"),
+ pkg->name, cdr2.buf,
strerror(errno));
strcpy(cdr2rest,DPKGOLDEXT);
if (unlink(cdr2.buf) && errno != ENOENT)
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to remove `%.250s' (before overwrite): %s\n"),
- pkg->name,
cdr2.buf, strerror(errno));
+ warning(_("%s: failed to remove
'%.250s' (before overwrite): %s"),
+ pkg->name, cdr2.buf,
strerror(errno));
if (!(what & cfof_userrmd))
if (link(cdr.buf,cdr2.buf))
- fprintf(stderr,
- _("dpkg: %s:
warning - failed to link `%.250s' to `%.250s': %s\n"),
- pkg->name,
cdr.buf, cdr2.buf, strerror(errno));
+ warning(_("%s: failed
to link '%.250s' to '%.250s': %s"),
+ pkg->name,
cdr.buf, cdr2.buf, strerror(errno));
/* fall through */
case cfo_install:
printf(_("Installing new version of
config file %s ...\n"),
@@ -354,9 +348,9 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
debug(dbg_conffdetail,"conffderef in=`%s' current
working=`%s'", in, result->buf);
if (lstat(result->buf,&stab)) {
if (errno != ENOENT)
- fprintf(stderr, _("dpkg: %s: warning - unable
to stat config file `%s'\n"
- " (= `%s'): %s\n"),
- pkg->name, in, result->buf,
strerror(errno));
+ warning(_("%s: unable to stat config file
'%s'\n"
+ " (= '%s'): %s"),
+ pkg->name, in, result->buf,
strerror(errno));
debug(dbg_conffdetail,"conffderef nonexistent");
return 0;
} else if (S_ISREG(stab.st_mode)) {
@@ -365,8 +359,8 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
} else if (S_ISLNK(stab.st_mode)) {
debug(dbg_conffdetail,"conffderef symlink
loopprotect=%d",loopprotect);
if (loopprotect++ >= 25) {
- fprintf(stderr, _("dpkg: %s: warning - config
file `%s' is a circular link\n"
- " (= `%s')\n"),
pkg->name, in, result->buf);
+ warning(_("%s: config file '%s' is a circular
link\n"
+ " (= '%s')"), pkg->name, in,
result->buf);
return -1;
}
need= 255;
@@ -378,9 +372,9 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
}
r=
readlink(result->buf,linkreadbuf,linkreadbufsize-1);
if (r < 0) {
- fprintf(stderr, _("dpkg: %s: warning -
unable to readlink conffile `%s'\n"
- " (= `%s'):
%s\n"),
- pkg->name, in,
result->buf, strerror(errno));
+ warning(_("%s: unable to readlink
conffile '%s'\n"
+ " (= '%s'): %s"),
+ pkg->name, in, result->buf,
strerror(errno));
return -1;
}
debug(dbg_conffdetail,"conffderef readlink gave
%d, `%.*s'",
@@ -397,10 +391,9 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
for (r=result->used-2; r>0 && result->buf[r] !=
'/'; r--)
;
if (r < 0) {
- fprintf(stderr,
- _("dpkg: %s: warning -
conffile `%.250s' resolves to degenerate filename\n"
- " (`%s' is a
symlink to `%s')\n"),
- pkg->name, in,
result->buf, linkreadbuf);
+ warning(_("%s: conffile '%.250s'
resolves to degenerate filename\n"
+ " ('%s' is a symlink to
'%s')"),
+ pkg->name, in, result->buf,
linkreadbuf);
return -1;
}
if (result->buf[r] == '/') r++;
@@ -411,9 +404,8 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
varbufaddstr(result,linkreadbuf);
varbufaddc(result,0);
} else {
- fprintf(stderr, _("dpkg: %s: warning - conffile
`%.250s' is not a plain"
- " file or symlink (= `%s')\n"),
- pkg->name, in, result->buf);
+ warning(_("%s: conffile '%.250s' is not a plain file or
symlink (= '%s')"),
+ pkg->name, in, result->buf);
return -1;
}
}
@@ -435,8 +427,8 @@ static void md5hash(struct pkginfo *pkg, char **hashbuf,
const char *fn) {
} else if (errno==ENOENT) {
*hashbuf = m_strdup(NONEXISTENTFLAG);
} else {
- fprintf(stderr, _("dpkg: %s: warning - unable to open conffile
%s for hash: %s\n"),
- pkg->name, fn, strerror(errno));
+ warning(_("%s: unable to open conffile %s for hash: %s"),
+ pkg->name, fn, strerror(errno));
*hashbuf = m_strdup("-");
}
}
diff --git a/src/errors.c b/src/errors.c
index 456f58f..c6bd958 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -109,7 +109,8 @@ void forcibleerr(int forceflag, const char *fmt, ...) {
va_list al;
va_start(al,fmt);
if (forceflag) {
- fputs(_("dpkg - warning, overriding problem because --force enabled:\n
"),stderr);
+ warning(_("overriding problem because --force enabled:"));
+ fputc(' ', stderr);
vfprintf(stderr,fmt,al);
fputc('\n',stderr);
} else {
diff --git a/src/filesdb.c b/src/filesdb.c
index 888daa3..11a4304 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -141,9 +141,8 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
onerr_abort--;
if (pkg->status != stat_configfiles) {
if (saidread == 1) putc('\n',stderr);
- fprintf(stderr,
- _("dpkg: serious warning: files list file for package `%.250s'
missing,"
- " assuming package has no files currently installed.\n"),
pkg->name);
+ warning(_("files list file for package `%.250s' missing, assuming "
+ "package has no files currently installed."), pkg->name);
}
pkg->clientdata->files = NULL;
pkg->clientdata->fileslistvalid= 1;
diff --git a/src/help.c b/src/help.c
index ce7ed5c..d7d0ae9 100644
--- a/src/help.c
+++ b/src/help.c
@@ -380,8 +380,7 @@ int maintainer_script_alternative(struct pkginfo *pkg,
scriptname,oldscriptpath);
return 0;
}
- fprintf(stderr,
- _("dpkg: warning - unable to stat %s `%.250s': %s\n"),
+ warning(_("unable to stat %s '%.250s': %s"),
buf,oldscriptpath,strerror(errno));
} else {
if (!do_script(pkg->name, scriptname, oldscriptpath, &stab, arglist,
diff --git a/src/processarc.c b/src/processarc.c
index c8c8f8b..9ecf71c 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -275,7 +275,7 @@ void process_archive(const char *filename) {
pfilename, pkg->name, depprobwhy.buf);
if (!force_depends(dsearch->list))
ohshit(_("pre-dependency problem - not installing
%.250s"),pkg->name);
- fprintf(stderr, _("dpkg: warning - ignoring pre-dependency problem
!\n"));
+ warning(_("ignoring pre-dependency problem!"));
}
}
}
@@ -656,22 +656,17 @@ void process_archive(const char *filename) {
if (lstat(fnamevb.buf, &oldfs)) {
if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
- fprintf(stderr,
- _("dpkg: warning - could not stat old file `%.250s'"
- " so not deleting it: %s"),
- fnamevb.buf, strerror(errno));
+ warning(_("could not stat old file '%.250s' so not deleting it: %s"),
+ fnamevb.buf, strerror(errno));
continue;
}
if (S_ISDIR(oldfs.st_mode)) {
if (rmdir(fnamevb.buf)) {
- fprintf(stderr,
- _("dpkg: warning - unable to delete old directory"
- " `%.250s': %s\n"), namenode->name, strerror(errno));
+ warning(_("unable to delete old directory '%.250s': %s"),
+ namenode->name, strerror(errno));
} else if ((namenode->flags & fnnf_old_conff)) {
- fprintf(stderr,
- _("dpkg: warning - old conffile `%.250s' was an empty"
- " directory (and has now been deleted)\n"),
- namenode->name);
+ warning(_("old conffile '%.250s' was an empty directory "
+ "(and has now been deleted)"), namenode->name);
}
} else {
/* Ok, it's an old file, but is it really not in the new package?
@@ -723,9 +718,8 @@ void process_archive(const char *filename) {
if (oldfs.st_dev == cfile->namenode->filestat->st_dev &&
oldfs.st_ino == cfile->namenode->filestat->st_ino) {
if (sameas)
- fprintf(stderr, _("dpkg: warning - old file `%.250s' is the same"
- " as several new files! (both `%.250s' and `%.250s')\n"),
- fnamevb.buf,
+ warning(_("old file '%.250s' is the same as several new files! "
+ "(both '%.250s' and '%.250s')"), fnamevb.buf,
sameas->namenode->name, cfile->namenode->name);
sameas= cfile;
debug(dbg_eachfile, "process_archive: not removing %s,"
@@ -766,7 +760,7 @@ void process_archive(const char *filename) {
if (chmodsafe_unlink_statted(fnamevb.buf, &oldfs, &failed)) {
const char *failed_local = gettext(failed);
- fprintf(stderr, _("dpkg: warning - unable to %s old file '%.250s':
%s\n"),
+ warning(_("unable to %s old file '%.250s': %s"),
failed_local, namenode->name, strerror(errno));
}
@@ -858,8 +852,7 @@ void process_archive(const char *filename) {
continue; /* ignore the control file */
}
if (!strcmp(de->d_name,LISTFILE)) {
- fprintf(stderr, _("dpkg: warning - package %s"
- " contained list as info file"), pkg->name);
+ warning(_("package %s contained list as info file"), pkg->name);
continue;
}
/* Right, install it */
diff --git a/src/remove.c b/src/remove.c
index f19c6c0..ce3c43b 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -80,17 +80,15 @@ void deferred_remove(struct pkginfo *pkg) {
debug(dbg_general,"deferred_remove package %s",pkg->name);
if (pkg->status == stat_notinstalled) {
- fprintf(stderr,
- _("dpkg - warning: ignoring request to remove %.250s which isn't
installed.\n"),
+ warning(_("ignoring request to remove %.250s which isn't installed."),
pkg->name);
pkg->clientdata->istobe= itb_normal;
return;
} else if (!f_pending &&
pkg->status == stat_configfiles &&
cipaction->arg != act_purge) {
- fprintf(stderr,
- _("dpkg - warning: ignoring request to remove %.250s, only the
config\n"
- " files of which are on the system. Use --purge to remove them
too.\n"),
+ warning(_("ignoring request to remove %.250s, only the config\n"
+ " files of which are on the system. Use --purge to remove them
too."),
pkg->name);
pkg->clientdata->istobe= itb_normal;
return;
@@ -253,9 +251,8 @@ static void removal_bulk_remove_files(
push_leftover(&leftover,namenode);
continue;
} else if (errno == EBUSY || errno == EPERM) {
- fprintf(stderr, _("dpkg - warning: while removing %.250s,"
- " unable to remove directory `%.250s':"
- " %s - directory may be a mount point ?\n"),
+ warning(_("while removing %.250s, unable to remove directory '%.250s':
"
+ "%s - directory may be a mount point?"),
pkg->name, namenode->name, strerror(errno));
push_leftover(&leftover,namenode);
continue;
@@ -368,16 +365,13 @@ static void removal_bulk_remove_leftover_dirs(struct
pkginfo *pkg) {
debug(dbg_eachfiledetail, "removal_bulk removing `%s'", fnvb.buf);
if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
if (errno == ENOTEMPTY || errno == EEXIST) {
- fprintf(stderr,
- _("dpkg - warning: while removing %.250s, directory `%.250s' not
empty "
- "so not removed.\n"),
+ warning(_("while removing %.250s, directory '%.250s' not empty so not
removed."),
pkg->name, namenode->name);
push_leftover(&leftover,namenode);
continue;
} else if (errno == EBUSY || errno == EPERM) {
- fprintf(stderr, _("dpkg - warning: while removing %.250s,"
- " unable to remove directory `%.250s':"
- " %s - directory may be a mount point ?\n"),
+ warning(_("while removing %.250s, unable to remove directory '%.250s': "
+ "%s - directory may be a mount point?"),
pkg->name, namenode->name, strerror(errno));
push_leftover(&leftover,namenode);
continue;
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]