3 * FreeBSD install - a package for the installation and maintainance
4 * of non-core utilities.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
18 * This is the delete module.
22 #include <sys/cdefs.h>
23 __FBSDID("$FreeBSD$");
25 #include <sys/types.h>
31 static char Options[] = "adDfGhinp:rvxX";
34 Boolean CleanDirs = FALSE;
35 Boolean Interactive = FALSE;
36 Boolean NoDeInstall = FALSE;
37 Boolean Recursive = FALSE;
38 match_t MatchType = MATCH_GLOB;
40 static void usage __P((void));
43 main(int argc, char **argv)
52 while ((ch = getopt(argc, argv, Options)) != -1)
80 MatchType = MATCH_ALL;
84 MatchType = MATCH_EXACT;
88 MatchType = MATCH_REGEX;
92 MatchType = MATCH_EREGEX;
113 /* Get all the remaining package names, if any */
115 /* Don't try to apply heuristics if arguments are regexs */
116 if (MatchType != MATCH_REGEX)
117 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
118 *pkgs_split++ = '\0';
120 * If character after the '/' is alphanumeric, then we've found the
121 * package name. Otherwise we've come across a trailing '/' and
122 * need to continue our quest.
124 if (isalnum(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
125 strpbrk(pkgs_split, "*?[]") != NULL)) {
133 /* If no packages, yelp */
134 if (pkgs == start && MatchType != MATCH_ALL)
135 warnx("missing package name(s)"), usage();
138 (void) stat(tmp, &stat_s);
139 if (!Fake && getuid() && geteuid() != stat_s.st_uid) {
141 errx(1, "you do not own %s, use -f to force", tmp);
143 warnx("you do not own %s (proceeding anyways)", tmp);
145 if ((error = pkg_perform(start)) != 0) {
147 warnx("%d package deletion(s) failed", error);
157 fprintf(stderr, "%s\n%s\n",
158 "usage: pkg_delete [-dDfGinrvxX] [-p prefix] pkg-name ...",
159 " pkg_delete -a [flags]");