main.c revision 1337
1#ifndef lint
2static const char *rcsid = "$Id: main.c,v 1.4 1993/09/12 20:45:29 jkh Exp $";
3#endif
4
5/*
6 * FreeBSD install - a package for the installation and maintainance
7 * of non-core utilities.
8 *
9 * Jordan K. Hubbard
10 * 18 July 1993
11 *
12 * This is the create module.
13 *
14 */
15
16#include "lib.h"
17#include "create.h"
18
19static char Options[] = "hvf:p:c:d:i:k:r:t:X:";
20
21char	*Prefix		= NULL;
22char	*Comment        = NULL;
23char	*Desc		= NULL;
24char	*Install	= NULL;
25char	*DeInstall	= NULL;
26char	*Contents	= NULL;
27char	*Require	= NULL;
28char	*PlayPen	= NULL;
29char	*ExcludeFrom	= NULL;
30
31int
32main(int argc, char **argv)
33{
34    int ch;
35    char **pkgs, **start;
36    char *prog_name = argv[0];
37
38    pkgs = start = argv;
39    while ((ch = getopt(argc, argv, Options)) != EOF)
40	switch(ch) {
41	case 'v':
42	    Verbose = TRUE;
43	    break;
44
45	case 'N':
46	    AutoAnswer = NO;
47	    break;
48
49	case 'Y':
50	    AutoAnswer = YES;
51	    break;
52
53	case 'p':
54	    Prefix = optarg;
55	    break;
56
57	case 'f':
58	    Contents = optarg;
59	    break;
60
61	case 'c':
62	    Comment = optarg;
63	    break;
64
65	case 'd':
66	    Desc = optarg;
67	    break;
68
69	case 'i':
70	    Install = optarg;
71	    break;
72
73	case 'k':
74	    DeInstall = optarg;
75	    break;
76
77	case 'r':
78	    Require = optarg;
79	    break;
80
81	case 't':
82	    PlayPen = optarg;
83	    break;
84
85	case 'X':
86	    ExcludeFrom = optarg;
87	    break;
88
89	case 'h':
90	case '?':
91	default:
92	    usage(prog_name, NULL);
93	    break;
94	}
95
96    argc -= optind;
97    argv += optind;
98
99    /* Get all the remaining package names, if any */
100    while (*argv)
101	*pkgs++ = *argv++;
102
103    /* If no packages, yelp */
104    if (pkgs == start)
105	usage(prog_name, "Missing package name");
106    *pkgs = NULL;
107    if (start[1])
108	usage(prog_name, "Only one package name allowed\n\t('%s' extraneous)",
109	      start[1]);
110    if (!pkg_perform(start)) {
111	if (Verbose)
112	    fprintf(stderr, "Package creation failed.\n");
113	return 1;
114    }
115    else
116	return 0;
117}
118
119void
120usage(const char *name, const char *fmt, ...)
121{
122    va_list args;
123
124    va_start(args, fmt);
125    if (fmt) {
126	fprintf(stderr, "%s: ", name);
127	vfprintf(stderr, fmt, args);
128	fprintf(stderr, "\n\n");
129    }
130    va_end(args);
131    fprintf(stderr, "Usage: %s [args] pkg\n\n", name);
132    fprintf(stderr, "Where args are one or more of:\n\n");
133
134    fprintf(stderr, "-c [-]file Get one-line comment from file (-or arg)\n");
135    fprintf(stderr, "-d [-]file Get description from file (-or arg)\n");
136    fprintf(stderr, "-f file    get list of files from file (- for stdin)\n");
137    fprintf(stderr, "-i script  install script\n");
138    fprintf(stderr, "-p arg     install prefix will be arg\n");
139    fprintf(stderr, "-k script  de-install script\n");
140    fprintf(stderr, "-r script  pre/post requirements script\n");
141    fprintf(stderr, "-t temp    use temp as template for mktemp()\n");
142    fprintf(stderr, "-X file    exclude files listed in file\n");
143    fprintf(stderr, "-v         verbose\n");
144    exit(1);
145}
146