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.
20 * $FreeBSD: src/usr.sbin/pkg_install/delete/main.c,v 1.26 2004/06/29 18:54:47 eik Exp $
21 * $DragonFly: src/usr.sbin/pkg_install/delete/Attic/main.c,v 1.4 2004/07/30 04:46:13 dillon Exp $
24 #include <sys/types.h>
30 static char Options[] = "adDfGhinp:rvxX";
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(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;
91 MatchType = MATCH_EREGEX;
112 /* Get all the remaining package names, if any */
114 /* Don't try to apply heuristics if arguments are regexs */
115 if (MatchType != MATCH_REGEX)
116 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
117 *pkgs_split++ = '\0';
119 * If character after the '/' is alphanumeric, then we've found the
120 * package name. Otherwise we've come across a trailing '/' and
121 * need to continue our quest.
123 if (isalpha(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
124 strpbrk(pkgs_split, "*?[]") != NULL)) {
132 /* If no packages, yelp */
133 if (pkgs == start && MatchType != MATCH_ALL)
134 warnx("missing package name(s)"), usage();
137 (void) stat(tmp, &stat_s);
138 if (!Fake && getuid() && geteuid() != stat_s.st_uid) {
140 errx(1, "you do not own %s, use -f to force", tmp);
142 warnx("you do not own %s (proceeding anyways)", tmp);
144 if ((error = pkg_perform(start)) != 0) {
146 warnx("%d package deletion(s) failed", error);
156 fprintf(stderr, "%s\n%s\n",
157 "usage: pkg_delete [-dDfGinrvxX] [-p prefix] pkg-name ...",
158 " pkg_delete -a [flags]");