2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
17 * This is the delete module.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD: src/usr.sbin/pkg_install/delete/main.c,v 1.17.2.8 2002/08/20 06:35:07 obrien Exp $");
24 #include <sys/types.h>
30 static char Options[] = "adDfGhinp:rvx";
33 Boolean CleanDirs = FALSE;
34 Boolean Interactive = FALSE;
35 Boolean NoDeInstall = FALSE;
36 Boolean Recursive = FALSE;
37 match_t MatchType = MATCH_GLOB;
39 static void usage __P((void));
42 main(int argc, char **argv)
51 while ((ch = getopt(argc, argv, Options)) != -1)
79 MatchType = MATCH_ALL;
83 MatchType = MATCH_EXACT;
87 MatchType = MATCH_REGEX;
108 /* Get all the remaining package names, if any */
110 /* Don't try to apply heuristics if arguments are regexs */
111 if (MatchType != MATCH_REGEX)
112 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
113 *pkgs_split++ = '\0';
115 * If character after the '/' is alphanumeric, then we've found the
116 * package name. Otherwise we've come across a trailing '/' and
117 * need to continue our quest.
119 if (isalpha(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
120 strpbrk(pkgs_split, "*?[]") != NULL)) {
128 /* If no packages, yelp */
129 if (pkgs == start && MatchType != MATCH_ALL)
130 warnx("missing package name(s)"), usage();
133 (void) stat(tmp, &stat_s);
134 if (!Fake && getuid() && geteuid() != stat_s.st_uid) {
136 errx(1, "you do not own %s, use -f to force", tmp);
138 warnx("you do not own %s (proceeding anyways)", tmp);
140 if ((error = pkg_perform(start)) != 0) {
142 warnx("%d package deletion(s) failed", error);
152 fprintf(stderr, "%s\n%s\n",
153 "usage: pkg_delete [-dDfGinrvx] [-p prefix] pkg-name ...",
154 " pkg_delete -a [flags]");