Remove building with NOCRYPTO option
[minix.git] / external / bsd / pkg_install / dist / add / main.c
blobc6f7b8c0a9296137be1b8d9222faecace4d6555a
1 /* $NetBSD: main.c,v 1.1.1.10 2011/02/18 22:32:27 aymeric 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.10 2011/02/18 22:32:27 aymeric Exp $");
14 * FreeBSD install - a package for the installation and maintainance
15 * of non-core utilities.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
26 * Jordan K. Hubbard
27 * 18 July 1993
29 * This is the add module.
33 #if HAVE_ERR_H
34 #include <err.h>
35 #endif
36 #if HAVE_SYS_PARAM_H
37 #include <sys/param.h>
38 #endif
39 #include "lib.h"
40 #include "add.h"
42 static char Options[] = "AC:DIK:LP:RVW:fhm:np:t:Uuvw:";
44 char *Destdir = NULL;
45 char *OverrideMachine = NULL;
46 char *Prefix = NULL;
47 char *View = NULL;
48 char *Viewbase = NULL;
49 Boolean NoView = FALSE;
50 Boolean NoInstall = FALSE;
51 Boolean NoRecord = FALSE;
52 Boolean Automatic = FALSE;
53 Boolean ForceDepends = FALSE;
55 * Normally, updating fails if the dependencies of a depending package
56 * are not satisfied by the package to be updated. ForceDepending
57 * turns that failure into a warning.
59 Boolean ForceDepending = FALSE;
61 int LicenseCheck = 0;
62 int Replace = 0;
63 int ReplaceSame = 0;
65 static void
66 usage(void)
68 (void) fprintf(stderr, "%s\n%s\n%s\n%s\n",
69 "usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]",
70 " [-m machine] [-p prefix] [-s verification-type",
71 " [-W viewbase] [-w view]\n",
72 " [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ...");
73 exit(1);
76 int
77 main(int argc, char **argv)
79 int ch, error=0;
80 lpkg_head_t pkgs;
82 setprogname(argv[0]);
83 while ((ch = getopt(argc, argv, Options)) != -1) {
84 switch (ch) {
85 case 'A':
86 Automatic = TRUE;
87 break;
89 case 'C':
90 config_file = optarg;
91 break;
93 case 'D':
94 ForceDepending = TRUE;
95 break;
97 case 'P':
98 Destdir = optarg;
99 break;
101 case 'f':
102 Force = TRUE;
103 ForceDepends = TRUE;
104 ForceDepending = TRUE;
105 break;
107 case 'I':
108 NoInstall = TRUE;
109 break;
111 case 'K':
112 pkgdb_set_dir(optarg, 3);
113 break;
115 case 'L':
116 NoView = TRUE;
117 break;
119 case 'R':
120 NoRecord = TRUE;
121 break;
123 case 'm':
124 OverrideMachine = optarg;
125 break;
127 case 'n':
128 Fake = TRUE;
129 Verbose = TRUE;
130 break;
132 case 'p':
133 Prefix = optarg;
134 break;
136 case 'U':
137 ReplaceSame = 1;
138 Replace = 1;
139 break;
141 case 'u':
142 Replace = 1;
143 break;
145 case 'V':
146 show_version();
147 /* NOTREACHED */
149 case 'v':
150 Verbose = TRUE;
151 break;
153 case 'W':
154 Viewbase = optarg;
155 break;
157 case 'w':
158 View = optarg;
159 break;
161 case 'h':
162 case '?':
163 default:
164 usage();
165 break;
168 argc -= optind;
169 argv += optind;
171 pkg_install_config();
173 if (Destdir != NULL) {
174 char *pkgdbdir;
176 pkgdbdir = xasprintf("%s/%s", Destdir, config_pkg_dbdir);
177 pkgdb_set_dir(pkgdbdir, 4);
178 free(pkgdbdir);
181 process_pkg_path();
182 TAILQ_INIT(&pkgs);
184 if (argc == 0) {
185 /* If no packages, yelp */
186 warnx("missing package name(s)");
187 usage();
190 if (strcasecmp(do_license_check, "no") == 0)
191 LicenseCheck = 0;
192 else if (strcasecmp(do_license_check, "yes") == 0)
193 LicenseCheck = 1;
194 else if (strcasecmp(do_license_check, "always") == 0)
195 LicenseCheck = 2;
196 else
197 errx(1, "Unknown value of the configuration variable"
198 "CHECK_LICENSE");
200 if (LicenseCheck)
201 load_license_lists();
203 /* Get all the remaining package names, if any */
204 for (; argc > 0; --argc, ++argv) {
205 lpkg_t *lpp;
207 if (IS_STDIN(*argv))
208 lpp = alloc_lpkg("-");
209 else
210 lpp = alloc_lpkg(*argv);
212 TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
215 error += pkg_perform(&pkgs);
216 if (error != 0) {
217 warnx("%d package addition%s failed", error, error == 1 ? "" : "s");
218 exit(1);
220 exit(0);