diff options
author | joerg <joerg@pkgsrc.org> | 2009-08-06 16:53:34 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2009-08-06 16:53:34 +0000 |
commit | 2f0d4681e7865219b527c251777744ac0ea56dae (patch) | |
tree | 3f2edd11f6afedcd6bd5af494a841e2e37538934 /pkgtools | |
parent | 04be251d49303785e63fea56e1d03971c6b31839 (diff) | |
download | pkgsrc-2f0d4681e7865219b527c251777744ac0ea56dae.tar.gz |
pkg_install-20090806:
- pkg_add: add support to check license conditions before installation
- pkg_delete: add -k option to skip over preserve packages.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/add/add.h | 3 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/main.c | 18 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/perform.c | 43 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/pkg_add.1 | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/pkg_add.cat1 | 11 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/pkg_delete.1 | 8 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/pkg_delete.c | 19 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/pkg_delete.cat1 | 8 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/parse-config.c | 9 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkg_install.conf.5.in | 14 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in | 15 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
13 files changed, 130 insertions, 34 deletions
diff --git a/pkgtools/pkg_install/files/add/add.h b/pkgtools/pkg_install/files/add/add.h index 3a6262aa9ae..2324110e142 100644 --- a/pkgtools/pkg_install/files/add/add.h +++ b/pkgtools/pkg_install/files/add/add.h @@ -1,4 +1,4 @@ -/* $NetBSD: add.h,v 1.13 2009/02/02 12:35:00 joerg Exp $ */ +/* $NetBSD: add.h,v 1.14 2009/08/06 16:53:34 joerg Exp $ */ /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp */ @@ -35,6 +35,7 @@ extern Boolean NoInstall; extern Boolean NoRecord; extern Boolean Force; extern Boolean Automatic; +extern int LicenseCheck; extern int Replace; int make_hierarchy(char *); diff --git a/pkgtools/pkg_install/files/add/main.c b/pkgtools/pkg_install/files/add/main.c index da8d295ed3d..b6d383c61b5 100644 --- a/pkgtools/pkg_install/files/add/main.c +++ b/pkgtools/pkg_install/files/add/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.18 2009/02/28 16:03:56 joerg Exp $ */ +/* $NetBSD: main.c,v 1.19 2009/08/06 16:53:34 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.18 2009/02/28 16:03:56 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.19 2009/08/06 16:53:34 joerg Exp $"); /* * @@ -54,6 +54,7 @@ Boolean NoInstall = FALSE; Boolean NoRecord = FALSE; Boolean Automatic = FALSE; +int LicenseCheck = 0; int Replace = 0; static void @@ -161,6 +162,19 @@ main(int argc, char **argv) usage(); } + if (strcasecmp(do_license_check, "no") == 0) + LicenseCheck = 0; + else if (strcasecmp(do_license_check, "yes") == 0) + LicenseCheck = 1; + else if (strcasecmp(do_license_check, "always") == 0) + LicenseCheck = 2; + else + errx(1, "Unknown value of the configuration variable" + "CHECK_LICENSE"); + + if (LicenseCheck) + load_license_lists(); + /* Get all the remaining package names, if any */ for (; argc > 0; --argc, ++argv) { lpkg_t *lpp; diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index 7fad55af7ce..4fd1da15359 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.88 2009/08/02 17:56:44 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.89 2009/08/06 16:53:34 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" #endif @@ -6,7 +6,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: perform.c,v 1.88 2009/08/02 17:56:44 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.89 2009/08/06 16:53:34 joerg Exp $"); /*- * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> @@ -478,6 +478,8 @@ read_buildinfo(struct pkg_task *pkg) else if (strncmp(data, "USE_ABI_DEPENDS=", 16) == 0) pkg->buildinfo[BI_USE_ABI_DEPENDS] = dup_value(data, eol); + else if (strncmp(data, "LICENSE=", 8) == 0) + pkg->buildinfo[BI_LICENSE] = dup_value(data, eol); } if (pkg->buildinfo[BI_OPSYS] == NULL || pkg->buildinfo[BI_OS_VERSION] == NULL || @@ -1241,6 +1243,34 @@ check_vulnerable(struct pkg_task *pkg) return 0; } +static int +check_license(struct pkg_task *pkg) +{ + if (LicenseCheck == 0) + return 0; + + if ((pkg->buildinfo[BI_LICENSE] == NULL || + *pkg->buildinfo[BI_LICENSE] == '\0')) { + + if (LicenseCheck == 1) + return 0; + warnx("No LICENSE set for package `%s'", pkg->pkgname); + return 1; + } + + switch (acceptable_license(pkg->buildinfo[BI_LICENSE])) { + case 0: + warnx("License `%s' of package `%s' is not acceptable", + pkg->buildinfo[BI_LICENSE], pkg->pkgname); + return 1; + case 1: + return 0; + default: + warnx("Invalid LICENSE for package `%s'", pkg->pkgname); + return 1; + } +} + /* * Install a single package. */ @@ -1276,9 +1306,15 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level) if (check_signature(pkg, invalid_sig)) goto clean_memory; + if (read_buildinfo(pkg)) + goto clean_memory; + if (check_vulnerable(pkg)) goto clean_memory; + if (check_license(pkg)) + goto clean_memory; + if (pkg->meta_data.meta_mtree != NULL) warnx("mtree specification in pkg `%s' ignored", pkg->pkgname); @@ -1317,9 +1353,6 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level) goto clean_memory; } - if (read_buildinfo(pkg)) - goto clean_memory; - if (check_platform(pkg)) goto clean_memory; diff --git a/pkgtools/pkg_install/files/add/pkg_add.1 b/pkgtools/pkg_install/files/add/pkg_add.1 index 474ccdd807b..0970df9af20 100644 --- a/pkgtools/pkg_install/files/add/pkg_add.1 +++ b/pkgtools/pkg_install/files/add/pkg_add.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_add.1,v 1.36 2009/04/10 04:03:11 reed Exp $ +.\" $NetBSD: pkg_add.1,v 1.37 2009/08/06 16:53:34 joerg Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -498,7 +498,9 @@ The following variables change the behavior of .Nm and are described in .Xr pkg_install.conf 5 : -.Bl -tag -width CERTIFICATE_ANCHOR_PKGS +.Bl -tag -compact -offset indent -width CERTIFICATE_ANCHOR_PKGS +.It Ev CHECK_LICENSE +.It Ev CHECK_VULNERABILITIES .It Ev CERTIFICATE_ANCHOR_PKGS .It Ev CERTIFICATE_CHAIN .It Ev VERIFIED_INSTALLATION diff --git a/pkgtools/pkg_install/files/add/pkg_add.cat1 b/pkgtools/pkg_install/files/add/pkg_add.cat1 index e4c23dbdda9..0f4b868dc70 100644 --- a/pkgtools/pkg_install/files/add/pkg_add.cat1 +++ b/pkgtools/pkg_install/files/add/pkg_add.cat1 @@ -289,12 +289,11 @@ EEXXAAMMPPLLEESS CCOONNFFIIGGUURRAATTIIOONN VVAARRIIAABBLLEESS The following variables change the behavior of ppkkgg__aadddd and are described in pkg_install.conf(5): - - CERTIFICATE_ANCHOR_PKGS - - CERTIFICATE_CHAIN - - VERIFIED_INSTALLATION + CHECK_LICENSE + CHECK_VULNERABILITIES + CERTIFICATE_ANCHOR_PKGS + CERTIFICATE_CHAIN + VERIFIED_INSTALLATION SSEEEE AALLSSOO pkg_admin(1), pkg_create(1), pkg_delete(1), pkg_info(1), tar(1), diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.1 b/pkgtools/pkg_install/files/delete/pkg_delete.1 index e0039dcf0d4..f32fce784f7 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.1 +++ b/pkgtools/pkg_install/files/delete/pkg_delete.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_delete.1,v 1.20 2009/04/24 14:00:25 joerg Exp $ +.\" $NetBSD: pkg_delete.1,v 1.21 2009/08/06 16:53:34 joerg Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -25,7 +25,7 @@ .Nd a utility for deleting previously installed software package distributions .Sh SYNOPSIS .Nm -.Op Fl ADFfNnORrVv +.Op Fl ADFfkNnORrVv .Bk -words .Op Fl K Ar pkg_dbdir .Ek @@ -48,6 +48,10 @@ Before any action is executed, checks for packages that are marked as .Cm preserved or have depending packages left. +If the +.Fl k +flag is given, preserved packages are removed from the list of packages +to remove. Unless the .Fl f flag is given, diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.c b/pkgtools/pkg_install/files/delete/pkg_delete.c index e127a0621f0..20aa62bbd40 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.c +++ b/pkgtools/pkg_install/files/delete/pkg_delete.c @@ -34,7 +34,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_delete.c,v 1.7 2009/08/02 17:56:44 joerg Exp $"); +__RCSID("$NetBSD: pkg_delete.c,v 1.8 2009/08/06 16:53:34 joerg Exp $"); #if HAVE_ERR_H #include <err.h> @@ -48,6 +48,7 @@ static const char *pkgdb; static const char *destdir; static const char *prefix; +static int keep_preserve; static int no_deinstall; static int find_by_filename; static int unregister_only; @@ -59,7 +60,7 @@ static int delete_automatic_leaves; static void usage(void) { - fprintf(stderr, "usage: pkg_delete [-DFfNnORrVv] [-K pkg_dbdir]" + fprintf(stderr, "usage: pkg_delete [-DFfkNnORrVv] [-K pkg_dbdir]" " [-P destdir] [-p prefix] pkg-name ...\n"); exit(1); } @@ -365,18 +366,23 @@ find_new_leaves(lpkg_head_t *pkgs) static int find_preserve_pkgs(lpkg_head_t *pkgs) { - lpkg_t *lpp; + lpkg_t *lpp, *lpp_next; char *fname; int found_preserve; found_preserve = 0; - TAILQ_FOREACH(lpp, pkgs, lp_link) { + TAILQ_FOREACH_SAFE(lpp, pkgs, lp_link, lpp_next) { fname = pkgdb_pkg_file(lpp->lp_name, PRESERVE_FNAME); if (!fexists(fname)) { free(fname); continue; } free(fname); + if (keep_preserve) { + TAILQ_REMOVE(pkgs, lpp, lp_link); + free_lpkg(lpp); + continue; + } if (!found_preserve) warnx("The following packages are marked as not " "for deletion:"); @@ -772,7 +778,7 @@ main(int argc, char *argv[]) TAILQ_INIT(&sorted_pkgs); setprogname(argv[0]); - while ((ch = getopt(argc, argv, "ADFfNnORrVvK:P:p:")) != -1) { + while ((ch = getopt(argc, argv, "ADFfK:kNnOP:p:RrVv")) != -1) { switch (ch) { case 'A': delete_automatic_leaves = 1; @@ -789,6 +795,9 @@ main(int argc, char *argv[]) case 'K': pkgdb = optarg; break; + case 'k': + keep_preserve = 1; + break; case 'N': unregister_only = 1; break; diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 index d81449efc12..24b58c1dac6 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 +++ b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 @@ -5,7 +5,7 @@ NNAAMMEE age distributions SSYYNNOOPPSSIISS - ppkkgg__ddeelleettee [--AADDFFffNNnnOORRrrVVvv] [--KK _p_k_g___d_b_d_i_r] [--PP _d_e_s_t_d_i_r] [--pp _p_r_e_f_i_x] + ppkkgg__ddeelleettee [--AADDFFffkkNNnnOORRrrVVvv] [--KK _p_k_g___d_b_d_i_r] [--PP _d_e_s_t_d_i_r] [--pp _p_r_e_f_i_x] _p_k_g_-_n_a_m_e _._._. DDEESSCCRRIIPPTTIIOONN @@ -13,8 +13,10 @@ DDEESSCCRRIIPPTTIIOONN ously installed with the pkg_add(1) command. The given packages are sorted, so that the dependencies of a package are deleted after the pack- age. Before any action is executed, ppkkgg__ddeelleettee checks for packages that - are marked as pprreesseerrvveedd or have depending packages left. Unless the --ff - flag is given, ppkkgg__ddeelleettee stops on the first error. + are marked as pprreesseerrvveedd or have depending packages left. If the --kk flag + is given, preserved packages are removed from the list of packages to + remove. Unless the --ff flag is given, ppkkgg__ddeelleettee stops on the first + error. WWAARRNNIINNGG _S_i_n_c_e _t_h_e ppkkgg__ddeelleettee _c_o_m_m_a_n_d _m_a_y _e_x_e_c_u_t_e _s_c_r_i_p_t_s _o_r _p_r_o_g_r_a_m_s _p_r_o_v_i_d_e_d _b_y diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index 1ffa3261f35..c87d48566ea 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.56 2009/08/02 17:56:45 joerg Exp $ */ +/* $NetBSD: lib.h,v 1.57 2009/08/06 16:53:34 joerg Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -183,7 +183,8 @@ typedef enum bi_ent_t { BI_MACHINE_ARCH, /* 2 */ BI_IGNORE_RECOMMENDED, /* 3 */ BI_USE_ABI_DEPENDS, /* 4 */ - BI_ENUM_COUNT /* 5 */ + BI_LICENSE, /* 5 */ + BI_ENUM_COUNT /* 6 */ } bi_ent_t; /* Types */ @@ -425,6 +426,7 @@ extern const char *certs_pkg_vulnerabilities; extern const char *check_vulnerabilities; extern const char *config_file; extern const char *config_pkg_path; +extern const char *do_license_check; extern const char *verified_installation; extern const char *gpg_cmd; extern const char *gpg_keyring_pkgvuln; diff --git a/pkgtools/pkg_install/files/lib/parse-config.c b/pkgtools/pkg_install/files/lib/parse-config.c index 60aabf0d0ac..082ef23511c 100644 --- a/pkgtools/pkg_install/files/lib/parse-config.c +++ b/pkgtools/pkg_install/files/lib/parse-config.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse-config.c,v 1.5 2009/04/25 21:31:14 joerg Exp $ */ +/* $NetBSD: parse-config.c,v 1.6 2009/08/06 16:53:34 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: parse-config.c,v 1.5 2009/04/25 21:31:14 joerg Exp $"); +__RCSID("$NetBSD: parse-config.c,v 1.6 2009/08/06 16:53:34 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -58,6 +58,7 @@ const char *certs_packages; const char *certs_pkg_vulnerabilities; const char *check_vulnerabilities; const char *config_pkg_path; +const char *do_license_check; const char *verified_installation; const char *gpg_cmd; const char *gpg_keyring_pkgvuln; @@ -80,6 +81,7 @@ static struct config_variable { { "CERTIFICATE_ANCHOR_PKGS", &certs_packages }, { "CERTIFICATE_ANCHOR_PKGVULN", &certs_pkg_vulnerabilities }, { "CERTIFICATE_CHAIN", &cert_chain_file }, + { "CHECK_LICENSE", &do_license_check }, { "CHECK_VULNERABILITIES", &check_vulnerabilities }, { "DEFAULT_ACCEPTABLE_LICENSES", &default_acceptable_licenses }, { "GPG", &gpg_cmd }, @@ -123,6 +125,9 @@ pkg_install_config(void) if (check_vulnerabilities == NULL) check_vulnerabilities = "never"; + if (do_license_check == NULL) + do_license_check = "no"; + if ((value = getenv("PKG_PATH")) != NULL) config_pkg_path = value; diff --git a/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in b/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in index 2f38101fee0..b4f917d4e13 100644 --- a/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in +++ b/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_install.conf.5.in,v 1.7 2009/07/24 19:06:45 joerg Exp $ +.\" $NetBSD: pkg_install.conf.5.in,v 1.8 2009/08/06 16:53:34 joerg Exp $ .\" .\" Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -70,6 +70,18 @@ contained in this file. Path to a file containing additional certificates that can be used for completing certificate chains when validating binary packages or pkg-vulnerabilities files. +.It Dv CHECK_LICENSE +Check the license conditions of packages before installing them. +Supported values are: +.Bl -tag -width interactiveXX +.It Dv no +The check is not performed. +.It Dv yes +The check is performed if the package has license conditions set. +.It Dv always +Passing the license check is required. +Missing license conditions are considered an error. +.El .It Dv CHECK_VULNERABILITIES Check for vulnerabilities when installing packages. Supported values are: diff --git a/pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in b/pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in index 40807c9c10d..eaaa41dabb6 100644 --- a/pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in +++ b/pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in @@ -37,6 +37,18 @@ DDEESSCCRRIIPPTTIIOONN used for completing certificate chains when validating binary packages or pkg-vulnerabilities files. + CHECK_LICENSE + Check the license conditions of packages before installing them. + Supported values are: + + no The check is not performed. + + yes The check is performed if the package has license + conditions set. + + always Passing the license check is required. Missing + license conditions are considered an error. + CHECK_VULNERABILITIES Check for vulnerabilities when installing packages. Supported values are: @@ -53,7 +65,8 @@ DDEESSCCRRIIPPTTIIOONN DEFAULT_ACCEPTABLE_LICENSES List of common Free and Open Source licenses packages are allowed to carry. The default value contains all OSI approved licenses - in pkgsrc on the date pkg_install was released. + in pkgsrc on the date pkg_install was released. License names + are case-sensitive. GPG Path to gpg(1), which can be used to verify the signature in the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file when running diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index e78635a5028..b8b08849479 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.133 2009/08/02 17:56:45 joerg Exp $ */ +/* $NetBSD: version.h,v 1.134 2009/08/06 16:53:34 joerg Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION "20090727" +#define PKGTOOLS_VERSION "20090806" #endif /* _INST_LIB_VERSION_H_ */ |