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