From owner-p4-projects@FreeBSD.ORG Mon Mar 22 09:39:44 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6F8351065675; Mon, 22 Mar 2010 09:39:44 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1920B1065672 for ; Mon, 22 Mar 2010 09:39:44 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 066688FC0A for ; Mon, 22 Mar 2010 09:39:44 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o2M9dhls095194 for ; Mon, 22 Mar 2010 09:39:43 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o2M9dhCx095192 for perforce@freebsd.org; Mon, 22 Mar 2010 09:39:43 GMT (envelope-from gcooper@FreeBSD.org) Date: Mon, 22 Mar 2010 09:39:43 GMT Message-Id: <201003220939.o2M9dhCx095192@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 175931 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2010 09:39:44 -0000 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 #include #include +#include +#include #include #include #include @@ -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':