diff options
| author | hubertf <hubertf@NetBSD.org> | 1997-10-16 00:31:32 +0000 |
|---|---|---|
| committer | hubertf <hubertf@NetBSD.org> | 1997-10-16 00:31:32 +0000 |
| commit | d0245e3952ee6e22ffeffe67e2c7dbf2ae7d93ed (patch) | |
| tree | 287265b6040901fa5e180bad2048c0160cca569c /usr.sbin/pkg_install/delete | |
| parent | bc6479768b704b0477d2f52afcd91dc620e0a6a7 (diff) | |
First cut on importing pkg_install as of FreeBSD 971013:
- warn()/err() instead of whinge()/barf()
- Update RCS Id strings
- Update manpages (mostly)
Diffstat (limited to 'usr.sbin/pkg_install/delete')
| -rw-r--r-- | usr.sbin/pkg_install/delete/main.c | 42 | ||||
| -rw-r--r-- | usr.sbin/pkg_install/delete/perform.c | 55 | ||||
| -rw-r--r-- | usr.sbin/pkg_install/delete/pkg_delete.1 | 18 |
3 files changed, 49 insertions, 66 deletions
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index a590da58475..beb8d89a9ca 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -1,10 +1,10 @@ -/* $NetBSD: main.c,v 1.3 1997/06/13 16:10:15 agc Exp $ */ +/* $NetBSD: main.c,v 1.4 1997/10/16 00:32:02 hubertf Exp $ */ #ifndef lint #if 0 -static char *rcsid = "from FreeBSD Id: main.c,v 1.9 1997/03/31 05:10:48 imp Exp"; +static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp"; #else -static char *rcsid = "$NetBSD: main.c,v 1.3 1997/06/13 16:10:15 agc Exp $"; +static char *rcsid = "$NetBSD: main.c,v 1.4 1997/10/16 00:32:02 hubertf Exp $"; #endif #endif @@ -29,9 +29,9 @@ static char *rcsid = "$NetBSD: main.c,v 1.3 1997/06/13 16:10:15 agc Exp $"; * */ +#include <err.h> #include "lib.h" #include "delete.h" -#include <err.h> static char Options[] = "hvDdnfp:"; @@ -39,12 +39,13 @@ char *Prefix = NULL; Boolean NoDeInstall = FALSE; Boolean CleanDirs = FALSE; +static void usage __P((void)); + int main(int argc, char **argv) { int ch, error; char **pkgs, **start; - char *prog_name = argv[0]; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) @@ -77,7 +78,7 @@ main(int argc, char **argv) case 'h': case '?': default: - usage(prog_name, NULL); + usage(); break; } @@ -91,39 +92,22 @@ main(int argc, char **argv) /* If no packages, yelp */ if (pkgs == start) - usage(prog_name, "Missing package name(s)"); + warnx("missing package name(s)"), usage(); *pkgs = NULL; if (!Fake && getuid() != 0) - errx(1, "You must be root to delete packages."); + errx(1, "you must be root to delete packages"); if ((error = pkg_perform(start)) != 0) { if (Verbose) - fprintf(stderr, "%d package deletion(s) failed.\n", error); + warnx("%d package deletion(s) failed", error); return error; } else return 0; } -void -usage(const char *name, const char *fmt, ...) +static void +usage() { - va_list args; - - va_start(args, fmt); - if (fmt) { - fprintf(stderr, "%s: ", name); - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n\n"); - } - va_end(args); - fprintf(stderr, "Usage: %s [args] pkg [ .. pkg ]\n", name); - fprintf(stderr, "Where args are one or more of:\n\n"); - fprintf(stderr, "-v verbose\n"); - fprintf(stderr, "-p arg override prefix with arg\n"); - fprintf(stderr, "-d delete empty directories when deinstalling\n"); - fprintf(stderr, "-f force delete even if dependencies exist\n"); - fprintf(stderr, " or deinstall/requirement checks fail\n"); - fprintf(stderr, "-D don't execute pkg de-install script, if any\n"); - fprintf(stderr, "-n don't actually de-install, just show steps\n"); + fprintf(stderr, "usage: pkg_delete [-vDdnf] [-p prefix] pkg-name ...\n"); exit(1); } diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index e9e0b61c84c..80a488d8669 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -1,10 +1,10 @@ -/* $NetBSD: perform.c,v 1.2 1997/06/05 12:59:36 agc Exp $ */ +/* $NetBSD: perform.c,v 1.3 1997/10/16 00:32:04 hubertf Exp $ */ #ifndef lint #if 0 -static const char *rcsid = "from FreeBSD Id: perform.c,v 1.13 1997/03/06 10:21:57 jkh Exp"; +static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp"; #else -static const char *rcsid = "$NetBSD: perform.c,v 1.2 1997/06/05 12:59:36 agc Exp $"; +static const char *rcsid = "$NetBSD: perform.c,v 1.3 1997/10/16 00:32:04 hubertf Exp $"; #endif #endif @@ -28,6 +28,7 @@ static const char *rcsid = "$NetBSD: perform.c,v 1.2 1997/06/05 12:59:36 agc Exp * */ +#include <err.h> #include "lib.h" #include "delete.h" @@ -65,33 +66,34 @@ pkg_do(char *pkg) sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, pkg); if (!fexists(LogDir)) { - whinge("No such package '%s' installed.", pkg); + warnx("no such package '%s' installed", pkg); return 1; } if (!getcwd(home, FILENAME_MAX)) - barf("Unable to get current working directory!"); + cleanup(0), errx(2, "unable to get current working directory!"); if (chdir(LogDir) == FAIL) { - whinge("Unable to change directory to %s! Deinstall failed.", LogDir); + warnx("unable to change directory to %s! deinstall failed", LogDir); return 1; } if (!isemptyfile(REQUIRED_BY_FNAME)) { char buf[512]; - whinge("Package `%s' is required by these other packages", pkg); - whinge("and may not be deinstalled%s:", Force ? " (but I'll delete it anyway)" : "" ); + warnx("package `%s' is required by these other packages\n" + "and may not be deinstalled%s:", + pkg, Force ? " (but I'll delete it anyway)" : "" ); cfile = fopen(REQUIRED_BY_FNAME, "r"); if (cfile) { while (fgets(buf, sizeof(buf), cfile)) fprintf(stderr, "%s", buf); fclose(cfile); } else - whinge("cannot open requirements file `%s'", REQUIRED_BY_FNAME); + warnx("cannot open requirements file `%s'", REQUIRED_BY_FNAME); if (!Force) return 1; } sanity_check(LogDir); cfile = fopen(CONTENTS_FNAME, "r"); if (!cfile) { - whinge("Unable to open '%s' file.", CONTENTS_FNAME); + warnx("unable to open '%s' file", CONTENTS_FNAME); return 1; } /* If we have a prefix, add it now */ @@ -101,7 +103,7 @@ pkg_do(char *pkg) fclose(cfile); p = find_plist(&Plist, PLIST_CWD); if (!p) { - whinge("Package '%s' doesn't have a prefix.", pkg); + warnx("package '%s' doesn't have a prefix", pkg); return 1; } setenv(PKG_PREFIX_VNAME, p->name, 1); @@ -110,8 +112,8 @@ pkg_do(char *pkg) printf("Executing 'require' script.\n"); vsystem("chmod +x %s", REQUIRE_FNAME); /* be sure */ if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) { - whinge("Package %s fails requirements %s", pkg, - Force ? "." : "- not deleted."); + warnx("package %s fails requirements %s", pkg, + Force ? "" : "- not deleted"); if (!Force) return 1; } @@ -122,21 +124,22 @@ pkg_do(char *pkg) else { vsystem("chmod +x %s", DEINSTALL_FNAME); /* make sure */ if (vsystem("./%s %s DEINSTALL", DEINSTALL_FNAME, pkg)) { - whinge("De-Install script returned error status."); + warnx("deinstall script returned error status"); if (!Force) return 1; } } } if (chdir(home) == FAIL) - barf("Toto! This doesn't look like Kansas anymore!"); + cleanup(0), errx(2, "Toto! This doesn't look like Kansas anymore!"); if (!Fake) { /* Some packages aren't packed right, so we need to just ignore delete_package()'s status. Ugh! :-( */ if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) - whinge("Couldn't entirely delete package (perhaps the packing list is\n" - "incorrectly specified?)\n"); + warnx( + "couldn't entirely delete package (perhaps the packing list is\n" + "incorrectly specified?)"); if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) { - whinge("Couldn't remove log entry in %s, de-install failed.", LogDir); + warnx("couldn't remove log entry in %s, deinstall failed", LogDir); if (!Force) return 1; } @@ -156,13 +159,15 @@ static void sanity_check(char *pkg) { if (!fexists(CONTENTS_FNAME)) - barf("Installed package %s has no %s file!", pkg, CONTENTS_FNAME); + cleanup(0), errx(2, "installed package %s has no %s file!", + pkg, CONTENTS_FNAME); } void cleanup(int sig) { /* Nothing to do */ + exit(1); } static void @@ -179,21 +184,21 @@ undepend(PackingList p, char *pkgname) p->name, REQUIRED_BY_FNAME); fp = fopen(fname, "r"); if (fp == NULL) { - whinge("Couldn't open dependency file `%s'", fname); + warnx("couldn't open dependency file `%s'", fname); return; } sprintf(ftmp, "%s.XXXXXX", fname); s = mkstemp(ftmp); if (s == -1) { fclose(fp); - whinge("Couldn't open temp file `%s'", ftmp); + warnx("couldn't open temp file `%s'", ftmp); return; } fpwr = fdopen(s, "w"); if (fpwr == NULL) { close(s); fclose(fp); - whinge("Couldn't fdopen temp file `%s'", ftmp); + warnx("couldn't fdopen temp file `%s'", ftmp); remove(ftmp); return; } @@ -205,18 +210,18 @@ undepend(PackingList p, char *pkgname) } (void) fclose(fp); if (fchmod(s, 0644) == FAIL) { - whinge("Error changing permission of temp file `%s'", ftmp); + warnx("error changing permission of temp file `%s'", ftmp); fclose(fpwr); remove(ftmp); return; } if (fclose(fpwr) == EOF) { - whinge("Error closing temp file `%s'", ftmp); + warnx("error closing temp file `%s'", ftmp); remove(ftmp); return; } if (rename(ftmp, fname) == -1) - whinge("Error renaming `%s' to `%s'", ftmp, fname); + warnx("error renaming `%s' to `%s'", ftmp, fname); remove(ftmp); /* just in case */ return; } diff --git a/usr.sbin/pkg_install/delete/pkg_delete.1 b/usr.sbin/pkg_install/delete/pkg_delete.1 index f70722244c8..0dbafc79fa7 100644 --- a/usr.sbin/pkg_install/delete/pkg_delete.1 +++ b/usr.sbin/pkg_install/delete/pkg_delete.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_delete.1,v 1.2 1997/06/05 14:25:49 agc Exp $ +.\" $NetBSD: pkg_delete.1,v 1.3 1997/10/16 00:32:06 hubertf Exp $ .\" .\" FreeBSD install - a package for the installation and maintainance .\" of non-core utilities. @@ -22,7 +22,7 @@ .Os FreeBSD 2.0 .Sh NAME .Nm pkg_delete -.Nd a utility for deleting previously installed software package distributions. +.Nd a utility for deleting previously installed software package distributions .Sh SYNOPSIS .Nm .Op Fl vDdnf @@ -64,28 +64,24 @@ command to examine the installed package control files. .Ef .Sh OPTIONS -The following command line options are supported. +The following command line options are supported: .Bl -tag -width indent .It Ar pkg-name ... The named packages are deinstalled. .It Fl v -Turns on verbose output. -.Em "Optional." +Turn on verbose output. .It Fl D If a deinstallation script exists for a given package, do not execute it. -.Em "Optional." .It Fl n Don't actually deinstall a package, just report the steps that would be taken if it were. -.Em "Optional." .It Fl p Ar prefix -Sets +Set .Ar prefix as the directory in which to delete files from any installed packages which do not explicitly set theirs. For most packages, the prefix will be set automatically to the installed location by .Xr pkg_add 1 . -.Em "Optional." .It Fl d Remove empty directories created by file cleanup. By default, only files/directories explicitly listed in a package's contents (either as @@ -95,11 +91,9 @@ directive) will be removed at deinstallation time. This option tells .Nm to also remove any directories that were emptied as a result of removing the package. -.Em "Optional." .It Fl f Force removal of the package, even if a dependency is recorded or the deinstall or require script fails. -.Em "Optional." .El .Pp @@ -129,7 +123,7 @@ then this is executed first as (where .Ar pkg-name is the name of the package in question and -.I DEINSTALL +.Ar DEINSTALL is a keyword denoting that this is a deinstallation) to see whether or not deinstallation should continue. A non-zero exit status means no, unless the |
