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:pPqrRst: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);
195 if (Flags & SHOW_PTREV) {
197 printf("Package tools revision: ");
198 printf("%d\n", PKG_INSTALL_VERSION);
202 /* Set some reasonable defaults */
204 Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
206 /* Get all the remaining package names, if any */
209 * Don't try to apply heuristics if arguments are regexs or if
210 * the argument refers to an existing file.
212 if (MatchType != MATCH_REGEX && !isfile(*argv))
213 while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) {
214 *pkgs_split++ = '\0';
216 * If character after the '/' is alphanumeric or shell
217 * metachar, then we've found the package name. Otherwise
218 * we've come across a trailing '/' and need to continue our
221 if (isalpha(*pkgs_split) || ((MatchType == MATCH_GLOB) && \
222 strpbrk(pkgs_split, "*?[]") != NULL)) {
230 /* If no packages, yelp */
231 if (pkgs == start && MatchType != MATCH_ALL && !CheckPkg &&
232 TAILQ_EMPTY(whead) && LookUpOrigin == NULL)
233 warnx("missing package name(s)"), usage();
235 return pkg_perform(start);
241 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
242 "usage: pkg_info [-cdDfGiIkLmopqrRsvVx] [-e package] [-l prefix]",
243 " [-t template] [pkg-name ...]",
244 " pkg_info [-q] -W filename",
245 " pkg_info [-q] -O origin",
246 " pkg_info -a [flags]");