etc/protocols - sync with NetBSD-8
[minix.git] / external / bsd / pkg_install / dist / create / main.c
blob325d12ba8fe7ee22ce2d96ab04cbc7c9c22092ba
1 /* $NetBSD: main.c,v 1.1.1.7 2010/01/30 21:33:31 joerg Exp $ */
3 #if HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6 #include <nbcompat.h>
7 #if HAVE_SYS_CDEFS_H
8 #include <sys/cdefs.h>
9 #endif
10 __RCSID("$NetBSD: main.c,v 1.1.1.7 2010/01/30 21:33:31 joerg Exp $");
13 * FreeBSD install - a package for the installation and maintainance
14 * of non-core utilities.
16 * Jordan K. Hubbard
17 * 18 July 1993
19 * This is the create module.
23 #if HAVE_ERR_H
24 #include <err.h>
25 #endif
26 #include "lib.h"
27 #include "create.h"
29 static const char Options[] = "B:C:D:EF:I:K:L:OP:S:T:UVb:c:d:f:g:i:k:ln:p:r:s:u:v";
31 char *Prefix = NULL;
32 char *Comment = NULL;
33 char *Desc = NULL;
34 char *Display = NULL;
35 char *Install = NULL;
36 char *DeInstall = NULL;
37 char *Contents = NULL;
38 char *Pkgdeps = NULL;
39 char *BuildPkgdeps = NULL;
40 char *Pkgcfl = NULL;
41 char *BuildVersion = NULL;
42 char *BuildInfo = NULL;
43 char *SizePkg = NULL;
44 char *SizeAll = NULL;
45 char *Preserve = NULL;
46 char *DefaultOwner = NULL;
47 char *DefaultGroup = NULL;
48 char *realprefix = NULL;
49 const char *CompressionType = NULL;
50 int update_pkgdb = 1;
51 int create_views = 0;
52 int PlistOnly = 0;
53 int RelativeLinks = 0;
54 Boolean File2Pkg = FALSE;
56 static void
57 usage(void)
59 fprintf(stderr,
60 "usage: pkg_create [-ElOUVv] [-B build-info-file] [-b build-version-file]\n"
61 " [-C cpkgs] [-D displayfile] [-F compression] \n"
62 " [-I realprefix] [-i iscript]\n"
63 " [-K pkg_dbdir] [-k dscript]\n"
64 " [-n preserve-file] [-P dpkgs] [-p prefix] [-r rscript]\n"
65 " [-S size-all-file] [-s size-pkg-file]\n"
66 " [-T buildpkgs] [-u owner] [-g group]\n"
67 " -c comment -d description -f packlist\n"
68 " pkg-name\n");
69 exit(1);
72 int
73 main(int argc, char **argv)
75 int ch;
77 setprogname(argv[0]);
78 while ((ch = getopt(argc, argv, Options)) != -1)
79 switch (ch) {
80 case 'v':
81 Verbose = TRUE;
82 break;
84 case 'E':
85 create_views = 1;
86 break;
88 case 'F':
89 CompressionType = optarg;
90 break;
92 case 'I':
93 realprefix = optarg;
94 break;
96 case 'O':
97 PlistOnly = 1;
98 break;
100 case 'U':
101 update_pkgdb = 0;
102 break;
104 case 'p':
105 Prefix = optarg;
106 break;
108 case 's':
109 SizePkg = optarg;
110 break;
112 case 'S':
113 SizeAll = optarg;
114 break;
116 case 'f':
117 Contents = optarg;
118 break;
120 case 'c':
121 Comment = optarg;
122 break;
124 case 'd':
125 Desc = optarg;
126 break;
128 case 'g':
129 DefaultGroup = optarg;
130 break;
132 case 'i':
133 Install = optarg;
134 break;
136 case 'K':
137 pkgdb_set_dir(optarg, 3);
138 break;
140 case 'k':
141 DeInstall = optarg;
142 break;
144 case 'l':
145 RelativeLinks = 1;
146 break;
148 case 'L':
149 warnx("Obsolete -L option ignored");
150 break;
152 case 'u':
153 DefaultOwner = optarg;
154 break;
156 case 'D':
157 Display = optarg;
158 break;
160 case 'n':
161 Preserve = optarg;
162 break;
164 case 'P':
165 Pkgdeps = optarg;
166 break;
168 case 'T':
169 BuildPkgdeps = optarg;
170 break;
172 case 'C':
173 Pkgcfl = optarg;
174 break;
176 case 'b':
177 BuildVersion = optarg;
178 break;
180 case 'B':
181 BuildInfo = optarg;
182 break;
184 case 'V':
185 show_version();
186 /* NOTREACHED */
188 case '?':
189 default:
190 usage();
191 break;
194 argc -= optind;
195 argv += optind;
197 pkg_install_config();
199 if (argc == 0) {
200 warnx("missing package name");
201 usage();
203 if (argc != 1) {
204 warnx("only one package name allowed");
205 usage();
208 if (pkg_perform(*argv))
209 return 0;
210 if (Verbose) {
211 if (PlistOnly)
212 warnx("package registration failed");
213 else
214 warnx("package creation failed");
216 return 1;