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.
19 * $FreeBSD: src/usr.sbin/pkg_install/delete/main.c,v 1.17.2.8 2002/08/20 06:35:07 obrien Exp $
20 * $DragonFly: src/usr.sbin/pkg_install/delete/Attic/main.c,v 1.2 2003/06/17 04:29:59 dillon Exp $
23 #include <sys/types.h>
29 static char Options[] = "adDfGhinp:rvx";
32 Boolean CleanDirs = FALSE;
33 Boolean Interactive = FALSE;
34 Boolean NoDeInstall = FALSE;
35 Boolean Recursive = FALSE;
36 match_t MatchType = MATCH_GLOB;
38 static void usage __P((void));
41 main(int argc, char **argv)
50 while ((ch = getopt(argc, argv, Options)) != -1)
78 MatchType = MATCH_ALL;
82 MatchType = MATCH_EXACT;
86 MatchType = MATCH_REGEX;
107 /* Get all the remaining package names, if any */
109 /* Don't try to apply heuristics if arguments are regexs */
110 if (MatchType != MATCH_REGEX)
111 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
112 *pkgs_split++ = '\0';
114 * If character after the '/' is alphanumeric, then we've found the
115 * package name. Otherwise we've come across a trailing '/' and
116 * need to continue our quest.
118 if (isalpha(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
119 strpbrk(pkgs_split, "*?[]") != NULL)) {
127 /* If no packages, yelp */
128 if (pkgs == start && MatchType != MATCH_ALL)
129 warnx("missing package name(s)"), usage();
132 (void) stat(tmp, &stat_s);
133 if (!Fake && getuid() && geteuid() != stat_s.st_uid) {
135 errx(1, "you do not own %s, use -f to force", tmp);
137 warnx("you do not own %s (proceeding anyways)", tmp);
139 if ((error = pkg_perform(start)) != 0) {
141 warnx("%d package deletion(s) failed", error);
151 fprintf(stderr, "%s\n%s\n",
152 "usage: pkg_delete [-dDfGinrvx] [-p prefix] pkg-name ...",
153 " pkg_delete -a [flags]");