Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/delete Pull up revision 1.13:
details: https://anonhg.NetBSD.org/src/rev/28addd5f1df0
branches: netbsd-1-4
changeset: 469382:28addd5f1df0
user: he <he%NetBSD.org@localhost>
date: Mon Sep 13 22:06:59 1999 +0000
description:
Pull up revision 1.13:
Bring closer to /usr/share/misc/style with the aid of indent(1). (hubertf)
diffstat:
usr.sbin/pkg_install/delete/main.c | 282 ++++++++++++++++++------------------
1 files changed, 140 insertions(+), 142 deletions(-)
diffs (truncated from 338 to 300 lines):
diff -r 86df97dd01f9 -r 28addd5f1df0 usr.sbin/pkg_install/delete/main.c
--- a/usr.sbin/pkg_install/delete/main.c Mon Sep 13 22:05:52 1999 +0000
+++ b/usr.sbin/pkg_install/delete/main.c Mon Sep 13 22:06:59 1999 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.11.2.1 1999/08/22 17:50:20 he Exp $ */
+/* $NetBSD: main.c,v 1.11.2.2 1999/09/13 22:06:59 he Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.11.2.1 1999/08/22 17:50:20 he Exp $");
+__RCSID("$NetBSD: main.c,v 1.11.2.2 1999/09/13 22:06:59 he Exp $");
#endif
#endif
@@ -37,182 +37,180 @@
static char Options[] = "hvDdnfFp:OrR";
-char *Prefix = NULL;
-char *ProgramPath = NULL;
-Boolean NoDeInstall = FALSE;
-Boolean CleanDirs = FALSE;
-Boolean File2Pkg = FALSE;
-Boolean Recurse_up = FALSE;
-Boolean Recurse_down = FALSE;
+char *Prefix = NULL;
+char *ProgramPath = NULL;
+Boolean NoDeInstall = FALSE;
+Boolean CleanDirs = FALSE;
+Boolean File2Pkg = FALSE;
+Boolean Recurse_up = FALSE;
+Boolean Recurse_down = FALSE;
Boolean OnlyDeleteFromPkgDB = FALSE;
lpkg_head_t pkgs;
static void
usage(void)
{
- fprintf(stderr, "usage: pkg_delete [-vDdnFfOrR] [-p prefix] pkg-name ...\n");
- exit(1);
+ fprintf(stderr, "usage: pkg_delete [-vDdnFfOrR] [-p prefix] pkg-name ...\n");
+ exit(1);
}
int
find_fn(const char *pkg, char *data)
{
- lpkg_t *lpp;
+ lpkg_t *lpp;
- lpp=alloc_lpkg(pkg);
- TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+ lpp = alloc_lpkg(pkg);
+ TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
- return 0;
+ return 0;
}
int
main(int argc, char **argv)
{
- int ch, error;
- lpkg_t *lpp;
+ int ch, error;
+ lpkg_t *lpp;
- ProgramPath = argv[0];
+ ProgramPath = argv[0];
- while ((ch = getopt(argc, argv, Options)) != -1)
- switch(ch) {
- case 'v':
- Verbose = TRUE;
- break;
+ while ((ch = getopt(argc, argv, Options)) != -1)
+ switch (ch) {
+ case 'v':
+ Verbose = TRUE;
+ break;
+
+ case 'f':
+ Force = TRUE;
+ break;
+
+ case 'F':
+ File2Pkg = TRUE;
+ break;
- case 'f':
- Force = TRUE;
- break;
+ case 'p':
+ Prefix = optarg;
+ break;
- case 'F':
- File2Pkg = TRUE;
- break;
+ case 'D':
+ NoDeInstall = TRUE;
+ break;
+
+ case 'd':
+ CleanDirs = TRUE;
+ break;
- case 'p':
- Prefix = optarg;
- break;
+ case 'n':
+ Fake = TRUE;
+ Verbose = TRUE;
+ break;
- case 'D':
- NoDeInstall = TRUE;
- break;
+ case 'r':
+ Recurse_up = TRUE;
+ break;
+
+ case 'R':
+ Recurse_down = TRUE;
+ break;
- case 'd':
- CleanDirs = TRUE;
- break;
+ case 'O':
+ OnlyDeleteFromPkgDB = TRUE;
+ break;
- case 'n':
- Fake = TRUE;
- Verbose = TRUE;
- break;
+ case 'h':
+ case '?':
+ default:
+ usage();
+ break;
+ }
- case 'r':
- Recurse_up = TRUE;
- break;
+ argc -= optind;
+ argv += optind;
+
+ TAILQ_INIT(&pkgs);
- case 'R':
- Recurse_down = TRUE;
- break;
+ /* Get all the remaining package names, if any */
+ if (File2Pkg)
+ if (pkgdb_open(1) == -1) {
+ err(1, "cannot open pkgdb");
+ }
+ /* Get all the remaining package names, if any */
+ while (*argv) {
+ /* pkgdb: if -F flag given, don't add pkgnames to pkgs but
+ * rather resolve the given filenames to pkgnames using
+ * pkgdb_retrieve, then add these. */
+ if (File2Pkg) {
+ char *s;
+
+ s = pkgdb_retrieve(*argv);
- case 'O':
- OnlyDeleteFromPkgDB = TRUE;
- break;
-
- case 'h':
- case '?':
- default:
- usage();
- break;
+ if (s) {
+ lpp = alloc_lpkg(s);
+ TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+ } else
+ errx(1, "No matching pkg for %s in pkgdb.", *argv);
+ } else {
+ if (ispkgpattern(*argv)) {
+ if (findmatchingname(_pkgdb_getPKGDB_DIR(), *argv, find_fn, NULL) == 0)
+ errx(1, "No matching pkg for %s.", *argv);
+ } else {
+ lpp = alloc_lpkg(*argv);
+ TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+ }
+ }
+ argv++;
}
- argc -= optind;
- argv += optind;
-
- TAILQ_INIT(&pkgs);
-
- /* Get all the remaining package names, if any */
- if (File2Pkg)
- if (pkgdb_open(1)==-1) {
- err(1, "cannot open pkgdb");
- }
- /* Get all the remaining package names, if any */
- while (*argv) {
- /* pkgdb: if -F flag given, don't add pkgnames to pkgs but
- * rather resolve the given filenames to pkgnames using
- * pkgdb_retrieve, then add them.
- */
- if (File2Pkg) {
- char *s;
+ if (File2Pkg)
+ pkgdb_close();
- s = pkgdb_retrieve(*argv);
+ /* If no packages, yelp */
+ if (TAILQ_FIRST(&pkgs) == NULL)
+ warnx("missing package name(s)"), usage();
+ if (!Fake && getuid() != 0)
+ errx(1, "you must be root to delete packages");
+ if (OnlyDeleteFromPkgDB) {
+ /* Only delete the given packages' files from pkgdb, do not
+ * touch the pkg itself. Used by "make reinstall" in
+ * bsd.pkg.mk */
+ char *key, *val;
- if (s) {
- lpp = alloc_lpkg(s);
- TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
- } else
- errx(1, "No matching pkg for %s in pkgdb.", *argv);
- } else {
- if (ispkgpattern(*argv)) {
- if (findmatchingname(_pkgdb_getPKGDB_DIR(), *argv, find_fn, NULL) == 0)
- errx(1, "No matching pkg for %s.", *argv);
- }else {
- lpp = alloc_lpkg(*argv);
- TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
- }
- }
- argv++;
- }
+ if (pkgdb_open(0) == -1) {
+ err(1, "cannot open %s", _pkgdb_getPKGDB_FILE());
+ }
- if (File2Pkg)
- pkgdb_close();
+ error = 0;
+ while ((key = pkgdb_iter())) {
+ val = pkgdb_retrieve(key);
- /* If no packages, yelp */
- if (TAILQ_FIRST(&pkgs) == NULL)
- warnx("missing package name(s)"), usage();
- if (!Fake && getuid() != 0)
- errx(1, "you must be root to delete packages");
- if (OnlyDeleteFromPkgDB) {
- /* Only delete the given packages' files from pkgdb, do not touch
- * the pkg itself. Used by "make reinstall" in bsd.pkg.mk
- */
- char *key, *val;
-
- if (pkgdb_open(0)==-1) {
- err(1, "cannot open %s", _pkgdb_getPKGDB_FILE());
- }
-
- error = 0;
- while ((key=pkgdb_iter())) {
- val=pkgdb_retrieve(key);
+ lpp = TAILQ_FIRST(&pkgs);
+ if (lpp != NULL) {
+ do {
+ if (strcmp(val, lpp->lp_name) == 0) {
+ if (Verbose)
+ printf("Removing file %s from pkgdb\n", key);
- lpp = TAILQ_FIRST(&pkgs);
- if (lpp != NULL) {
- do {
- if (strcmp(val, lpp->lp_name) == 0) {
- if (Verbose)
- printf("Removing file %s from pkgdb\n", key);
-
- errno=0;
- if (pkgdb_remove(key)) {
- if (errno)
- printf("Error removing %s from pkgdb: %s\n", key, strerror(errno));
- else
- printf("Key %s not present in pkgdb?!\n", key);
- error = 1;
+ errno = 0;
+ if (pkgdb_remove(key)) {
+ if (errno)
Home |
Main Index |
Thread Index |
Old Index