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