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 info module.
22 #include <sys/cdefs.h>
23 __FBSDID("$FreeBSD$");
29 static char Options[] = "acdDe:fgGhiIkl:LmoO:pqrRst:vVW:x";
32 match_t MatchType = MATCH_GLOB;
33 Boolean Quiet = FALSE;
34 char *InfoPrefix = (char *)(uintptr_t)"";
35 char PlayPen[FILENAME_MAX];
36 char *CheckPkg = NULL;
37 char *LookUpOrigin = NULL;
38 struct which_head *whead;
40 static void usage __P((void));
43 main(int argc, char **argv)
49 whead = malloc(sizeof(struct which_head));
56 MatchType = MATCH_ALL;
59 else while ((ch = getopt(argc, argv, Options)) != -1) {
62 MatchType = MATCH_ALL;
67 /* Reasonable definition of 'everything' */
68 Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL |
69 SHOW_DEINSTALL | SHOW_REQUIRE | SHOW_DISPLAY | SHOW_MTREE;
81 Flags |= SHOW_COMMENT;
89 Flags |= SHOW_DISPLAY;
101 MatchType = MATCH_EXACT;
105 Flags |= SHOW_INSTALL;
109 Flags |= SHOW_DEINSTALL;
113 Flags |= SHOW_REQUIRE;
133 Flags |= SHOW_ORIGIN;
137 LookUpOrigin = strdup(optarg);
138 if (LookUpOrigin == NULL)
143 Flags |= SHOW_FMTREV;
155 strlcpy(PlayPen, optarg, sizeof(PlayPen));
159 MatchType = MATCH_REGEX;
168 struct which_entry *entp;
170 entp = calloc(1, sizeof(struct which_entry));
174 strlcpy(entp->file, optarg, PATH_MAX);
176 TAILQ_INSERT_TAIL(whead, entp, next);
191 /* Set some reasonable defaults */
193 Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
195 /* Get all the remaining package names, if any */
198 * Don't try to apply heuristics if arguments are regexs or if
199 * the argument refers to an existing file.
201 if (MatchType != MATCH_REGEX && !isfile(*argv))
202 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
203 *pkgs_split++ = '\0';
205 * If character after the '/' is alphanumeric or shell
206 * metachar, then we've found the package name. Otherwise
207 * we've come across a trailing '/' and need to continue our
210 if (isalpha(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
211 strpbrk(pkgs_split, "*?[]") != NULL)) {
219 /* If no packages, yelp */
220 if (pkgs == start && MatchType != MATCH_ALL && !CheckPkg &&
221 TAILQ_EMPTY(whead) && LookUpOrigin == NULL)
222 warnx("missing package name(s)"), usage();
224 return pkg_perform(start);
230 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
231 "usage: pkg_info [-cdDfGiIkLmopqrRsvVx] [-e package] [-l prefix]",
232 " [-t template] [pkg-name ...]",
233 " pkg_info [-q] -W filename",
234 " pkg_info [-q] -O origin",
235 " pkg_info -a [flags]");