Deleted Added
full compact
main.c (71513) main.c (84670)
1#ifndef lint
2static const char rcsid[] =
1#ifndef lint
2static const char rcsid[] =
3 "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 71513 2001-01-24 08:22:53Z sobomax $";
3 "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 84670 2001-10-08 17:01:35Z 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
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:";
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;
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;
38char PlayPen[FILENAME_MAX];
39int Dereference = FALSE;
40int PlistOnly = FALSE;
41int UseBzip2 = FALSE;
42
43static void usage __P((void));
44
45int
46main(int argc, char **argv)
47{
48 int ch;
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;
49 char **pkgs, **start;
50 char **pkgs, **start, *tmp;
50
51
52 /*{int barrier = 1; while (barrier); }*/
51 pkgs = start = argv;
52 while ((ch = getopt(argc, argv, Options)) != -1)
53 switch(ch) {
54 case 'v':
55 Verbose = TRUE;
56 break;
57
58 case 'N':

--- 75 unchanged lines hidden (view full) ---

134 case 'o':
135 Origin = optarg;
136 break;
137
138 case 'y':
139 UseBzip2 = TRUE;
140 break;
141
53 pkgs = start = argv;
54 while ((ch = getopt(argc, argv, Options)) != -1)
55 switch(ch) {
56 case 'v':
57 Verbose = TRUE;
58 break;
59
60 case 'N':

--- 75 unchanged lines hidden (view full) ---

136 case 'o':
137 Origin = optarg;
138 break;
139
140 case 'y':
141 UseBzip2 = TRUE;
142 break;
143
144 case 'b':
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
142 case '?':
143 default:
144 usage();
145 break;
146 }
147
148 argc -= optind;
149 argv += optind;
150
151 /* Get all the remaining package names, if any */
152 while (*argv)
153 *pkgs++ = *argv++;
154
155 /* If no packages, yelp */
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 */
156 if (pkgs == start)
173 if ((pkgs == start) && (InstalledPkg == NULL))
157 warnx("missing package name"), usage();
158 *pkgs = NULL;
174 warnx("missing package name"), usage();
175 *pkgs = NULL;
159 if (start[1])
160 warnx("only one package name allowed ('%s' extraneous)", start[1]),
176 if ((start[0] != NULL) && (start[1] != NULL)) {
177 warnx("only one package name allowed ('%s' extraneous)", start[1]);
161 usage();
178 usage();
179 }
180 if (start[0] == NULL)
181 start[0] = InstalledPkg;
162 if (!pkg_perform(start)) {
163 if (Verbose)
164 warnx("package creation failed");
165 return 1;
166 }
167 else
168 return 0;
169}
170
171static void
172usage()
173{
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{
174 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
194 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
175"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
176" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
177" [-t template] [-X excludefile] [-D displayfile] ",
178" [-m mtreefile] [-o origin] -c comment -d description ",
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 ",
179" -f packlist pkg-name");
199" -f packlist pkg-filename",
200" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
180 exit(1);
181}
201 exit(1);
202}