1 /* $NetBSD: main.c,v 1.22 2009/10/07 12:53:26 joerg Exp $ */
10 __RCSID("$NetBSD: main.c,v 1.22 2009/10/07 12:53:26 joerg 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
[] = "AIK:LP:RVW:fhm:np:t:uvw:";
44 const char *PlainPkgdb
= NULL
;
46 char *OverrideMachine
= NULL
;
49 char *Viewbase
= NULL
;
50 Boolean NoView
= FALSE
;
51 Boolean NoInstall
= FALSE
;
52 Boolean NoRecord
= FALSE
;
53 Boolean Automatic
= FALSE
;
54 Boolean ForceDepends
= FALSE
;
62 (void) fprintf(stderr
, "%s\n%s\n%s\n%s\n",
63 "usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]",
64 " [-m machine] [-p prefix] [-s verification-type",
65 " [-W viewbase] [-w view]\n",
66 " [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ...");
71 main(int argc
, char **argv
)
75 const char *pkgdb
= NULL
;
78 while ((ch
= getopt(argc
, argv
, Options
)) != -1) {
113 OverrideMachine
= optarg
;
155 pkg_install_config();
158 pkgdb
= _pkgdb_getPKGDB_DIR();
159 PlainPkgdb
= xstrdup(pkgdb
);
161 if (Destdir
!= NULL
) {
164 pkgdbdir
= xasprintf("%s/%s", Destdir
, pkgdb
);
165 _pkgdb_setPKGDB_DIR(pkgdbdir
);
168 _pkgdb_setPKGDB_DIR(pkgdb
);
174 /* If no packages, yelp */
175 warnx("missing package name(s)");
179 if (strcasecmp(do_license_check
, "no") == 0)
181 else if (strcasecmp(do_license_check
, "yes") == 0)
183 else if (strcasecmp(do_license_check
, "always") == 0)
186 errx(1, "Unknown value of the configuration variable"
190 load_license_lists();
192 /* Get all the remaining package names, if any */
193 for (; argc
> 0; --argc
, ++argv
) {
197 lpp
= alloc_lpkg("-");
199 lpp
= alloc_lpkg(*argv
);
201 TAILQ_INSERT_TAIL(&pkgs
, lpp
, lp_link
);
204 error
+= pkg_perform(&pkgs
);
206 warnx("%d package addition%s failed", error
, error
== 1 ? "" : "s");