bin/146859: [patch] [pkg_install] libpkg/msg.c removal and related
cleanup
Garrett Cooper
gcooper at FreeBSD.org
Sun May 23 09:10:02 UTC 2010
>Number: 146859
>Category: bin
>Synopsis: [patch] [pkg_install] libpkg/msg.c removal and related cleanup
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun May 23 09:10:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Garrett Cooper
>Release: 9-CURRENT
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r206173M: Mon Apr 26 22:45:06 PDT 2010 root at bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA.ata amd64
>Description:
This proposed change:
1. Removes msg.c from libpkg as it was largely unused.
2. Removes the one and only function call made from msg.c (upchuck in
3. Removes some dead prototypes (barf, whinge).
4. Removes -N and -Y from pkg_create as they're complete no-ops in pkg_create, and libpkg.
>How-To-Repeat:
These are error conditions that won't occur 99.9% of the time (unless uname(2) fails), but will occur given proper circumstances.
>Fix:
See attached patch.
Patch attached with submission follows:
Index: lib/libpkg/global.c
===================================================================
--- lib/libpkg/global.c (revision 208438)
+++ lib/libpkg/global.c (working copy)
@@ -28,5 +28,4 @@
Boolean Quiet = FALSE;
Boolean Fake = FALSE;
Boolean Force = FALSE;
-int AutoAnswer = FALSE;
int Verbose = 0; /* Allow multiple levels of verbose. */
Index: lib/libpkg/pen.c
===================================================================
--- lib/libpkg/pen.c (revision 208438)
+++ lib/libpkg/pen.c (working copy)
@@ -126,8 +126,8 @@
}
if (!getcwd(cwd, FILENAME_MAX)) {
- upchuck("getcwd");
- return NULL;
+ cleanup(0);
+ err(EXIT_FAILURE, "getcwd");
}
if (chdir(pen) == FAIL) {
Index: lib/libpkg/msg.c
===================================================================
--- lib/libpkg/msg.c (revision 208438)
+++ lib/libpkg/msg.c (working copy)
@@ -1,70 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * of non-core utilities.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous message routines.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "pkg.h"
-#include <err.h>
-#include <paths.h>
-
-/* Die a relatively simple death */
-void
-upchuck(const char *message)
-{
- cleanup(0);
- errx(1, "fatal error during execution: %s", message);
-}
-
-/*
- * As a yes/no question, prompting from the varargs string and using
- * default if user just hits return.
- */
-Boolean
-y_or_n(Boolean def, const char *msg, ...)
-{
- va_list args;
- int ch = 0;
- FILE *tty;
-
- va_start(args, msg);
- /*
- * Need to open /dev/tty because file collection may have been
- * collected on stdin
- */
- tty = fopen(_PATH_TTY, "r");
- if (!tty) {
- cleanup(0);
- errx(2, "can't open %s!", _PATH_TTY);
- }
- while (ch != 'Y' && ch != 'N') {
- vfprintf(stderr, msg, args);
- if (def)
- fprintf(stderr, " [yes]? ");
- else
- fprintf(stderr, " [no]? ");
- fflush(stderr);
- ch = toupper(fgetc(tty));
- if (ch == '\n')
- ch = (def) ? 'Y' : 'N';
- }
- fclose(tty) ;
- return (ch == 'Y') ? TRUE : FALSE;
-}
Index: lib/libpkg/pkg.h
===================================================================
--- lib/libpkg/pkg.h (revision 208438)
+++ lib/libpkg/pkg.h (working copy)
@@ -191,12 +191,6 @@
int unpack(const char *, const char *);
void format_cmd(char *, int, const char *, const char *, const char *);
-/* Msg */
-void upchuck(const char *);
-void barf(const char *, ...);
-void whinge(const char *, ...);
-Boolean y_or_n(Boolean, const char *, ...);
-
/* Packing list */
PackingList new_plist_entry(void);
PackingList last_plist(Package *);
Index: usr.sbin/pkg_install/create/pkg_create.1
===================================================================
--- usr.sbin/pkg_install/create/pkg_create.1 (revision 208438)
+++ usr.sbin/pkg_install/create/pkg_create.1 (working copy)
@@ -31,7 +31,7 @@
.Nd a utility for creating software package distributions
.Sh SYNOPSIS
.Nm
-.Op Fl YNOhjnvyz
+.Op Fl Ohjnvyz
.Op Fl C Ar conflicts
.Op Fl P Ar pkgs
.Op Fl p Ar prefix
@@ -52,7 +52,7 @@
.Fl f Ar packlist
.Ar pkg-filename
.Nm
-.Op Fl EGYNRhnvxy
+.Op Fl EGRhnvxy
.Fl b Ar pkg-name
.Op Ar pkg-filename
.Sh DESCRIPTION
@@ -103,10 +103,6 @@
or, if preceded by
.Cm - ,
the argument itself.
-.It Fl Y , -yes
-Assume a default answer of `Yes' for any questions asked.
-.It Fl N , -no
-Assume a default answer of `No' for any questions asked.
.It Fl O , -plist-only
Go into a `packing list Only' mode.
This is a custom hack for the
Index: usr.sbin/pkg_install/create/main.c
===================================================================
--- usr.sbin/pkg_install/create/main.c (revision 208438)
+++ usr.sbin/pkg_install/create/main.c (working copy)
@@ -48,12 +48,11 @@
static void usage(void);
-static char opts[] = "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
+static char opts[] = "EGnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
static struct option longopts[] = {
{ "backup", required_argument, NULL, 'b' },
{ "extended", no_argument, NULL, 'E' },
{ "help", no_argument, &Help, TRUE },
- { "no", no_argument, NULL, 'N' },
{ "no-glob", no_argument, NULL, 'G' },
{ "origin", required_argument, NULL, 'o' },
{ "plist-only", no_argument, NULL, 'O' },
@@ -62,7 +61,6 @@
{ "regex", no_argument, NULL, 'x' },
{ "template", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
- { "yes", no_argument, NULL, 'Y' },
{ NULL, 0, NULL, 0 },
};
@@ -93,14 +91,6 @@
MatchType = MATCH_EXACT;
break;
- case 'N':
- AutoAnswer = NO;
- break;
-
- case 'Y':
- AutoAnswer = YES;
- break;
-
case 'O':
PlistOnly = TRUE;
break;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list