Date: Mon, 22 Mar 2010 09:39:43 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 175931 for review Message-ID: <201003220939.o2M9dhCx095192@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=175931 Change 175931 by gcooper@gcooper-bayonetta on 2010/03/22 09:39:43 Commit local change for bin/121165, s.t. the error message from find_play_pen makes more sense when the install fails (the command used, e.g. pkg_add(1), pkg_info(1), etc is now prefixed to all failures in lib/pen.c). Affected files ... .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/main.c#3 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/main.c#2 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/main.c#2 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/info/main.c#2 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/lib.h#2 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/pen.c#4 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/main.c#2 edit Differences ... ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/main.c#3 (text+ko) ==== @@ -50,6 +50,8 @@ char **pkgs; +char *progname = NULL; + struct { int lowver; /* Lowest version number to match */ int hiver; /* Highest version number to match */ @@ -128,9 +130,12 @@ static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; - if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) - PkgAddCmd = realpath(argv[0], pkgaddpath); - else + if ((progname = basename(argv[0])) == NULL) + err(EXIT_FAILURE, "basename"); + if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) { + if ((PkgAddCmd = realpath(argv[0], pkgaddpath)) == NULL) + err(EXIT_FAILURE, "realpath"); + } else PkgAddCmd = argv[0]; start = argv; ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/main.c#2 (text+ko) ==== @@ -45,6 +45,7 @@ int Help = FALSE; enum zipper Zipper = BZIP2; +char *progname = NULL; static void usage(void); @@ -72,6 +73,8 @@ int ch; char **pkgs, **start, *tmp; + if ((progname = basename(argv[0])) == NULL) + err(EXIT_FAILURE, "basename"); pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/main.c#2 (text+ko) ==== @@ -37,6 +37,8 @@ Boolean Recursive = FALSE; match_t MatchType = MATCH_GLOB; +char *progname = NULL; + static void usage(void); static char opts[] = "adDfGhinp:rvxX"; @@ -67,6 +69,8 @@ const char *tmp; struct stat stat_s; + if ((progname = basename(argv[0])) == NULL) + err(EXIT_FAILURE, "basename"); pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/info/main.c#2 (text+ko) ==== @@ -39,6 +39,8 @@ Boolean KeepPackage = FALSE; struct which_head *whead; +char *progname = NULL; + static void usage(void); static char opts[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX"; @@ -73,6 +75,8 @@ err(2, NULL); TAILQ_INIT(whead); + if ((progname = basename(argv[0])) == NULL) + err(EXIT_FAILURE, "basename"); pkgs = start = argv; if (argc == 1) { MatchType = MATCH_ALL; ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/lib.h#2 (text+ko) ==== @@ -30,6 +30,8 @@ #include <sys/queue.h> #include <ctype.h> #include <dirent.h> +#include <err.h> +#include <libgen.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -239,9 +241,10 @@ int version_cmp(const char *, const char *); /* Externs */ +extern char *progname; extern Boolean Quiet; extern Boolean Fake; -extern Boolean Force; +extern Boolean Force; extern int AutoAnswer; extern int Verbose; ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/pen.c#4 (text+ko) ==== @@ -62,10 +62,11 @@ cleanup(0); humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE, HN_NOSPACE); - errx(2, -"%s: can't find enough temporary space to extract the files, please set your\n" -"PKG_TMPDIR environment variable to a location with at least %s bytes\n" -"free", __func__, humbuf); + /* XXX: Maintain 80 column width in the error message. */ + errx(EXIT_FAILURE, + "%s.%s: not enough temporary space to extract the files; set PKG_TMPDIR in\n" + "your environment to a location with at least %s bytes free", + progname, __func__, humbuf); return NULL; } return pen; @@ -79,7 +80,7 @@ pushPen(const char *pen) { if (++pdepth == MAX_STACK) - errx(2, "%s: stack overflow.\n", __func__); + errx(2, "%s: stack overflow.\n", progname, __func__); pstack[pdepth] = strdup(pen); return pstack[pdepth]; @@ -127,9 +128,10 @@ if (min_free(pen) < sz) { rmdir(pen); cleanup(0); - errx(2, "%s: not enough free space to create '%s'.\n" + errx(2, "%s.%s: not enough free space to create '%s'.\n" "Please set your PKG_TMPDIR environment variable to a location\n" - "with more space and\ntry the command again", __func__, pen); + "with more space and\ntry the command again", progname, __func__, + pen); } if (!getcwd(cwd, FILENAME_MAX)) { @@ -139,7 +141,7 @@ if (chdir(pen) == FAIL) { cleanup(0); - errx(2, "%s: can't chdir to '%s'", __func__, pen); + errx(2, "%s:%s: can't chdir to '%s'", progname, __func__, pen); } strcpy(PenLocation, pen); @@ -163,11 +165,11 @@ if (chdir(PenLocation) == FAIL) { cleanup(0); - errx(2, "%s: can't chdir back to '%s'", __func__, PenLocation); + errx(2, "%s.%s: can't chdir back to '%s'", progname, __func__, PenLocation); } if (left[0] == '/' && vsystem("/bin/rm -rf %s", left)) - warnx("couldn't remove temporary dir '%s'", left); + warnx("%s.%s: couldn't remove temporary dir '%s'", progname, __func__, left); signal(SIGINT, oldsig); return 1; @@ -179,7 +181,7 @@ struct statfs buf; if (statfs(tmpdir, &buf) != 0) { - warn("statfs"); + warn("%s.%s: statfs", progname, __func__); return -1; } return (off_t)buf.f_bavail * (off_t)buf.f_bsize; ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/main.c#2 (text+ko) ==== @@ -36,6 +36,8 @@ Boolean UseINDEXOnly = FALSE; Boolean ShowOrigin = FALSE; +char *progname = NULL; + static void usage(void); static char opts[] = "dIhl:L:qs:XtTO:ov"; @@ -67,6 +69,8 @@ cmp = version_match(argv[3], argv[2]); exit(cmp == 1 ? 0 : 1); } + if ((progname = basename(argv[0])) == NULL) + err(EXIT_FAILURE, "basename"); else while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) { switch(ch) { case 'v':
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003220939.o2M9dhCx095192>