src/modules/publish/dependencies.py
author Shawn Walker <shawn.walker@oracle.com>
Wed, 27 Jul 2011 13:42:21 -0700
changeset 2476 25342deb3749
parent 2462 d89a0da0a548
child 2493 5db1603f0c3f
permissions -rw-r--r--
3262 symlink loops can cause operation traceback 14805 action creation shouldn't allow multiple values for key attributes 14807 depend action doesn't validate fmri attribute syntax 17863 multiple values for standard pkg attributes can cause publication traceback 18629 validate_fsobj_common needs to check for lists of attribute values 18635 pkgdepend shouldn't require build-release in fmris 18717 traceback from pkgsend publish when -s forgotten 18718 pkgsend publish does not display errors 18719 depend action's clean_fmri needs to be sent to the dustbin 18720 action validation shouldn't permit strings for numeric attributes 18721 user action install doesn't preserve password and lastchg entries for existing users
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1500
diff changeset
     1
#!/usr/bin/python
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     2
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     4
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     8
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    13
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    19
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    21
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    22
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    23
#
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
    24
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    25
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    26
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
    27
import copy
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    28
import itertools
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
    29
import operator
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    30
import os
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    31
import re
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
    32
import urllib
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    33
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    34
from collections import namedtuple
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    35
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    36
import pkg.actions as actions
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
    37
import pkg.client.api as api
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
    38
import pkg.client.api_errors as apx
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    39
import pkg.flavor.base as base
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    40
import pkg.flavor.elf as elf_dep
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    41
import pkg.flavor.hardlink as hardlink
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    42
import pkg.flavor.script as script
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
    43
import pkg.flavor.smf_manifest as smf_manifest
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    44
import pkg.fmri as fmri
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    45
import pkg.manifest as manifest
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    46
import pkg.portable as portable
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    47
import pkg.variant as variants
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    48
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
    49
paths_prefix = "%s.path" % base.Dependency.DEPEND_DEBUG_PREFIX
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
    50
files_prefix = "%s.file" % base.Dependency.DEPEND_DEBUG_PREFIX
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
    51
reason_prefix = "%s.reason" % base.Dependency.DEPEND_DEBUG_PREFIX
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    52
type_prefix = "%s.type" % base.Dependency.DEPEND_DEBUG_PREFIX
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    53
target_prefix = "%s.target" % base.Dependency.DEPEND_DEBUG_PREFIX
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    54
bypassed_prefix = "%s.bypassed" % base.Dependency.DEPEND_DEBUG_PREFIX
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
    55
via_links_prefix = "%s.via-links" % base.Dependency.DEPEND_DEBUG_PREFIX
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    56
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    57
# A tag used to hold the product of the paths_prefix and files_prefix
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    58
# contents, used when bypassing dependency generation
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
    59
fullpaths_prefix = "%s.fullpath" % base.Dependency.DEPEND_DEBUG_PREFIX
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    60
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    61
Entries = namedtuple("Entries", ["delivered", "installed"])
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    62
# This namedtuple is used to hold two items. The first, delivered, is used to
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    63
# hold items which are part of packages being delivered.  The second, installed,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    64
# is used to hold items which are part of packages installed on the system.
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
    65
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    66
class DependencyError(Exception):
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    67
        """The parent class for all dependency exceptions."""
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    68
        pass
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    69
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
    70
class MultiplePackagesPathError(DependencyError):
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    71
        """This exception is used when a file dependency has paths which cause
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    72
        two or more packages to deliver files which fulfill the dependency under
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    73
        some combination of variants."""
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    74
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    75
        def __set_pkg_name(self, name):
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    76
                self.__pkg_name = str(name)
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    77
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    78
        pkg_name = property(lambda self: self.__pkg_name, __set_pkg_name)
2428
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
    79
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    80
        def __init__(self, res, source, vc, pkg_name=None):
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    81
                self.res = res
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    82
                self.source = source
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
    83
                self.vc = vc
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    84
                self.pkg_name = pkg_name
2428
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
    85
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
    86
        def __str__(self):
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    87
                if self.vc.sat_set and self.pkg_name:
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    88
                        return _("The file dependency %(src)s delivered in "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    89
                            "package %(pkg)s has paths which resolve to "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    90
                            "multiple packages under this combination of "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    91
                            "variants:\n%(vars)s\nThe actions "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    92
                            "are:\n%(acts)s") % {
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    93
                                "src":self.source,
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    94
                                "acts":"\n".join(
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    95
                                    ["\t%s" % a for a in self.res]),
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    96
                                "vars":"\n".join([
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    97
                                    " ".join([
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    98
                                        ("%s:%s" % (name, val))
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
    99
                                        for name, val in grp
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   100
                                    ])
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   101
                                    for grp in self.vc.sat_set]),
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   102
                                "pkg": self.pkg_name
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   103
                            }
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   104
                elif self.vc.sat_set:
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   105
                        return _("The file dependency %(src)s has paths which"
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   106
                            "resolve to multiple packages under this "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   107
                            "combination of variants:\n%(vars)s\nThe actions "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   108
                            "are:\n%(acts)s") % {
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   109
                                "src":self.source,
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   110
                                "acts":"\n".join(
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   111
                                    ["\t%s" % a for a in self.res]),
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   112
                                "vars":"\n".join([
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   113
                                    " ".join([
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   114
                                        ("%s:%s" % (name, val))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   115
                                        for name, val in grp
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   116
                                    ])
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   117
                                    for grp in self.vc.sat_set])
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   118
                            }
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   119
                elif self.pkg_name:
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   120
                        return _("The file dependency %(src)s delivered in "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   121
                            "%(pkg)s has paths which resolve to multiple "
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   122
                            "packages.\nThe actions are:\n%(acts)s") % {
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   123
                                "src":self.source,
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   124
                                "acts":"\n".join(
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   125
                                ["\t%s" % a for a in self.res]),
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   126
                                "pkg":self.pkg_name
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
   127
                            }
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   128
                else:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   129
                        return _("The file dependency %(src)s has paths which "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   130
                            "resolve to multiple packages.\nThe actions "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   131
                            "are:\n%(acts)s") % {
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   132
                                "src":self.source,
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   133
                                "acts":"\n".join(
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   134
                                ["\t%s" % a for a in self.res])
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   135
                            }
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   136
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   137
class AmbiguousPathError(DependencyError):
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   138
        """This exception is used when multiple packages deliver a path which
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   139
        is depended upon."""
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   140
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   141
        def __init__(self, pkgs, source):
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   142
                self.pkgs = pkgs
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   143
                self.source = source
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   144
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   145
        def __str__(self):
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   146
                return _("The file dependency %(src)s depends on a path "
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   147
                    "delivered by multiple packages. Those packages "
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   148
                    "are:%(pkgs)s") % {
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   149
                        "src":self.source,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   150
                        "pkgs":" ".join([str(p) for p in self.pkgs])
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   151
                    }
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   152
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   153
class UnresolvedDependencyError(DependencyError):
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   154
        """This exception is used when no package delivers a file which is
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   155
        depended upon."""
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
   156
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   157
        def __init__(self, pth, file_dep, pvars):
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   158
                self.path = pth
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   159
                self.file_dep = file_dep
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   160
                self.pvars = pvars
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   161
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   162
        def __str__(self):
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   163
                if self.pvars.not_sat_set:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   164
                        return _("%(pth)s has unresolved dependency '%(dep)s' "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   165
                            "under the following combinations of "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   166
                            "variants:\n%(combo)s") % \
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   167
                            {
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   168
                                "pth":self.path,
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   169
                                "dep":self.file_dep,
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   170
                                "combo":"\n".join([
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   171
                                    " ".join([
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   172
                                        ("%s:%s" % (name, val))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   173
                                        for name, val in sorted(grp)
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   174
                                    ])
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   175
                                    for grp in self.pvars.not_sat_set
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   176
                            ])}
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   177
                else:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   178
                        return _("%(pth)s has unresolved dependency "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   179
                            "'%(dep)s'.") % \
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   180
                            { "pth":self.path, "dep":self.file_dep }
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   181
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   182
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   183
class MissingPackageVariantError(DependencyError):
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   184
        """This exception is used when an action is tagged with a variant or
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   185
        variant value which the package is not tagged with."""
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   186
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   187
        def __init__(self, act_vars, pkg_vars, pth):
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   188
                self.act_vars = act_vars
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   189
                self.pkg_vars = pkg_vars
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   190
                self.path = pth
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   191
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   192
        def __str__(self):
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   193
                return _("The action delivering %(path)s is tagged with a "
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   194
                    "variant type or value not tagged on the package. "
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   195
                    "Dependencies on this file may fail to be reported.\n"
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   196
                    "The action's variants are: %(act)s\nThe package's "
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   197
                    "variants are: %(pkg)s") % {
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   198
                        "path": self.path,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   199
                        "act": self.act_vars,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   200
                        "pkg": self.pkg_vars
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   201
                    }
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
   202
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   203
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   204
class BadDependencyFmri(DependencyError):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   205
        """This exception is used when dependency actions have text in their
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   206
        fmri attributes which are not valid fmris."""
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   207
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   208
        def __init__(self, pkg, fmris):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   209
                self.pkg = pkg
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   210
                self.fmris = fmris
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   211
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   212
        def __str__(self):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   213
                return _("The package %(pkg)s contains depend actions with "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   214
                    "values in their fmri attributes which are not valid "
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   215
                    "fmris.  The bad values are:\n%(fmris)s\n") % {
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   216
                    "pkg": self.pkg,
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   217
                    "fmris": "\n".join(["\t%s" % f for f in sorted(self.fmris)])
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   218
                }
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   219
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   220
2428
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   221
class BadPackageFmri(DependencyError):
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   222
        """This exception is used when a manifest's fmri isn't a valid fmri."""
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   223
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   224
        def __init__(self, path, e):
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   225
                self.path = path
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   226
                self.exc = e
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   227
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   228
        def __str__(self):
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   229
                return _("The manifest '%(path)s' has an invalid package "
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   230
                    "FMRI:\n\t%(exc)s") % { "path": self.path, "exc": self.exc }
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   231
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
   232
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   233
class ExtraVariantedDependency(DependencyError):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   234
        """This exception is used when one or more dependency actions have a
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   235
        variant set on them which is not in the package's set of variants."""
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   236
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   237
        def __init__(self, pkg, reason_variants, manual_dep):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   238
                self.pkg = pkg
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   239
                assert len(reason_variants) > 0
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   240
                self.rvs = reason_variants
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   241
                self.manual = manual_dep
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   242
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   243
        def __str__(self):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   244
                s = ""
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   245
                for r, diff in sorted(self.rvs.iteritems()):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   246
                        for kind in diff.type_diffs:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   247
                                s += _("\t%(r)-15s Variant '%(kind)s' is not "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   248
                                    "declared.\n") % \
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   249
                                    {"r":r, "kind":kind}
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   250
                        for k, v in diff.value_diffs:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   251
                                s += _("\t%(r)-15s Variant '%(kind)s' is not "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   252
                                    "declared to have value '%(val)s'.\n") % \
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   253
                                    {"r":r, "val":v, "kind":k}
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   254
                if not self.manual:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   255
                        return _("The package '%(pkg)s' contains actions with "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   256
                            "the\npaths seen below which have variants set on "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   257
                            "them which are not set on the\npackage.  These "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   258
                            "variants must be set on the package or removed "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   259
                            "from the actions.\n\n%(rvs)s") % {
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   260
                            "pkg": self.pkg,
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   261
                            "rvs": s
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   262
                        }
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   263
                else:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   264
                        return _("The package '%(pkg)s' contains manually "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   265
                            "specified dependencies\nwhich have variants set "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   266
                            "on them which are not set on the package.  "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   267
                            "These\nvariants must be set on the package or "
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   268
                            "removed from the actions.\n\n%(rvs)s") % {
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   269
                            "pkg": self.pkg,
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   270
                            "rvs": s
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   271
                        }
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   272
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   273
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   274
class __NotSubset(DependencyError):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   275
        def __init__(self, diff):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   276
                self.diff = variants.VCTDifference(tuple(diff.type_diffs),
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   277
                    tuple(diff.value_diffs))
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   278
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
   279
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   280
def list_implicit_deps(file_path, proto_dirs, dyn_tok_conv, run_paths,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   281
    remove_internal_deps=True, convert=True, ignore_bypass=False):
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   282
        """Given the manifest provided in file_path, use the known dependency
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   283
        generators to produce a list of dependencies the files delivered by
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   284
        the manifest have.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   285
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   286
        'file_path' is the path to the manifest for the package.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   287
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   288
        'proto_dirs' is a list of paths to proto areas which hold the files that
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   289
        will be delivered by the package.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   290
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   291
        'dyn_tok_conv' is the dictionary which maps the dynamic tokens, like
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   292
        $PLATFORM, to the values they should be expanded to.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   293
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   294
        'run_paths' contains the run paths that are used to find modules.
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   295
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   296
        'convert' determines whether PublishingDependencies will be transformed
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   297
        to DependencyActions prior to being returned.  This is primarily an
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   298
        option to facilitate testing and debugging.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   299
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   300
        'ignore_bypass' determines whether to bypass generation of dependencies
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   301
        against certain files or directories.  This is primarily an option to
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   302
        facilitate testing and debugging.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   303
        """
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   304
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   305
        m, missing_manf_files = __make_manifest(file_path, proto_dirs)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   306
        pkg_vars = m.get_all_variants()
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   307
        deps, elist, missing, pkg_attrs = list_implicit_deps_for_manifest(m,
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   308
            proto_dirs, pkg_vars, dyn_tok_conv, run_paths,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   309
            ignore_bypass=ignore_bypass)
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   310
        rid_errs = []
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   311
        if remove_internal_deps:
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   312
                deps, rid_errs = resolve_internal_deps(deps, m, proto_dirs,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   313
                    pkg_vars)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   314
        if convert:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   315
                deps = convert_to_standard_dep_actions(deps)
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   316
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   317
        return deps, missing_manf_files + elist + rid_errs, missing, pkg_attrs
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   318
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   319
def convert_to_standard_dep_actions(deps):
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   320
        """Convert pkg.base.Dependency objects to
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   321
        pkg.actions.dependency.Dependency objects."""
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   322
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   323
        res = []
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   324
        for d in deps:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   325
                tmp = []
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   326
                for c in d.dep_vars.not_sat_set:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   327
                        attrs = d.attrs.copy()
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   328
                        attrs.update(c)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   329
                        tmp.append(actions.depend.DependencyAction(**attrs))
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   330
                if not tmp:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   331
                        tmp.append(actions.depend.DependencyAction(**d.attrs))
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   332
                res.extend(tmp)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   333
        return res
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   334
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   335
def resolve_internal_deps(deps, mfst, proto_dirs, pkg_vars):
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   336
        """Given a list of dependencies, remove those which are satisfied by
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   337
        others delivered by the same package.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   338
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   339
        'deps' is a list of Dependency objects.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   340
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   341
        'mfst' is the Manifest of the package that delivered the dependencies
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   342
        found in deps.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   343
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   344
        'proto_dir' is the path to the proto area which holds the files that
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   345
        will be delivered by the package.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   346
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   347
        'pkg_vars' are the variants that this package was published against."""
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   348
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   349
        res = []
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   350
        errs = []
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   351
        delivered = {}
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   352
        delivered_bn = {}
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   353
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   354
        files = Entries({}, {})
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   355
        links = {}
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   356
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   357
        # A fake pkg name is used because there is no requirement that a package
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   358
        # name itself to generate its dependencies.  Also, the name is entirely
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   359
        # a private construction which should not escape to the user.
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   360
        add_fmri_path_mapping(files.delivered, links,
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
   361
            fmri.PkgFmri("INTERNAL@0-0", "0"), mfst)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   362
        for a in mfst.gen_actions_by_type("file"):
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   363
                pvars = a.get_variant_template()
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   364
                if not pvars:
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   365
                        pvars = pkg_vars
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   366
                else:
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   367
                        if not pvars.issubset(pkg_vars):
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   368
                                # This happens when an action in a package is
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   369
                                # tagged with a variant type or value which the
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   370
                                # package has not been tagged with.
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   371
                                errs.append(
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   372
                                    MissingPackageVariantError(pvars, pkg_vars,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   373
                                        a.attrs["path"]))
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   374
                        pvars.merge_unknown(pkg_vars)
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   375
                pvc = variants.VariantCombinations(pvars, satisfied=True)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   376
                p = a.attrs["path"]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   377
                bn = os.path.basename(p)
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   378
                delivered_bn.setdefault(bn, copy.copy(pvc))
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
   379
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   380
        for d in deps:
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   381
                etype, pvars = d.resolve_internal(
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   382
                    delivered_files=files.delivered,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   383
                    delivered_base_names=delivered_bn, links=links,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   384
                    resolve_links=resolve_links)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   385
                if etype is None:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   386
                        continue
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   387
                pvars.simplify(pkg_vars)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   388
                d.dep_vars = pvars
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   389
                res.append(d)
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   390
        return res, errs
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   391
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   392
def no_such_file(action, **kwargs):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   393
        """Function to handle dispatch of files not found on the system."""
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   394
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   395
        return [], [base.MissingFile(action.attrs["path"])], {}
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   396
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   397
# Dictionary which maps codes from portable.get_file_type to the functions which
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   398
# find dependencies for those types of files.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   399
dispatch_dict = {
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   400
    portable.ELF: elf_dep.process_elf_dependencies,
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   401
    portable.EXEC: script.process_script_deps,
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   402
    portable.SMF_MANIFEST: smf_manifest.process_smf_manifest_deps,
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   403
    portable.UNFOUND: no_such_file
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   404
}
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   405
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   406
def list_implicit_deps_for_manifest(mfst, proto_dirs, pkg_vars, dyn_tok_conv,
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   407
    run_paths, ignore_bypass=False):
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   408
        """For a manifest, produce the list of dependencies generated by the
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   409
        files it installs.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   410
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   411
        'mfst' is the Manifest of the package that delivered the dependencies
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   412
        found in deps.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   413
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   414
        'proto_dirs' are the paths to the proto areas which hold the files that
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   415
        will be delivered by the package.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   416
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   417
        'pkg_vars' are the variants that this package was published against.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   418
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   419
        'dyn_tok_conv' is the dictionary which maps the dynamic tokens, like
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   420
        $PLATFORM, to the values they should be expanded to.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   421
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   422
        'run_paths' contains the run paths used to find modules, this is
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   423
        overridden by any manifest or action attributes setting
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   424
        'pkg.depend.runpath' (portable.PD_RUN_PATH)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   425
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   426
        'ignore_bypass' set to True will prevent us from looking up any
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   427
        pkg.depend.bypass-generate attributes - this is primarily to aid
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   428
        debugging and testing.
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   429
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   430
        Returns a tuple of three lists.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   431
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   432
        'deps' is a list of dependencies found for the given Manifest.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   433
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   434
        'elist' is a list of errors encountered while finding dependencies.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   435
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   436
        'missing' is a dictionary mapping a file type that isn't recognized by
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   437
        portable.get_file_type to a file which produced that filetype.
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   438
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   439
        'pkg_attrs' is a dictionary containing metadata that was gathered
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   440
        during dependency analysis. Typically these would get turned into
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   441
        AttributeActions for that package. """
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   442
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   443
        deps = []
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   444
        elist = []
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   445
        missing = {}
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   446
        pkg_attrs = {}
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   447
        act_list = list(mfst.gen_actions_by_type("file"))
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   448
        file_types = portable.get_file_type(act_list)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   449
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   450
        if portable.PD_RUN_PATH in mfst:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   451
                # check for multiple values in a set attribute
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   452
                run_path_str = mfst[portable.PD_RUN_PATH]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   453
                es = __verify_run_path(run_path_str)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   454
                if es:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   455
                        return deps, elist + es, missing, pkg_attrs
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   456
                run_paths = run_path_str.split(":")
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   457
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   458
        mf_bypass = []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   459
        if portable.PD_BYPASS_GENERATE in mfst:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   460
                mf_bypass = __makelist(mfst[portable.PD_BYPASS_GENERATE])
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   461
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   462
        for i, file_type in enumerate(file_types):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   463
                a = act_list[i]
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   464
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   465
                a_run_paths = run_paths
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   466
                if portable.PD_RUN_PATH in a.attrs:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   467
                        a_run_path_str = a.attrs[portable.PD_RUN_PATH]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   468
                        es = __verify_run_path(a_run_path_str)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   469
                        if es:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   470
                                return deps, elist + es, missing, pkg_attrs
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   471
                        a_run_paths = a_run_path_str.split(":")
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   472
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   473
                bypass = __makelist(
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   474
                    a.attrs.get(portable.PD_BYPASS_GENERATE, mf_bypass))
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   475
                # If we're bypassing all depdendency generation, we can avoid
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   476
                # calling our dispatch_dict function altogether.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   477
                if (".*" in bypass or "^.*$" in bypass) and not ignore_bypass:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   478
                        pkg_attrs[bypassed_prefix] = "%s:.*" % a.attrs["path"]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   479
                        continue
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   480
                try:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   481
                        func = dispatch_dict[file_type]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   482
                except KeyError:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   483
                        if file_type not in missing:
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   484
                                missing[file_type] = \
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   485
                                    a.attrs[portable.PD_LOCAL_PATH]
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   486
                else:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   487
                        try:
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   488
                                ds, errs, attrs = func(action=a,
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   489
                                    pkg_vars=pkg_vars,
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   490
                                    dyn_tok_conv=dyn_tok_conv,
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   491
                                    run_paths=a_run_paths)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   492
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   493
                                # prune out any dependencies on the files we've
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   494
                                # been asked to avoid creating dependencies on
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   495
                                if bypass and not ignore_bypass:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   496
                                        ds = \
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   497
                                            __bypass_deps(ds, bypass, pkg_attrs)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   498
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   499
                                deps.extend(ds)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   500
                                elist.extend(errs)
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   501
                                __update_pkg_attrs(pkg_attrs, attrs)
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   502
                        except base.DependencyAnalysisError, e:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   503
                                elist.append(e)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   504
        for a in mfst.gen_actions_by_type("hardlink"):
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   505
                deps.extend(hardlink.process_hardlink_deps(a, pkg_vars))
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   506
        return deps, elist, missing, pkg_attrs
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   507
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   508
def __update_pkg_attrs(pkg_attrs, new_attrs):
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   509
        """Update the pkg_attrs dictionary with the contents of new_attrs."""
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   510
        for key in new_attrs:
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   511
                pkg_attrs.setdefault(key, []).extend(new_attrs[key])
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   512
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   513
def __verify_run_path(run_path_str):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   514
        """Verify we've been passed a single item and ensure it contains
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   515
        at least one non-null string."""
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   516
        if not isinstance(run_path_str, str):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   517
                # require a colon separated string to potentially enforce
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   518
                # ordering in the future
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   519
                return [base.DependencyAnalysisError(
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   520
                    _("Manifest specified multiple values for %s rather "
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   521
                    "than a single colon-separated string.") %
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   522
                    portable.PD_RUN_PATH)]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   523
        if set(run_path_str.split(":")) == set([""]):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   524
                return [base.DependencyAnalysisError(
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   525
                    _("Manifest did not specify any entries for %s, expecting "
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   526
                    "a colon-separated string.") % portable.PD_RUN_PATH)]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   527
        return []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   528
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   529
def __makelist(value):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   530
        """Given a value, return it if that value is a list, or if it's a
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   531
        string, return a single-element list of just that string."""
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   532
        if isinstance(value, list):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   533
                return value
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   534
        elif isinstance(value, str):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   535
                if value:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   536
                        return [value]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   537
                else:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   538
                        return []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   539
        else:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   540
                raise ValueError("Value was not a string or a list")
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   541
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   542
def __bypass_deps(ds, bypass, pkg_attrs):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   543
        """Return a list of dependencies, excluding any of those that should be
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   544
        bypassed.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   545
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   546
        ds         the list of dependencies to operate on
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   547
        bypass     a list of paths on which we should not generate dependencies
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   548
        pkg_attrs  the set of package attributes for this manifest, produced as
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   549
                   a by-product of this dependency generation
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   550
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   551
        We support regular expressions as entries in the bypass list, matching
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   552
        one or more files.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   553
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   554
        If a bypass-list entry is provided that does not contain one of the
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   555
        following characters: ["/", "*", "?"], it is assumed to be a filename,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   556
        and expanded to the regular expression ".*/<entry>"
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   557
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   558
        All bypass-list entries are assumed to be regular expressions that are
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   559
        rooted at ^ and $.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   560
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   561
        The special match-all wildcard ".*" is dealt with separately,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   562
        by list_implicit_deps_for_manifest(..)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   563
        """
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   564
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   565
        new_ds = []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   566
        for dep in ds:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   567
                full_paths = set(make_paths(dep))
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   568
                bypassed_files = set()
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   569
                bypass_regexps = []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   570
                try:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   571
                        for item in bypass:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   572
                                # try to determine if this is a regexp,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   573
                                # rather than a filename
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   574
                                if "*" in item or "?" in item:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   575
                                        pass
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   576
                                # if it appears to be a filename, make it match
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   577
                                # all paths to that filename.
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   578
                                elif "/" not in item:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   579
                                        item = ".*%s%s" % (os.path.sep, item)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   580
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   581
                                # always anchor our regular expressions,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   582
                                # otherwise, we get partial matches for files,
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   583
                                # eg. bypassing "foo.c" would otherwise also
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   584
                                # bypass "foo.cc"
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   585
                                if item:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   586
                                        if not item.endswith("$"):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   587
                                                item = item + "$"
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   588
                                        if not item.startswith("^"):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   589
                                                item = "^" + item
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   590
                                        bypass_regexps.append(re.compile(item))
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   591
                except re.error, e:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   592
                        raise base.InvalidDependBypassValue(item, e)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   593
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   594
                for path in full_paths:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   595
                        if path in bypass:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   596
                                bypassed_files.add(path)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   597
                                continue
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   598
                        for regexp in bypass_regexps:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   599
                                if regexp.match(path):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   600
                                        bypassed_files.add(path)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   601
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   602
                if bypassed_files:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   603
                        # remove the old runpath and basename entries from
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   604
                        # the dependency if they were present
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   605
                        dep.attrs.pop(files_prefix, None)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   606
                        dep.attrs.pop(paths_prefix, None)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   607
                        dep.base_names = []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   608
                        dep.run_paths = []
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   609
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   610
                        # determine our new list of paths
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   611
                        full_paths = full_paths - bypassed_files
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   612
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   613
                        dep.full_paths = sorted(list(full_paths))
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   614
                        dep.attrs[fullpaths_prefix] = dep.full_paths
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   615
                        pkg_attrs[bypassed_prefix] = \
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   616
                            sorted(list(bypassed_files))
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   617
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   618
                        # only include the dependency if it still contains data
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   619
                        if full_paths:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   620
                                new_ds.append(dep)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   621
                else:
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   622
                        new_ds.append(dep)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   623
        return new_ds
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   624
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   625
def __make_manifest(fp, basedirs=None, load_data=True):
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   626
        """Given the file path, 'fp', return a Manifest for that path."""
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   627
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   628
        m = manifest.Manifest()
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   629
        try:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   630
                fh = open(fp, "rb")
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   631
        except EnvironmentError, e:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   632
                raise apx._convert_error(e)
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   633
        acts = []
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   634
        missing_files = []
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   635
        accumulate = ""
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   636
        for l in fh:
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   637
                l = l.strip()
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   638
                if l.endswith("\\"):
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   639
                        accumulate += l[0:-1]
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   640
                        continue
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   641
                elif accumulate:
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   642
                        l = accumulate + l
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   643
                        accumulate = ""
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   644
                if not l or l[0] == '#':
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   645
                        continue
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   646
                try:
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   647
                        a, local_path, used_bd = actions.internalizestr(l,
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   648
                            basedirs=basedirs,
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   649
                            load_data=load_data)
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   650
                        if local_path:
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   651
                                assert portable.PD_LOCAL_PATH not in a.attrs
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   652
                                a.attrs[portable.PD_LOCAL_PATH] = local_path
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   653
                                a.attrs[portable.PD_PROTO_DIR] = used_bd
1933
5193ac03ad9f 15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 1908
diff changeset
   654
                                a.attrs[portable.PD_PROTO_DIR_LIST] = basedirs
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   655
                        acts.append(a)
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   656
                except actions.ActionDataError, e:
1908
4bdaf0463bae 15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents: 1887
diff changeset
   657
                        new_a, local_path, used_bd = actions.internalizestr(
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   658
                            l, basedirs=basedirs, load_data=False)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   659
                        if new_a.name == "license":
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   660
                                acts.append(new_a)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   661
                        else:
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   662
                                missing_files.append(base.MissingFile(
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   663
                                    new_a.attrs["path"], basedirs))
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   664
        fh.close()
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 1934
diff changeset
   665
        m.set_content(content=acts)
1500
fb15a23b6915 11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents: 1431
diff changeset
   666
        return m, missing_files
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   667
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   668
def choose_name(fp, mfst):
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   669
        """Find the package name for this manifest.  If it's defined in a set
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   670
        action in the manifest, use that.  Otherwise use the basename of the
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   671
        path to the manifest as the name.  If a proper package fmri is found,
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   672
        then also return a PkgFmri object so that we can track which packages
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   673
        are being processed.
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   674
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   675
        'fp' is the path to the file for the manifest.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   676
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   677
        'mfst' is the Manifest object."""
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   678
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   679
        if mfst is None:
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   680
                return urllib.unquote(os.path.basename(fp)), None
1431
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   681
        name = mfst.get("pkg.fmri", mfst.get("fmri", None))
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   682
        if name is not None:
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   683
                try:
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
   684
                        pfmri = fmri.PkgFmri(name, "5.11")
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   685
                except fmri.IllegalFmri:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   686
                        pfmri = None
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   687
                return name, pfmri
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   688
        return urllib.unquote(os.path.basename(fp)), None
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   689
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
   690
def helper(lst, file_dep, dep_vars, orig_dep_vars):
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   691
        """Creates the depend actions from lst for the dependency and determines
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   692
        which variants have been accounted for.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   693
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   694
        'lst' is a list of fmri, variants pairs. The fmri a package which can
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   695
        satisfy the dependency. The variants are the variants under which it
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   696
        satisfies the dependency.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   697
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   698
        'file_dep' is the dependency that needs to be satisfied.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   699
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   700
        'dep_vars' is the variants under which 'file_dep' has not yet been
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   701
        satisfied.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   702
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   703
        'orig_dep_vars' is the original set of variants under which the
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
   704
        dependency must be satisfied."""
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   705
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   706
        res = []
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   707
        vars = []
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   708
        errs = set()
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   709
        for path, pfmri, delivered_vars, via_links in lst:
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   710
                # If the pfmri package isn't present under any of the variants
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   711
                # where the dependency is, skip it.
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   712
                if not orig_dep_vars.intersects(delivered_vars,
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   713
                    only_not_sat=True):
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   714
                        continue
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   715
                vc = orig_dep_vars.intersection(delivered_vars)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   716
                vc.mark_all_as_satisfied()
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   717
                for found_vars, found_fmri in vars:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   718
                        # Because we don't have the concept of one-of
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   719
                        # dependencies, depending on a file which is delivered
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   720
                        # in multiple packages under a set of variants
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   721
                        # prevents automatic resolution of dependencies.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   722
                        if found_fmri != pfmri and \
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   723
                            found_vars.intersects(delivered_vars):
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   724
                                errs.add(found_fmri)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   725
                                errs.add(pfmri)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   726
                # Find the variants under which pfmri is relevant.
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   727
                action_vars = vc
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   728
                # Mark the variants as satisfied so it's possible to know if
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   729
                # all variant combinations have been covered.
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   730
                dep_vars.mark_as_satisfied(delivered_vars)
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   731
                attrs = file_dep.attrs.copy()
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   732
                attrs.update({"fmri":pfmri.get_short_fmri()})
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   733
                # We know which path satisfies this dependency, so remove the
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   734
                # list of files and paths, and replace them with the single path
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   735
                # that works.
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   736
                attrs.pop(paths_prefix, None)
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   737
                attrs.pop(fullpaths_prefix, None)
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   738
                attrs[files_prefix] = [path]
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   739
                if via_links:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   740
                        via_links.reverse()
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   741
                        attrs[via_links_prefix] = ":".join(via_links)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   742
                # Add this package as satisfying the dependency.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   743
                res.append((actions.depend.DependencyAction(**attrs),
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   744
                    action_vars))
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   745
                vars.append((action_vars, pfmri))
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   746
        if errs:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   747
                # If any packages are in errs, then more than one file delivered
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   748
                # the same path under some configuration of variants. This
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   749
                # situation is unresolvable.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   750
                raise AmbiguousPathError(errs, file_dep)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   751
        return res, dep_vars
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   752
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   753
def make_paths(file_dep):
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   754
        """Find all the possible paths which could satisfy the dependency
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   755
        'file_dep'."""
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   756
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   757
        if file_dep.attrs.get(fullpaths_prefix, []):
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   758
                return file_dep.attrs[fullpaths_prefix]
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   759
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   760
        rps = file_dep.attrs.get(paths_prefix, [""])
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   761
        files = file_dep.attrs[files_prefix]
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   762
        if isinstance(files, basestring):
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   763
                files = [files]
1674
faf484754465 13059 pkgdep generate should analyze python modules using the version of python they use
Brock Pytlik <bpytlik@sun.com>
parents: 1581
diff changeset
   764
        if isinstance(rps, basestring):
faf484754465 13059 pkgdep generate should analyze python modules using the version of python they use
Brock Pytlik <bpytlik@sun.com>
parents: 1581
diff changeset
   765
                rps = [rps]
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   766
        return [os.path.join(rp, f) for rp in rps for f in files]
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   767
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   768
def resolve_links(path, files_dict, links, path_vars, file_dep_attrs, index=1):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   769
        """This method maps a path to one or more real paths and the variants
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   770
        under which each real path can exist.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   771
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   772
        'path' is the original text of the path which is being resolved to a
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   773
        real path.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   774
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   775
        'files_dict' is a dictionary which maps package identity to the files
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   776
        the package delivers and the variants under which each file is present.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   777
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   778
        'links' is an Entries namedtuple which contains two dictionaries.  One
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   779
        dictionary maps package identity to the links that it delivers.  The
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   780
        other dictionary, contains the same information for links that are
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   781
        installed on the system.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   782
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   783
        'path_vars' is the set of variants under which 'path' exists.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   784
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   785
        'file_dep_attrs' is the dictonary of attributes for the file dependency
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   786
        for 'path'.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   787
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   788
        'index' indicates how much of 'path' should be checked against the file
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   789
        and link dictionaries."""
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   790
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   791
        res_paths = []
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   792
        res_links = []
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   793
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   794
        # If the current path is a known file, then we might be done resolving
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   795
        # the path.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   796
        if path in files_dict:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   797
                # Copy the variants so that marking the variants as satisified
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   798
                # doesn't change the sate of 'path_vars.'
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   799
                tmp_vars = copy.copy(path_vars)
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   800
                # If tmp_vars has been satisfied, then this function should
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   801
                # never have been called.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   802
                assert(tmp_vars.is_empty() or not tmp_vars.is_satisfied())
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   803
                # Check each package which delivers a file with this path.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   804
                for pfmri, p_vc in files_dict[path]:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   805
                        # If the file is delivered under a set of variants which
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   806
                        # are irrelevant to the path being considered, skip it.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   807
                        if not path_vars.intersects(p_vc):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   808
                                continue
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   809
                        # The intersection of the variants which apply to the
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   810
                        # current path and the variants for the delivered file
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   811
                        # is the combination of variants where the original
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   812
                        # path resolves to the delivered file.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   813
                        inter = path_vars.intersection(p_vc)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   814
                        inter.mark_all_as_satisfied()
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   815
                        tmp_vars.mark_as_satisfied(p_vc)
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   816
                        res_paths.append((path, pfmri, inter, []))
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   817
                # If the path was resolved under all relevant variants, then
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   818
                # we're done.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   819
                if res_paths and tmp_vars.is_satisfied():
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   820
                        return res_paths, res_links
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   821
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   822
        lst = path.split(os.path.sep)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   823
        # If there aren't any more pieces of the path left to check, then
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   824
        # there's nothing to do so return whatever has been found so far.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   825
        if index > len(lst):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   826
                return res_paths, res_links
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   827
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   828
        # Create the path to check for links.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   829
        cur_path = os.path.join(*lst[0:index])
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   830
        # Find the links which match the path being checked.
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   831
        rel_links = links.get(cur_path, False)
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   832
        # If there weren't any relevant links, then add the next path component
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   833
        # to the path being considered and try again.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   834
        if not rel_links:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   835
                return resolve_links(path, files_dict, links, path_vars,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   836
                    file_dep_attrs, index=index+1)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   837
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   838
        links_found = {}
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   839
        for link_pfmri, link_vc, rel_target in rel_links:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   840
                # If the variants needed to reach the current path and the
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   841
                # variants for the link don't intersect, then the link is
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   842
                # irrelevant.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   843
                if not path_vars.intersects(link_vc):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   844
                        continue
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   845
                vc_intersection = path_vars.intersection(link_vc)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   846
                # If the link only matters under variants that are satisfied,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   847
                # then it's not an interesting link for this purpose.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   848
                if vc_intersection.is_satisfied() and \
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   849
                    not vc_intersection.is_empty():
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   850
                        continue
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   851
                # Apply the link to the current path to get the new relevant
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   852
                # path.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   853
                next_path = os.path.normpath(os.path.join(
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   854
                    os.path.dirname(cur_path), rel_target,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   855
                    *lst[index:])).lstrip(os.path.sep)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   856
                # Index is reset back to the default because an element in path
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   857
                # the link provides could actually be a link.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   858
                rec_paths, link_deps = resolve_links(next_path, files_dict,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   859
                    links, vc_intersection, file_dep_attrs)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   860
                if not rec_paths:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   861
                        continue
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   862
                # The current path was able to be resolved to a real path, so
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   863
                # add the paths and the dependencies from links found to the
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   864
                # results.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   865
                res_links.extend(link_deps)
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   866
                for rec_path, rec_pfmri, rec_vc, via_links in rec_paths:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   867
                        via_links.append(path)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   868
                        assert vc_intersection.intersects(rec_vc), \
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   869
                            "vc:%s\nvc_intersection:%s" % \
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   870
                            (rec_vc, vc_intersection)
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   871
                res_paths.extend(rec_paths)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   872
                links_found.setdefault(next_path, []).append(
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   873
                    (link_pfmri, rec_vc))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   874
        # Now add in the dependencies for the current link.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   875
        for next_path in links_found.keys():
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   876
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   877
                # Create a bin for each possible variant combination.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   878
                vcs = [(vc, []) for vc in path_vars.split_combinations()]
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   879
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   880
                # For each pfmri which delivers this link, if it intersects with
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   881
                # a variant combination, add it to that combination's bin.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   882
                for pfmri, pvc in links_found[next_path]:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   883
                        for vc, l in vcs:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   884
                                if pvc.intersects(vc):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   885
                                        l.append(pfmri)
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   886
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   887
                # Group the variant combinations by their bin of fmris.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   888
                sort_key = operator.itemgetter(1)
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   889
                for pfmris, group in itertools.groupby(
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   890
                    sorted(vcs, key=sort_key),
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   891
                    key=sort_key):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   892
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   893
                        # If pfmris is empty, then no packages delivered the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   894
                        # link under this combination of variants, so skip it.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   895
                        if not pfmris:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   896
                                continue
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   897
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   898
                        # Make a copy of path_vars which is unsatisfied, then
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   899
                        # mark the specific combinations which are satisfied by
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   900
                        # this group of pfmris.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   901
                        dep_vc = path_vars.unsatisfied_copy()
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   902
                        for vc, pfmris in group:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   903
                                dep_vc.mark_as_satisfied(vc)
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   904
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   905
                        dep_type = "require-any"
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   906
                        names = [p.get_short_fmri() for p in pfmris]
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   907
                        # If there's only one fmri delivering this link, then
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   908
                        # it's a require dependency, not a require-any.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   909
                        if len(pfmris) == 1:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   910
                                dep_type = "require"
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   911
                                names = names[0]
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   912
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   913
                        attrs = file_dep_attrs.copy()
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   914
                        attrs.update({
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   915
                            "fmri": names,
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   916
                            type_prefix: "link",
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   917
                            target_prefix: next_path,
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   918
                            files_prefix: [path],
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   919
                            "type": dep_type
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   920
                        })
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   921
                        attrs.pop(paths_prefix, None)
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   922
                        attrs.pop(fullpaths_prefix, None)
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
   923
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   924
                        # The dependency is created with the same variants as
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   925
                        # the path.  This works because the set of relevant
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   926
                        # variants is restricted as links are applied so the
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   927
                        # variants used for the path are the intersection of the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   928
                        # variants for each of the links used to reach the path
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   929
                        # and the variants under which the file is delivered.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   930
                        res_links.append((
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   931
                            actions.depend.DependencyAction(**attrs), dep_vc))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
   932
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   933
        return res_paths, res_links
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   934
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   935
def find_package_using_delivered_files(files_dict, links, file_dep, dep_vars,
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
   936
    orig_dep_vars):
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   937
        """Maps a dependency on a file to the packages which can satisfy that
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   938
        dependency.
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   939
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   940
        'files_dict' is a dictionary mapping paths to a list of fmri, variants
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   941
        pairs.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   942
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   943
        'links' is an Entries namedtuple which contains two dictionaries.  One
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   944
        dictionary maps package identity to the links that it delivers.  The
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   945
        other dictionary, contains the same information for links that are
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   946
        installed on the system.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   947
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   948
        'file_dep' is the dependency that is being resolved.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   949
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   950
        'dep_vars' are the variants for which the dependency has not yet been
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   951
        resolved.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   952
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   953
        'orig_dep_vars' is the original set of variants under which the
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
   954
        dependency must be satisfied."""
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
   955
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
   956
        res = []
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   957
        errs = []
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   958
        link_deps = []
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   959
        multiple_path_errs = []
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   960
        multiple_path_pkgs = set()
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   961
        for p in make_paths(file_dep):
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   962
                # If orig_dep_vars is satisfied, then this function should never
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   963
                # have been called.
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   964
                assert(orig_dep_vars.is_empty() or
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
   965
                    not orig_dep_vars.is_satisfied())
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   966
                paths_info, path_deps = resolve_links(os.path.normpath(p),
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   967
                    files_dict, links, orig_dep_vars, file_dep.attrs.copy())
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   968
                link_deps.extend(path_deps)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   969
                try:
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
   970
                        new_res, dep_vars = helper(paths_info, file_dep,
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
   971
                            dep_vars, orig_dep_vars)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   972
                except AmbiguousPathError, e:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   973
                        errs.append(e)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   974
                else:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   975
                        if not res:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   976
                                res = new_res
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   977
                                continue
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   978
                        # If there are previous results, then it's necessary to
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   979
                        # check the new results against the previous results
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   980
                        # to see if different paths for the same dependency are
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   981
                        # satisfied by different packages.
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   982
                        for a, v in res:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   983
                                for new_a, new_v in new_res:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   984
                                        if a.attrs["fmri"] == \
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   985
                                            new_a.attrs["fmri"]:
1580
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   986
                                                a.attrs[files_prefix].extend(
2763f36d0eda 13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents: 1544
diff changeset
   987
                                                    new_a.attrs[files_prefix])
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   988
                                                continue
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   989
                                        # Check to see if there's a
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   990
                                        # configuration of variants under which
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   991
                                        # both packages can deliver a path which
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
   992
                                        # satisfies the dependencies.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   993
                                        if v.intersects(new_v):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   994
                                                multiple_path_errs.append((a,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   995
                                                    new_a,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   996
                                                    v.intersection(new_v)))
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   997
                                                multiple_path_pkgs.add(a)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   998
                                                multiple_path_pkgs.add(new_a)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
   999
                                        elif new_v.intersects(v):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1000
                                                multiple_path_errs.append((a,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1001
                                                    new_a,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1002
                                                    new_v.intersection(v)))
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1003
                                                multiple_path_pkgs.add(a)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1004
                                                multiple_path_pkgs.add(new_a)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1005
                                        else:
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1006
                                                res.append((new_a, new_v))
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1007
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1008
        for a1, a2, vc in multiple_path_errs:
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1009
                errs.append(MultiplePackagesPathError([a1, a2],
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1010
                    file_dep, vc))
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1011
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1012
        # Extract the actions from res, and only return those which don't have
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1013
        # multiple path errors.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1014
        return [(a, v) for a, v in res if a not in multiple_path_pkgs] + \
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1015
            link_deps, dep_vars, errs
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1016
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1017
def find_package(files, links, file_dep, orig_dep_vars, pkg_vars, use_system):
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1018
        """Find the packages which resolve the dependency. It returns a list of
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1019
        dependency actions with the fmri tag resolved.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1020
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1021
        'files' is an Entries namedtuple which contains two dictionaries.  One
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1022
        dictionary maps package identity to the files that it delivers.  The
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1023
        other dictionary, contains the same information for files that are
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1024
        installed on the system.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1025
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1026
        'links' is an Entries namedtuple which contains two dictionaries.  One
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1027
        dictionary maps package identity to the links that it delivers.  The
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1028
        other dictionary, contains the same information for links that are
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1029
        installed on the system.
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1030
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1031
        'file_dep' is the dependency being resolved.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1032
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1033
        'orig_dep_vars' is the original set of variants under which the
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1034
        dependency must be satisfied.
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1035
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1036
        'pkg_vars' is the variants against which the package was published."""
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1037
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1038
        # If the file dependency has already satisfied all its variants, then
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1039
        # this function should never have been called.
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1040
        assert(orig_dep_vars.is_empty() or not orig_dep_vars.is_satisfied())
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1041
        dep_vars = copy.copy(orig_dep_vars)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1042
        # First try to resolve the dependency against the delivered files.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1043
        res, dep_vars, errs = find_package_using_delivered_files(
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1044
                files.delivered, links, file_dep, dep_vars, orig_dep_vars)
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1045
        # If dep_vars is satisfied then we found at least one solution.  It's
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1046
        # possible that more than one solution was found, causing an error.
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1047
        assert(not dep_vars.is_satisfied() or
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1048
            (res or errs or dep_vars.is_empty()))
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1049
        if ((res or errs) and dep_vars.is_satisfied()) or not use_system:
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1050
                return res, dep_vars, errs
1934
4afdb552a5ec 15647 pkgdepend generates duplicate dependencies if dependency can't be satisfied for all variant values
Richard Lowe <richlowe@richlowe.net>
parents: 1933
diff changeset
  1051
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1052
        # If the dependency isn't fully satisfied, resolve it against the
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1053
        # files installed in the current image.
1934
4afdb552a5ec 15647 pkgdepend generates duplicate dependencies if dependency can't be satisfied for all variant values
Richard Lowe <richlowe@richlowe.net>
parents: 1933
diff changeset
  1054
        #
4afdb552a5ec 15647 pkgdepend generates duplicate dependencies if dependency can't be satisfied for all variant values
Richard Lowe <richlowe@richlowe.net>
parents: 1933
diff changeset
  1055
        # We only need to resolve for the variants not already satisfied
4afdb552a5ec 15647 pkgdepend generates duplicate dependencies if dependency can't be satisfied for all variant values
Richard Lowe <richlowe@richlowe.net>
parents: 1933
diff changeset
  1056
        # above.
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1057
        const_dep_vars = copy.copy(dep_vars)
2191
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1058
        # If dep_vars has been satisfied, then we should have exited the
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1059
        # function above.
da5a579210cc 17700 pkgdep can trace back when two packages deliver paths which satisfy a dependency
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2159
diff changeset
  1060
        assert(const_dep_vars.is_empty() or not const_dep_vars.is_satisfied())
1581
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1061
        inst_res, dep_vars, inst_errs = find_package_using_delivered_files(
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1062
            files.installed, links, file_dep, dep_vars, const_dep_vars)
1581
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1063
        res.extend(inst_res)
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1064
        errs.extend(inst_errs)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1065
        return res, dep_vars, errs
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1066
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1067
def is_file_dependency(act):
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1068
        return act.name == "depend" and \
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1069
            act.attrs.get("fmri", None) == base.Dependency.DUMMY_FMRI and \
2236
7b074b5316ec 16015 pkgdepend needs python runpath hints
Tim Foster <tim.s.foster@oracle.com>
parents: 2191
diff changeset
  1070
            (files_prefix in act.attrs or fullpaths_prefix in act.attrs)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1071
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1072
def merge_deps(dest, src):
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1073
        """Add the information contained in src's attrs to dest."""
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1074
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1075
        for k, v in src.attrs.items():
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1076
                # If any of these dependencies already have a variant set,
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1077
                # then something's gone horribly wrong.
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1078
                assert(not k.startswith("variant."))
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1079
                if k not in dest.attrs:
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1080
                        dest.attrs[k] = v
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1081
                elif v != dest.attrs[k]:
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1082
                        # For now, just merge the values. Duplicate values
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1083
                        # will be removed in a later step.
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1084
                        if isinstance(v, basestring):
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1085
                                v = [v]
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1086
                        if isinstance(dest.attrs[k], list):
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1087
                                dest.attrs[k].extend(v)
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1088
                        else:
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1089
                                t = [dest.attrs[k]]
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1090
                                t.extend(v)
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1091
                                dest.attrs[k] = t
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1092
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1093
def combine(deps, pkg_vars, pkg_fmri, pkg_name):
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1094
        """Combine duplicate dependency actions.
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1095
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1096
        'deps' is a list of tuples. Each tuple contains a dependency action and
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1097
        the variants associated with that dependency.
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1098
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1099
        'pkg_vars' are the variants that the package for which dependencies are
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1100
        being generated was published against.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1101
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1102
        'pkg_fmri' is the name of the package being resolved.  This can be None.
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1103
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1104
        'pkg_name' is either the same as 'pkg_fmri', if 'pkg_fmri' is not None,
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1105
        or it's the basename of the path to the manifest being resolved."""
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1106
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1107
        def action_group_key(d):
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1108
                """Return a key on which the tuples can be sorted and grouped
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1109
                so that the groups match the duplicate actions that the code
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1110
                in pkg.manifest notices."""
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1111
2283
c368082b6a17 16499 pkgdepend resolve -mo includes manifest path in output stream
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2275
diff changeset
  1112
                # d is a tuple containing two items.  d[0] is the action.  d[1]
c368082b6a17 16499 pkgdepend resolve -mo includes manifest path in output stream
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2275
diff changeset
  1113
                # is the VariantCombination for this action.  The
c368082b6a17 16499 pkgdepend resolve -mo includes manifest path in output stream
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2275
diff changeset
  1114
                # VariantCombination isn't useful for our grouping needs.
c368082b6a17 16499 pkgdepend resolve -mo includes manifest path in output stream
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2275
diff changeset
  1115
                return d[0].name, d[0].attrs.get("type", None), \
c368082b6a17 16499 pkgdepend resolve -mo includes manifest path in output stream
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2275
diff changeset
  1116
                    d[0].attrs.get(d[0].key_attr, id(d[0]))
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1117
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1118
        def add_vars(d, d_vars, pkg_vars):
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1119
                """Add the variants 'd_vars' to the dependency 'd', after
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1120
                removing the variants matching those defined in 'pkg_vars'."""
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1121
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1122
                d_vars.simplify(pkg_vars)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1123
                res = []
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1124
                for s in d_vars.sat_set:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1125
                        attrs = d.attrs.copy()
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1126
                        attrs.update(s)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1127
                        t = actions.depend.DependencyAction(**attrs)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1128
                        t.consolidate_attrs()
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1129
                        res.append(t)
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1130
                if not res:
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1131
                        d.consolidate_attrs()
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1132
                        res = [d]
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1133
                return res
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1134
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1135
        res = []
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1136
        req_fmris = []
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1137
        bad_fmris = set()
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1138
        errs = []
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1139
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1140
        # For each group of dependencies (g) for a particular fmri (k) ...
2288
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1141
        for k, group in itertools.groupby(sorted(deps, key=action_group_key),
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1142
            action_group_key):
2288
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1143
                group = list(group)
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1144
                res_dep = group[0][0]
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1145
                res_vars = variants.VariantCombinations(pkg_vars, False)
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1146
                for cur_dep, cur_vars in group:
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1147
                        merge_deps(res_dep, cur_dep)
29c3afa79a1b 18130 pkgdepend doesn't simplify variants where it should
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2283
diff changeset
  1148
                        res_vars.mark_as_satisfied(cur_vars)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1149
                res.append((res_dep, res_vars))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1150
        new_res = []
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1151
        for cur_dep, cur_vars in res:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1152
                if cur_dep.attrs["type"] not in ("require", "require-any"):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1153
                        new_res.append((cur_dep, cur_vars))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1154
                        continue
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1155
                cur_fmris = []
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1156
                for f in cur_dep.attrlist("fmri"):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1157
                        try:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1158
                                # XXX version requires build string; 5.11 is not
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1159
                                # sane.
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
  1160
                                cur_fmris.append(fmri.PkgFmri(f, "5.11"))
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1161
                        except fmri.IllegalFmri:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1162
                                bad_fmris.add(f)
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1163
                skip = False
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1164
                # If we're resolving a pkg with a known name ...
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1165
                if pkg_fmri is not None:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1166
                        for pfmri in cur_fmris:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1167
                                # Then if this package is a successor to any of
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1168
                                # the packages the dependency requires, then we
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1169
                                # can omit the dependency.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1170
                                if pkg_fmri.is_successor(pfmri):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1171
                                        skip = True
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1172
                if skip:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1173
                        continue
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1174
                # If this dependency isn't a require-any dependency, then it
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1175
                # should be included in the output.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1176
                if cur_dep.attrs["type"] != "require-any":
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1177
                        new_res.append((cur_dep, cur_vars))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1178
                        continue
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1179
                marked = False
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1180
                # Now the require-any dependency is going to be compared to all
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1181
                # the known require dependencies to see if it can be omitted.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1182
                # It can be omitted if one of the packages it requires is
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1183
                # already required.  Because a require-any dependency could be
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1184
                # omitted under some, but not all, variant combinations, the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1185
                # satisfied set of the variant combination of the require-any
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1186
                # dependency is used for bookkeeping.  Each require dependency
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1187
                # which has a successor to one of the packages in the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1188
                # require-any dependency marks the variant combinations under
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1189
                # which it's valid as unsatisfied in the require-any dependency.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1190
                # At the end, if the require-any dependency is still satisfied
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1191
                # under any variant combinations, then it's included in the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1192
                # result.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1193
                for comp_dep, comp_vars in res:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1194
                        if comp_dep.attrs["type"] != "require":
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1195
                                continue
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
  1196
                        comp_fmri = fmri.PkgFmri(comp_dep.attrs["fmri"], "5.11")
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1197
                        successor = False
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1198
                        # Check to see whether the package required by the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1199
                        # require dependency is a successor to any of the
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1200
                        # packages required by the require-any dependency.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1201
                        for c in cur_fmris:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1202
                                if c.is_successor(comp_fmri):
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1203
                                        successor = True
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1204
                                        break
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1205
                        if not successor:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1206
                                continue
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1207
                        # If comp_vars is empty, then no variants have been
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1208
                        # declared for these packages, so having a matching
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1209
                        # require dependency is enough to omit this require-any
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1210
                        # dependency.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1211
                        if cur_vars.mark_as_unsatisfied(comp_vars) or \
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1212
                            comp_vars.is_empty():
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1213
                                marked = True
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1214
                # If the require-any dependency was never changed, then include
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1215
                # it.  If it was changed, check whether there are situations
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1216
                # where the require-any dependency is needed.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1217
                if not marked or cur_vars.sat_set:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1218
                        new_res.append((cur_dep, cur_vars))
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1219
        res = []
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1220
        # Merge the variant information into the depend action.
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1221
        for d, vc in new_res:
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1222
                res.extend(add_vars(d, vc, pkg_vars))
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1223
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1224
        if bad_fmris:
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1225
                errs.append(BadDependencyFmri(pkg_name, bad_fmris))
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1226
        return res, errs
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1227
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1228
def split_off_variants(dep, pkg_vars, satisfied=False):
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1229
        """Take a dependency which may be tagged with variants and move those
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1230
        tags into a VariantSet."""
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1231
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1232
        dep_vars = dep.get_variant_template()
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1233
        if not dep_vars.issubset(pkg_vars):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1234
                raise __NotSubset(dep_vars.difference(pkg_vars))
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1235
        dep_vars.merge_unknown(pkg_vars)
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1236
        # Since all variant information is being kept in the above VariantSets,
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1237
        # remove the variant information from the action.  This prevents
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1238
        # confusion about which is the authoritative source of information.
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1239
        dep.strip_variants()
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1240
        return dep, variants.VariantCombinations(dep_vars, satisfied=satisfied)
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1241
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1242
def prune_debug_attrs(action):
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1243
        """Given a dependency action with pkg.debug.depend attributes
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1244
        return a matching action with those attributes removed"""
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1245
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1246
        attrs = dict((k, v) for k, v in action.attrs.iteritems()
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1247
                     if not k.startswith(base.Dependency.DEPEND_DEBUG_PREFIX))
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1248
        return actions.depend.DependencyAction(**attrs)
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1249
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1250
def add_fmri_path_mapping(files_dict, links_dict, pfmri, mfst,
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1251
    distro_vars=None):
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1252
        """Add mappings from path names to FMRIs and variants.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1253
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1254
        'files_dict' is a dictionary which maps package identity to the files
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1255
        the package delivers and the variants under which each file is
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1256
        present.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1257
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1258
        'links_dict' is a dictionary which maps package identity to the links
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1259
        the package delivers and the variants under which each link is
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1260
        present.
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1261
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1262
        'pfmri' is the FMRI of the current manifest.
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1263
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1264
        'mfst' is the manifest to process.
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1265
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1266
        'distro_vars' is a VariantCombinationTemplate which contains all the
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1267
        variant types and values known."""
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1268
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1269
        pvariants = mfst.get_all_variants()
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1270
        if distro_vars:
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1271
                pvariants.merge_unknown(distro_vars)
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1272
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1273
        for f in mfst.gen_actions_by_type("file"):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1274
                dep_vars = f.get_variant_template()
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1275
                dep_vars.merge_unknown(pvariants)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1276
                vc = variants.VariantCombinations(dep_vars,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1277
                    satisfied=True)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1278
                files_dict.setdefault(f.attrs["path"], []).append(
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1279
                    (pfmri, vc))
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1280
        for f in itertools.chain(mfst.gen_actions_by_type("hardlink"),
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1281
             mfst.gen_actions_by_type("link")):
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1282
                dep_vars = f.get_variant_template()
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1283
                dep_vars.merge_unknown(pvariants)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1284
                vc = variants.VariantCombinations(dep_vars,
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1285
                    satisfied=True)
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1286
                links_dict.setdefault(f.attrs["path"], []).append(
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1287
                    (pfmri, vc, f.attrs["target"]))
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1288
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1856
diff changeset
  1289
def resolve_deps(manifest_paths, api_inst, prune_attrs=False, use_system=True):
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1290
        """For each manifest given, resolve the file dependencies to package
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1291
        dependencies. It returns a mapping from manifest_path to a list of
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1292
        dependencies and a list of unresolved dependencies.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1293
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1294
        'manifest_paths' is a list of paths to the manifests being resolved.
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1295
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1296
        'api_inst' is an ImageInterface which references the current image.
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1297
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1298
        'prune_attrs' is a boolean indicating whether debugging
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1299
        attributes should be stripped from returned actions."""
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1300
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
  1301
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1302
        # The variable 'manifests' is a list of 5-tuples. The first element
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1303
        # of the tuple is the path to the manifest. The second is the name of
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1304
        # the package contained in the manifest. The third is the manifest
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1305
        # object for the manifest in that location. The fourth is the list of
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1306
        # variants the package was published against. The fifth is the list of
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1307
        # files referenced in the manifest that couldn't be found.
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1308
        manifests = [
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1309
            (mp, choose_name(mp, mfst), mfst, mfst.get_all_variants(),
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1310
            missing_files)
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1311
            for mp, (mfst, missing_files) in
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1312
            ((mp, __make_manifest(mp, load_data=False))
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1313
            for mp in manifest_paths)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1314
        ]
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1315
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1316
        files = Entries({}, {})
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1317
        links = {}
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
  1318
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1319
        # This records all the variants used in any package known.  It is used
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1320
        # to ensure that all packages live in the same variant universe for
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1321
        # purposes of dependency resolution.
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1322
        distro_vars = variants.VariantCombinationTemplate()
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1323
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1324
        resolving_pkgs = set()
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1325
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1326
        for mp, (name, pfmri), mfst, pkg_vars, miss_files in manifests:
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1327
                distro_vars.merge_values(pkg_vars)
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1328
                if pfmri:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1329
                        resolving_pkgs.add(pfmri.pkg_name)
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1330
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1331
        pkg_list = None
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1332
        if use_system:
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1333
                # We make this a list because we want to reuse the list of
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1334
                # packages again, and despite it's name, get_pkg_list is a
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1335
                # generator.
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1336
                pkg_list = list(api_inst.get_pkg_list(
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1337
                    api.ImageInterface.LIST_INSTALLED))
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1338
                for (pub, stem, ver), summ, cats, states in pkg_list:
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
  1339
                        pfmri = fmri.PkgFmri("pkg:/%s@%s" % (stem, ver), "5.11")
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1340
                        if pfmri.pkg_name in resolving_pkgs:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1341
                                continue
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1342
                        mfst = api_inst.get_manifest(pfmri, all_variants=True)
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1343
                        distro_vars.merge_values(mfst.get_all_variants())
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1344
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1345
        # Build a list of all files delivered in the manifests being resolved.
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1346
        for mp, (name, pfmri), mfst, pkg_vars, miss_files in manifests:
2428
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1347
                try:
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1348
                        if pfmri is None:
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1349
                                pfmri = fmri.PkgFmri(name, "5.11")
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1350
                except fmri.IllegalFmri, e:
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1351
                        raise BadPackageFmri(mp, e)
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1352
                add_fmri_path_mapping(files.delivered, links, pfmri, mfst,
25adeb0b7928 16849 pkgdepend doesn't handle invalid or incomplete package FMRIs gracefully
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2411
diff changeset
  1353
                    distro_vars)
1856
68eb900fbed5 14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents: 1845
diff changeset
  1354
1581
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1355
        # Build a list of all files delivered in the packages installed on
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1356
        # the system.
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1856
diff changeset
  1357
        if use_system:
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1358
                for (pub, stem, ver), summ, cats, states in pkg_list:
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2462
diff changeset
  1359
                        pfmri = fmri.PkgFmri("pkg:/%s@%s" % (stem, ver), "5.11")
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1360
                        if pfmri.pkg_name in resolving_pkgs:
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1361
                                continue
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1856
diff changeset
  1362
                        mfst = api_inst.get_manifest(pfmri, all_variants=True)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1363
                        add_fmri_path_mapping(files.installed, links,
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1364
                            pfmri, mfst, distro_vars)
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1365
        if pkg_list:
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1366
                del pkg_list
1581
37d9bf54ee23 13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents: 1580
diff changeset
  1367
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1368
        pkg_deps = {}
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1369
        errs = []
2298
c15c3c1a5590 18172 p.d.d.file is misleading when links are involved
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2288
diff changeset
  1370
        for mp, (name, pfmri), mfst, pkg_vars, miss_files in manifests:
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1371
                name_to_use = pfmri or name
2275
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1372
                # The add_fmri_path_mapping function moved the actions it found
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1373
                # into the distro_vars universe of variants, so we need to move
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1374
                # pkg_vars (and by extension the variants on depend actions)
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1375
                # into that universe too.
eed34df93728 18045 pkgdepend resolve fails to recognize unvarianted dependencies
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2236
diff changeset
  1376
                pkg_vars.merge_unknown(distro_vars)
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1377
                errs.extend(miss_files)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1378
                if mfst is None:
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1379
                        pkg_deps[mp] = None
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1380
                        continue
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1381
                ds = []
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1382
                bad_ds = {}
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1383
                for d in mfst.gen_actions_by_type("depend"):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1384
                        if not is_file_dependency(d):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1385
                                continue
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1386
                        try:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1387
                                r = split_off_variants(d, pkg_vars)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1388
                                ds.append(r)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1389
                        except __NotSubset, e:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1390
                                diff = bad_ds.setdefault(d.attrs[reason_prefix],
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1391
                                    variants.VCTDifference(set(), set()))
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1392
                                diff.type_diffs.update(e.diff.type_diffs)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1393
                                diff.value_diffs.update(e.diff.value_diffs)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1394
                if bad_ds:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1395
                        errs.append(ExtraVariantedDependency(name_to_use,
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1396
                            bad_ds, False))
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1397
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1398
                pkg_res = [
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1399
                    (d, find_package(files, links, d, d_vars, pkg_vars,
2159
be07d9cad5a7 16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2091
diff changeset
  1400
                        use_system))
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1401
                    for d, d_vars in ds
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1402
                ]
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1403
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1404
                # Seed the final results with those dependencies defined
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1405
                # manually.
2462
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1406
                deps = []
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1407
                bad_deps = {}
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1408
                for d in mfst.gen_actions_by_type("depend"):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1409
                        if is_file_dependency(d):
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1410
                                continue
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1411
                        try:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1412
                                r = split_off_variants(d, pkg_vars,
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1413
                                    satisfied=True)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1414
                                deps.append(r)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1415
                        except __NotSubset, e:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1416
                                diff = bad_deps.setdefault(
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1417
                                    d.attrs.get("fmri", None),
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1418
                                    variants.VCTDifference(set(), set()))
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1419
                                diff.type_diffs.update(e.diff.type_diffs)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1420
                                diff.value_diffs.update(e.diff.value_diffs)
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1421
                if bad_deps:
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1422
                        errs.append(ExtraVariantedDependency(name_to_use,
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1423
                            bad_deps, True))
d89a0da0a548 17756 action with more variants than its package raises assertion
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2428
diff changeset
  1424
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1425
                for file_dep, (res, dep_vars, pkg_errs) in pkg_res:
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1426
                        for e in pkg_errs:
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1427
                                if hasattr(e, "pkg_name"):
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1428
                                        e.pkg_name = name_to_use
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1429
                        errs.extend(pkg_errs)
2091
824491c11ff3 15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2073
diff changeset
  1430
                        dep_vars.simplify(pkg_vars)
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1431
                        if not res:
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1432
                                errs.append(UnresolvedDependencyError(mp,
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1433
                                    file_dep, dep_vars))
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1434
                        else:
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1435
                                deps.extend(res)
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1436
                                if not dep_vars.is_satisfied():
1544
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1437
                                        errs.append(UnresolvedDependencyError(
e0ce5081236a 12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents: 1516
diff changeset
  1438
                                            mp, file_dep, dep_vars))
1756
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1439
                # Add variant information to the dependency actions and combine
0dd15313e977 14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents: 1674
diff changeset
  1440
                # what would otherwise be duplicate dependencies.
2411
936617650fa1 18150 MultiplePackagesPathError should include package
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2381
diff changeset
  1441
                deps, combine_errs = combine(deps, pkg_vars, pfmri, name_to_use)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2298
diff changeset
  1442
                errs.extend(combine_errs)
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1443
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1444
                if prune_attrs:
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1445
                        deps = [prune_debug_attrs(d) for d in deps]
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1446
                pkg_deps[mp] = deps
1845
d9a33bd442b5 14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents: 1756
diff changeset
  1447
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1231
diff changeset
  1448
        return pkg_deps, errs