d66ee6c3fd
- DB support is always included from libnbcompat if needed - pkg_view and linkfarm are not installed any more; they are not moved into the attic yet, so they can easily be installed as separte package - common configuration file to customise the behavior of various components; this supersedes the old audit-packages.conf - support for PKSC7 signatures (using X509 certs) and GPG signatures for packages in a secure way. See pkg_admin(8) for how to create them and pkg_install.conf(5) for the options to use them - audit-packages and download-vulnerability-list are wrapper scripts around pkg_admin. They try to mimic the classic options if used sanely. "pkg_admin audit" is now an order of magnitude faster than before - pkg_add uses libarchive and libfetch instead of external ftp and tar: - progress bar is currently missing for downloads - "pkg_add -" is no longer supported - no adhoc check for conficts between dependencies and already installed packages - "pkg_add -s" has been replaced with an option in pkg_install.conf, verification of plain detached GPG signatures is no longer supported - optional check for vulnerabilities before adding a package - if /var and /usr/pkg are on different fileystems it is twice as fast now - conflicts due to overlapping plists are checked before installation - pkg_add no longer plays with the process limits - pkg_add and pkg_delete have a new destdir option; scripts have to either be modified to use PKG_DESTDIR or should be disabled - pkg_add -u for now can't be used to update to the exact same version - internal "rm -rf" and "mkdir_p" code - all memory allocation failures are not explicitly fatal - if a file is not removed due to a failed checksum, still remove the entry from pkgdb
183 lines
3.3 KiB
C
183 lines
3.3 KiB
C
/* $NetBSD: main.c,v 1.1.1.2 2009/02/02 20:44:00 joerg Exp $ */
|
|
|
|
#if HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include <nbcompat.h>
|
|
#if HAVE_SYS_CDEFS_H
|
|
#include <sys/cdefs.h>
|
|
#endif
|
|
__RCSID("$NetBSD: main.c,v 1.1.1.2 2009/02/02 20:44:00 joerg Exp $");
|
|
|
|
/*
|
|
*
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
* of non-core utilities.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* Jordan K. Hubbard
|
|
* 18 July 1993
|
|
*
|
|
* This is the add module.
|
|
*
|
|
*/
|
|
|
|
#if HAVE_ERR_H
|
|
#include <err.h>
|
|
#endif
|
|
#if HAVE_SYS_PARAM_H
|
|
#include <sys/param.h>
|
|
#endif
|
|
#if HAVE_SYS_RESOURCE_H
|
|
#include <sys/resource.h>
|
|
#endif
|
|
#include "lib.h"
|
|
#include "add.h"
|
|
|
|
static char Options[] = "AIK:LP:RVW:fhm:np:t:uvw:";
|
|
|
|
char *Destdir = NULL;
|
|
char *OverrideMachine = NULL;
|
|
char *Prefix = NULL;
|
|
char *View = NULL;
|
|
char *Viewbase = NULL;
|
|
Boolean NoView = FALSE;
|
|
Boolean NoInstall = FALSE;
|
|
Boolean NoRecord = FALSE;
|
|
Boolean Automatic = FALSE;
|
|
|
|
int Replace = 0;
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
(void) fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
|
"usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]",
|
|
" [-m machine] [-p prefix] [-s verification-type",
|
|
" [-W viewbase] [-w view]\n",
|
|
" [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ...");
|
|
exit(1);
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int ch, error=0;
|
|
lpkg_head_t pkgs;
|
|
|
|
setprogname(argv[0]);
|
|
while ((ch = getopt(argc, argv, Options)) != -1) {
|
|
switch (ch) {
|
|
case 'A':
|
|
Automatic = TRUE;
|
|
break;
|
|
|
|
case 'C':
|
|
config_file = optarg;
|
|
|
|
case 'P':
|
|
Destdir = optarg;
|
|
break;
|
|
|
|
case 'f':
|
|
Force = TRUE;
|
|
break;
|
|
|
|
case 'I':
|
|
NoInstall = TRUE;
|
|
break;
|
|
|
|
case 'K':
|
|
_pkgdb_setPKGDB_DIR(optarg);
|
|
break;
|
|
|
|
case 'L':
|
|
NoView = TRUE;
|
|
break;
|
|
|
|
case 'R':
|
|
NoRecord = TRUE;
|
|
break;
|
|
|
|
case 'm':
|
|
OverrideMachine = optarg;
|
|
break;
|
|
|
|
case 'n':
|
|
Fake = TRUE;
|
|
Verbose = TRUE;
|
|
break;
|
|
|
|
case 'p':
|
|
Prefix = optarg;
|
|
break;
|
|
|
|
case 'u':
|
|
Replace++;
|
|
break;
|
|
|
|
case 'V':
|
|
show_version();
|
|
/* NOTREACHED */
|
|
|
|
case 'v':
|
|
Verbose = TRUE;
|
|
break;
|
|
|
|
case 'W':
|
|
Viewbase = optarg;
|
|
break;
|
|
|
|
case 'w':
|
|
View = optarg;
|
|
break;
|
|
|
|
case 'h':
|
|
case '?':
|
|
default:
|
|
usage();
|
|
break;
|
|
}
|
|
}
|
|
argc -= optind;
|
|
argv += optind;
|
|
|
|
pkg_install_config();
|
|
|
|
path_create(getenv("PKG_PATH"));
|
|
TAILQ_INIT(&pkgs);
|
|
|
|
if (argc == 0) {
|
|
/* If no packages, yelp */
|
|
warnx("missing package name(s)");
|
|
usage();
|
|
}
|
|
|
|
/* Get all the remaining package names, if any */
|
|
for (; argc > 0; --argc, ++argv) {
|
|
lpkg_t *lpp;
|
|
|
|
if (IS_STDIN(*argv))
|
|
lpp = alloc_lpkg("-");
|
|
else
|
|
lpp = alloc_lpkg(*argv);
|
|
|
|
TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
|
|
}
|
|
|
|
error += pkg_perform(&pkgs);
|
|
if (error != 0) {
|
|
warnx("%d package addition%s failed", error, error == 1 ? "" : "s");
|
|
exit(1);
|
|
}
|
|
exit(0);
|
|
}
|