1 /* $NetBSD: main.c,v 1.1.1.10 2011/02/18 22:32:27 aymeric Exp $ */
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
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.
29 * This is the add module.
37 #include <sys/param.h>
42 static char Options
[] = "AC:DIK:LP:RVW:fhm:np:t:Uuvw:";
45 char *OverrideMachine
= 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
;
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 ...");
77 main(int argc
, char **argv
)
83 while ((ch
= getopt(argc
, argv
, Options
)) != -1) {
94 ForceDepending
= TRUE
;
104 ForceDepending
= TRUE
;
112 pkgdb_set_dir(optarg
, 3);
124 OverrideMachine
= optarg
;
171 pkg_install_config();
173 if (Destdir
!= NULL
) {
176 pkgdbdir
= xasprintf("%s/%s", Destdir
, config_pkg_dbdir
);
177 pkgdb_set_dir(pkgdbdir
, 4);
185 /* If no packages, yelp */
186 warnx("missing package name(s)");
190 if (strcasecmp(do_license_check
, "no") == 0)
192 else if (strcasecmp(do_license_check
, "yes") == 0)
194 else if (strcasecmp(do_license_check
, "always") == 0)
197 errx(1, "Unknown value of the configuration variable"
201 load_license_lists();
203 /* Get all the remaining package names, if any */
204 for (; argc
> 0; --argc
, ++argv
) {
208 lpp
= alloc_lpkg("-");
210 lpp
= alloc_lpkg(*argv
);
212 TAILQ_INSERT_TAIL(&pkgs
, lpp
, lp_link
);
215 error
+= pkg_perform(&pkgs
);
217 warnx("%d package addition%s failed", error
, error
== 1 ? "" : "s");