pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20090806:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e2f09e4f1078
branches:  trunk
changeset: 396970:e2f09e4f1078
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu Aug 06 16:53:34 2009 +0000

description:
pkg_install-20090806:
- pkg_add: add support to check license conditions before installation
- pkg_delete: add -k option to skip over preserve packages.

diffstat:

 pkgtools/pkg_install/files/add/add.h                    |   3 +-
 pkgtools/pkg_install/files/add/main.c                   |  18 ++++++-
 pkgtools/pkg_install/files/add/perform.c                |  43 +++++++++++++++-
 pkgtools/pkg_install/files/add/pkg_add.1                |   6 +-
 pkgtools/pkg_install/files/add/pkg_add.cat1             |  11 +--
 pkgtools/pkg_install/files/delete/pkg_delete.1          |   8 ++-
 pkgtools/pkg_install/files/delete/pkg_delete.c          |  19 +++++-
 pkgtools/pkg_install/files/delete/pkg_delete.cat1       |   8 +-
 pkgtools/pkg_install/files/lib/lib.h                    |   6 +-
 pkgtools/pkg_install/files/lib/parse-config.c           |   9 ++-
 pkgtools/pkg_install/files/lib/pkg_install.conf.5.in    |  14 +++++-
 pkgtools/pkg_install/files/lib/pkg_install.conf.cat5.in |  15 +++++-
 pkgtools/pkg_install/files/lib/version.h                |   4 +-
 13 files changed, 130 insertions(+), 34 deletions(-)

diffs (truncated from 468 to 300 lines):

diff -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/add/add.h
--- a/pkgtools/pkg_install/files/add/add.h      Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/add/add.h      Thu Aug 06 16:53:34 2009 +0000
@@ -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 NoRecord;
 extern Boolean Force;
 extern Boolean Automatic;
+extern int LicenseCheck;
 extern int Replace;
 
 int     make_hierarchy(char *);
diff -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/add/main.c
--- a/pkgtools/pkg_install/files/add/main.c     Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/add/main.c     Thu Aug 06 16:53:34 2009 +0000
@@ -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 NoRecord = FALSE;
 Boolean Automatic = FALSE;
 
+int    LicenseCheck = 0;
 int     Replace = 0;
 
 static void
@@ -161,6 +162,19 @@
                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 -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Thu Aug 06 16:53:34 2009 +0000
@@ -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@localhost>
@@ -478,6 +478,8 @@
                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 @@
        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 @@
        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 @@
                goto clean_memory;
        }
 
-       if (read_buildinfo(pkg))
-               goto clean_memory;
-
        if (check_platform(pkg))
                goto clean_memory;
 
diff -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Thu Aug 06 16:53:34 2009 +0000
@@ -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 @@
 .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 -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/add/pkg_add.cat1
--- a/pkgtools/pkg_install/files/add/pkg_add.cat1       Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.cat1       Thu Aug 06 16:53:34 2009 +0000
@@ -289,12 +289,11 @@
 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 -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/delete/pkg_delete.1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.1    Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.1    Thu Aug 06 16:53:34 2009 +0000
@@ -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 @@
 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 -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/delete/pkg_delete.c
--- a/pkgtools/pkg_install/files/delete/pkg_delete.c    Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.c    Thu Aug 06 16:53:34 2009 +0000
@@ -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 *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 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 @@
 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 @@
        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 @@
                case 'K':
                        pkgdb = optarg;
                        break;
+               case 'k':
+                       keep_preserve = 1;
+                       break;
                case 'N':
                        unregister_only = 1;
                        break;
diff -r 52518e1e382c -r e2f09e4f1078 pkgtools/pkg_install/files/delete/pkg_delete.cat1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Thu Aug 06 15:41:54 2009 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Thu Aug 06 16:53:34 2009 +0000
@@ -5,7 +5,7 @@
      age distributions



Home | Main Index | Thread Index | Old Index