main.c revision 71095
1#ifndef lint
2static const char rcsid[] =
3  "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 71095 2001-01-16 08:27:28Z 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[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:";
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	PlayPen[FILENAME_MAX];
39int	Dereference	= FALSE;
40int	PlistOnly	= FALSE;
41
42static void usage __P((void));
43
44int
45main(int argc, char **argv)
46{
47    int ch;
48    char **pkgs, **start;
49
50    pkgs = start = argv;
51    while ((ch = getopt(argc, argv, Options)) != -1)
52	switch(ch) {
53	case 'v':
54	    Verbose = TRUE;
55	    break;
56
57	case 'N':
58	    AutoAnswer = NO;
59	    break;
60
61	case 'Y':
62	    AutoAnswer = YES;
63	    break;
64
65	case 'O':
66	    PlistOnly = TRUE;
67	    break;
68
69	case 'p':
70	    Prefix = optarg;
71	    break;
72
73	case 's':
74	    SrcDir = optarg;
75	    break;
76
77	case 'f':
78	    Contents = optarg;
79	    break;
80
81	case 'c':
82	    Comment = optarg;
83	    break;
84
85	case 'd':
86	    Desc = optarg;
87	    break;
88
89	case 'i':
90	    Install = optarg;
91	    break;
92
93	case 'I':
94	    PostInstall = optarg;
95	    break;
96
97	case 'k':
98	    DeInstall = optarg;
99	    break;
100
101	case 'K':
102	    PostDeInstall = optarg;
103	    break;
104
105	case 'r':
106	    Require = optarg;
107	    break;
108
109	case 't':
110	    strcpy(PlayPen, optarg);
111	    break;
112
113	case 'X':
114	    ExcludeFrom = optarg;
115	    break;
116
117	case 'h':
118	    Dereference = TRUE;
119	    break;
120
121	case 'D':
122	    Display = optarg;
123	    break;
124
125	case 'm':
126	    Mtree = optarg;
127	    break;
128
129	case 'P':
130	    Pkgdeps = optarg;
131	    break;
132
133	case 'o':
134	    Origin = optarg;
135	    break;
136
137	case '?':
138	default:
139	    usage();
140	    break;
141	}
142
143    argc -= optind;
144    argv += optind;
145
146    /* Get all the remaining package names, if any */
147    while (*argv)
148	*pkgs++ = *argv++;
149
150    /* If no packages, yelp */
151    if (pkgs == start)
152	warnx("missing package name"), usage();
153    *pkgs = NULL;
154    if (start[1])
155	warnx("only one package name allowed ('%s' extraneous)", start[1]),
156	usage();
157    if (!pkg_perform(start)) {
158	if (Verbose)
159	    warnx("package creation failed");
160	return 1;
161    }
162    else
163	return 0;
164}
165
166static void
167usage()
168{
169    fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
170"usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
171"                  [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
172"                  [-t template] [-X excludefile] [-D displayfile] ",
173"                  [-m mtreefile] [-o origin] -c comment -d description ",
174"                  -f packlist pkg-name");
175    exit(1);
176}
177