The following commit has been merged in the master branch: commit 9fe0a1b16d3045534f7863aed2e35f5177156a15 Author: Guillem Jover <guil...@debian.org> Date: Sat Jul 2 02:00:51 2011 +0200
Use new dpkg_set_progname and dpkg_get_progname instead of thisname The current implementation demanded libdpkg users to define thisname themselves, which is not really a nice interface to offer to programs. Closes: #631757 diff --git a/debian/changelog b/debian/changelog index 2c153dc..e4e9444 100644 --- a/debian/changelog +++ b/debian/changelog @@ -116,6 +116,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low Thanks to Ludovic Brenta <ludo...@ludovic-brenta.org>. Closes: #630533 * Do not fail to unpack shared directories missing on the file system from packages being replaced by other packages. Closes: #631808 + * Do not require programs to define thisname, provide two new functions + to handle the program name (dpkg_set_progname and dpkg_get_progname). + Closes: #631757 [ Bill Allombert] * Add support for Build-Features: build-arch. Closes: #229357 diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index 4512a98..5aa6c4d 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -125,7 +125,6 @@ usage(const struct cmdinfo *cip, const char *value) exit(0); } -const char thisname[]= BACKEND; static const char printforhelp[] = N_("Type dpkg-deb --help for help about manipulating *.deb files;\n" "Type dpkg --help for help about installing and deinstalling packages."); @@ -189,6 +188,7 @@ int main(int argc, const char *const *argv) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname(BACKEND); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/dpkg-split/main.c b/dpkg-split/main.c index e92ba29..c6d956d 100644 --- a/dpkg-split/main.c +++ b/dpkg-split/main.c @@ -100,7 +100,6 @@ usage(const struct cmdinfo *cip, const char *value) exit(0); } -const char thisname[]= SPLITTER; static const char printforhelp[] = N_("Type dpkg-split --help for help."); struct partqueue *queue= NULL; @@ -159,6 +158,7 @@ int main(int argc, const char *const *argv) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname(SPLITTER); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/dselect/main.cc b/dselect/main.cc index 15c86a9..fa58def 100644 --- a/dselect/main.cc +++ b/dselect/main.cc @@ -57,7 +57,6 @@ #include "bindings.h" #include "pkglist.h" -const char thisname[]= DSELECT; static const char printforhelp[] = N_("Type dselect --help for help."); modstatdb_rw readwrite; @@ -514,6 +513,8 @@ main(int, const char *const *argv) bindtextdomain(DSELECT, LOCALEDIR); textdomain(DSELECT); + dpkg_set_progname(DSELECT); + push_error_context_func(dselect_catch_fatal_error, print_fatal_error, 0); loadcfgfile(DSELECT, cmdinfos); diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h index d191233..3bfbd7a 100644 --- a/lib/dpkg/dpkg.h +++ b/lib/dpkg/dpkg.h @@ -98,6 +98,7 @@ DPKG_BEGIN_DECLS #define FIND_EXPRSTARTCHARS "-(),!" +#include <dpkg/progname.h> #include <dpkg/ehandle.h> /*** from startup.c ***/ diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c index f73648d..c2fbd6f 100644 --- a/lib/dpkg/ehandle.c +++ b/lib/dpkg/ehandle.c @@ -31,6 +31,7 @@ #include <dpkg/macros.h> #include <dpkg/i18n.h> +#include <dpkg/progname.h> #include <dpkg/ehandle.h> /* 6x255 for inserted strings (%.255s &c in fmt; and %s with limited length arg) @@ -91,13 +92,13 @@ run_error_handler(void) * abort. Hopefully the user can fix the situation (out of disk, out * of memory, etc). */ fprintf(stderr, _("%s: unrecoverable fatal error, aborting:\n %s\n"), - thisname, errmsg); + dpkg_get_progname(), errmsg); exit(2); } if (econtext == NULL) { fprintf(stderr, _("%s: outside error context, aborting:\n %s\n"), - thisname, errmsg); + dpkg_get_progname(), errmsg); exit(2); } else if (econtext->handler_type == handler_type_func) { econtext->handler.func(); @@ -179,7 +180,8 @@ push_error_context(void) static void print_cleanup_error(const char *emsg, const char *contextstring) { - fprintf(stderr, _("%s: error while cleaning up:\n %s\n"),thisname,emsg); + fprintf(stderr, _("%s: error while cleaning up:\n %s\n"), + dpkg_get_progname(), emsg); } static void @@ -197,7 +199,7 @@ run_cleanups(struct error_context *econ, int flagsetin) if (++preventrecurse > 3) { onerr_abort++; fprintf(stderr, _("%s: too many nested errors during error recovery!!\n"), - thisname); + dpkg_get_progname()); flagset= 0; } else { flagset= flagsetin; @@ -347,7 +349,7 @@ catch_fatal_error(void) void print_fatal_error(const char *emsg, const char *contextstring) { - fprintf(stderr, _("%s: error: %s\n"), thisname, emsg); + fprintf(stderr, _("%s: error: %s\n"), dpkg_get_progname(), emsg); } void @@ -388,7 +390,7 @@ warningv(const char *fmt, va_list args) warn_count++; vsnprintf(buf, sizeof(buf), fmt, args); - fprintf(stderr, _("%s: warning: %s\n"), thisname, buf); + fprintf(stderr, _("%s: warning: %s\n"), dpkg_get_progname(), buf); } void @@ -412,7 +414,7 @@ do_internerr(const char *file, int line, const char *fmt, ...) va_end(args); fprintf(stderr, _("%s:%s:%d: internal error: %s\n"), - thisname, file, line, buf); + dpkg_get_progname(), file, line, buf); abort(); } diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h index ff0a66e..b450647 100644 --- a/lib/dpkg/ehandle.h +++ b/lib/dpkg/ehandle.h @@ -30,9 +30,6 @@ DPKG_BEGIN_DECLS -/* Defined separately in each program. */ -extern const char thisname[]; - extern volatile int onerr_abort; enum { diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions index b035276..8dbd7a5 100644 --- a/lib/dpkg/libdpkg.Versions +++ b/lib/dpkg/libdpkg.Versions @@ -138,7 +138,6 @@ LIBDPKG_PRIVATE { loadcfgfile; myopt; badusage; - # thisname; # XXX variable, do not require external cipaction; # XXX variable, do not export setaction; setobsolete; diff --git a/lib/dpkg/subproc.c b/lib/dpkg/subproc.c index 71fe734..4b9c1e5 100644 --- a/lib/dpkg/subproc.c +++ b/lib/dpkg/subproc.c @@ -74,7 +74,7 @@ subproc_signals_cleanup(int argc, void **argv) static void print_subproc_error(const char *emsg, const char *contextstring) { - fprintf(stderr, _("%s (subprocess): %s\n"), thisname, emsg); + fprintf(stderr, _("%s (subprocess): %s\n"), dpkg_get_progname(), emsg); } pid_t diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h index 4e7dc31..17342fd 100644 --- a/lib/dpkg/test.h +++ b/lib/dpkg/test.h @@ -38,8 +38,6 @@ #ifndef TEST_MAIN_PROVIDED static void test(void); -const char thisname[] = "test"; - int main(int argc, char **argv) { diff --git a/src/divertcmd.c b/src/divertcmd.c index d88ecd0..595e25a 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -46,7 +46,6 @@ #include "filesdb.h" -const char thisname[] = "dpkg-divert"; static const char printforhelp[] = N_( "Use --help for help about querying packages."); @@ -64,7 +63,8 @@ static int opt_rename = 0; static void printversion(const struct cmdinfo *cip, const char *value) { - printf(_("Debian %s version %s.\n"), thisname, DPKG_VERSION_ARCH); + printf(_("Debian %s version %s.\n"), dpkg_get_progname(), + DPKG_VERSION_ARCH); printf(_( "Copyright (C) 1995 Ian Jackson.\n" @@ -85,7 +85,7 @@ usage(const struct cmdinfo *cip, const char *value) { printf(_( "Usage: %s [<option> ...] <command>\n" -"\n"), thisname); +"\n"), dpkg_get_progname()); printf(_( "Commands:\n" @@ -698,6 +698,7 @@ main(int argc, const char * const *argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname("dpkg-divert"); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/src/errors.c b/src/errors.c index c715031..f016910 100644 --- a/src/errors.c +++ b/src/errors.c @@ -58,7 +58,7 @@ void print_error_perpackage(const char *emsg, const char *arg) { struct error_report *nr; fprintf(stderr, _("%s: error processing %s (--%s):\n %s\n"), - thisname, arg, cipaction->olong, emsg); + dpkg_get_progname(), arg, cipaction->olong, emsg); statusfd_send("status: %s : %s : %s", arg, "error", emsg); @@ -66,7 +66,7 @@ void print_error_perpackage(const char *emsg, const char *arg) { if (!nr) { fprintf(stderr, _("%s: failed to allocate memory for new entry in list of failed packages: %s"), - thisname, strerror(errno)); + dpkg_get_progname(), strerror(errno)); abort_processing = true; nr= &emergency; } @@ -76,7 +76,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"), thisname); + fprintf(stderr, _("%s: too many errors, stopping\n"), dpkg_get_progname()); abort_processing = true; } diff --git a/src/main.c b/src/main.c index fbda5f1..d3e7d25 100644 --- a/src/main.c +++ b/src/main.c @@ -165,7 +165,6 @@ usage(const struct cmdinfo *ci, const char *value) exit(0); } -const char thisname[]= "dpkg"; const char native_arch[] = ARCHITECTURE; static const char printforhelp[] = N_( "Type dpkg --help for help about installing and deinstalling packages [*];\n" @@ -734,6 +733,7 @@ int main(int argc, const char *const *argv) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname("dpkg"); standard_startup(); loadcfgfile(DPKG, cmdinfos); myopt(&argv, cmdinfos, printforhelp); diff --git a/src/querycmd.c b/src/querycmd.c index cb512ae..71855e4 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -347,8 +347,8 @@ searchfiles(const char *const *argv) iterfileend(it); } if (!found) { - fprintf(stderr, _("%s: no path found matching pattern %s.\n"), thisname, - thisarg); + fprintf(stderr, _("%s: no path found matching pattern %s.\n"), + dpkg_get_progname(), thisarg); failures++; m_output(stderr, _("<standard error>")); } else { @@ -652,7 +652,6 @@ usage(const struct cmdinfo *ci, const char *value) exit(0); } -const char thisname[]= "dpkg-query"; static const char printforhelp[] = N_( "Use --help for help about querying packages."); @@ -684,6 +683,7 @@ int main(int argc, const char *const *argv) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname("dpkg-query"); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/src/statcmd.c b/src/statcmd.c index 55ac07a..fcbbba0 100644 --- a/src/statcmd.c +++ b/src/statcmd.c @@ -48,14 +48,14 @@ #include "main.h" #include "filesdb.h" -const char thisname[] = "dpkg-statoverride"; static const char printforhelp[] = N_( "Use --help for help about querying packages."); static void DPKG_ATTR_NORET printversion(const struct cmdinfo *cip, const char *value) { - printf(_("Debian %s version %s.\n"), thisname, DPKG_VERSION_ARCH); + printf(_("Debian %s version %s.\n"), dpkg_get_progname(), + DPKG_VERSION_ARCH); printf(_( "Copyright (C) 2000, 2001 Wichert Akkerman.\n" @@ -75,7 +75,7 @@ usage(const struct cmdinfo *cip, const char *value) { printf(_( "Usage: %s [<option> ...] <command>\n" -"\n"), thisname); +"\n"), dpkg_get_progname()); printf(_( "Commands:\n" @@ -369,6 +369,7 @@ main(int argc, const char *const *argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname("dpkg-statoverride"); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/src/trigcmd.c b/src/trigcmd.c index 2f27188..4c42044 100644 --- a/src/trigcmd.c +++ b/src/trigcmd.c @@ -42,8 +42,6 @@ #include <dpkg/trigdeferred.h> #include <dpkg/triglib.h> -const char thisname[] = "dpkg-trigger"; - static const char printforhelp[] = N_( "Type dpkg-trigger --help for help about this utility."); @@ -51,7 +49,7 @@ static void DPKG_ATTR_NORET printversion(const struct cmdinfo *ci, const char *value) { printf(_("Debian %s package trigger utility version %s.\n"), - thisname, DPKG_VERSION_ARCH); + dpkg_get_progname(), DPKG_VERSION_ARCH); printf(_( "This is free software; see the GNU General Public License version 2 or\n" @@ -68,7 +66,7 @@ usage(const struct cmdinfo *ci, const char *value) printf(_( "Usage: %s [<options> ...] <trigger-name>\n" " %s [<options> ...] <command>\n" -"\n"), thisname, thisname); +"\n"), dpkg_get_progname(), dpkg_get_progname()); printf(_( "Commands:\n" @@ -152,11 +150,11 @@ do_check(void) switch (uf) { case tdus_error_no_dir: fprintf(stderr, _("%s: triggers data directory not yet created\n"), - thisname); + dpkg_get_progname()); exit(1); case tdus_error_no_deferred: fprintf(stderr, _("%s: trigger records not yet in existence\n"), - thisname); + dpkg_get_progname()); exit(1); case tdus_ok: case tdus_error_empty_deferred: @@ -188,6 +186,7 @@ main(int argc, const char *const *argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + dpkg_set_progname("dpkg-trigger"); standard_startup(); myopt(&argv, cmdinfos, printforhelp); diff --git a/src/trigproc.c b/src/trigproc.c index 506f798..862740b 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -249,7 +249,7 @@ check_trigger_cycle(struct pkginfo *processing_now) * progress. */ fprintf(stderr, _("%s: cycle found while processing triggers:\n chain of" " packages whose triggers are or may be responsible:\n"), - thisname); + dpkg_get_progname()); sep = " "; for (tcn = tortoise; tcn; tcn = tcn->next) { fprintf(stderr, "%s%s", sep, tcn->then_processed->name); -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org