Deleted Added
sdiff udiff text old ( 85470 ) new ( 93520 )
full compact
1#ifndef lint
2static const char rcsid[] =
3 "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 85470 2001-10-25 07:56:20Z sobomax $";
4#endif
5
6/*
7 * FreeBSD install - a package for the installation and maintainance
8 * of non-core utilities.
9 *
10 * Jordan K. Hubbard
11 * 18 July 1993
12 *
13 * This is the create module.
14 *
15 */
16
17#include <err.h>
18#include "lib.h"
19#include "create.h"
20
21static char Options[] = "YNOhvyf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:b:";
22
23char *Prefix = NULL;
24char *Comment = NULL;
25char *Desc = NULL;
26char *SrcDir = NULL;
27char *Display = NULL;
28char *Install = NULL;
29char *PostInstall = NULL;
30char *DeInstall = NULL;
31char *PostDeInstall = NULL;
32char *Contents = NULL;
33char *Require = NULL;
34char *ExcludeFrom = NULL;
35char *Mtree = NULL;
36char *Pkgdeps = NULL;
37char *Origin = NULL;
38char *InstalledPkg = NULL;
39char PlayPen[FILENAME_MAX];
40int Dereference = FALSE;
41int PlistOnly = FALSE;
42int UseBzip2 = FALSE;
43
44static void usage __P((void));
45
46int
47main(int argc, char **argv)
48{
49 int ch;
50 char **pkgs, **start, *tmp;
51
52 pkgs = start = argv;
53 while ((ch = getopt(argc, argv, Options)) != -1)
54 switch(ch) {
55 case 'v':
56 Verbose = TRUE;
57 break;
58
59 case 'N':
60 AutoAnswer = NO;
61 break;
62
63 case 'Y':
64 AutoAnswer = YES;
65 break;
66
67 case 'O':
68 PlistOnly = TRUE;
69 break;
70
71 case 'p':
72 Prefix = optarg;
73 break;
74
75 case 's':
76 SrcDir = optarg;
77 break;
78
79 case 'f':
80 Contents = optarg;
81 break;
82
83 case 'c':
84 Comment = optarg;
85 break;
86
87 case 'd':
88 Desc = optarg;
89 break;
90
91 case 'i':
92 Install = optarg;
93 break;
94
95 case 'I':
96 PostInstall = optarg;
97 break;
98
99 case 'k':
100 DeInstall = optarg;
101 break;
102
103 case 'K':
104 PostDeInstall = optarg;
105 break;
106
107 case 'r':
108 Require = optarg;
109 break;
110
111 case 't':
112 strlcpy(PlayPen, optarg, sizeof(PlayPen));
113 break;
114
115 case 'X':
116 ExcludeFrom = optarg;
117 break;
118
119 case 'h':
120 Dereference = TRUE;
121 break;
122
123 case 'D':
124 Display = optarg;
125 break;
126
127 case 'm':
128 Mtree = optarg;
129 break;
130
131 case 'P':
132 Pkgdeps = optarg;
133 break;
134
135 case 'o':
136 Origin = optarg;
137 break;
138
139 case 'y':
140 UseBzip2 = TRUE;
141 break;
142
143 case 'b':
144 InstalledPkg = optarg;
145 while ((tmp = strrchr(optarg, (int)'/')) != NULL) {
146 *tmp++ = '\0';
147 /*
148 * If character after the '/' is alphanumeric, then we've
149 * found the package name. Otherwise we've come across
150 * a trailing '/' and need to continue our quest.
151 */
152 if (isalpha(*tmp)) {
153 InstalledPkg = tmp;
154 break;
155 }
156 }
157 break;
158
159 case '?':
160 default:
161 usage();
162 break;
163 }
164
165 argc -= optind;
166 argv += optind;
167
168 /* Get all the remaining package names, if any */
169 while (*argv)
170 *pkgs++ = *argv++;
171
172 /* If no packages, yelp */
173 if ((pkgs == start) && (InstalledPkg == NULL))
174 warnx("missing package name"), usage();
175 *pkgs = NULL;
176 if ((start[0] != NULL) && (start[1] != NULL)) {
177 warnx("only one package name allowed ('%s' extraneous)", start[1]);
178 usage();
179 }
180 if (start[0] == NULL)
181 start[0] = InstalledPkg;
182 if (!pkg_perform(start)) {
183 if (Verbose)
184 warnx("package creation failed");
185 return 1;
186 }
187 else
188 return 0;
189}
190
191static void
192usage()
193{
194 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
195"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
196" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
197" [-t template] [-X excludefile] [-D displayfile] ",
198" [-m mtreefile] [-o origin] -c comment -d description ",
199" -f packlist pkg-filename",
200" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
201 exit(1);
202}