author | Brock Pytlik <brock.pytlik@oracle.com> |
Wed, 08 Dec 2010 16:29:54 -0800 | |
changeset 2159 | be07d9cad5a7 |
parent 2091 | 824491c11ff3 |
child 2191 | da5a579210cc |
permissions | -rw-r--r-- |
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 |
# |
1887
757d613561da
15777 pkgdep resolve should provide an option to only resolve against the manifests provided (fix copyright)
Brock Pytlik <bpytlik@sun.com>
parents:
1886
diff
changeset
|
24 |
# Copyright (c) 2009, 2010, 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 |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
29 |
import os |
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
|
30 |
import urllib |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
31 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
32 |
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
|
33 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
34 |
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
|
35 |
import pkg.client.api as api |
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.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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
target_prefix = "%s.target" % 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
|
51 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
52 |
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
|
53 |
# 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
|
54 |
# 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
|
55 |
# 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
|
56 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
57 |
class DependencyError(Exception): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
58 |
"""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
|
59 |
pass |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
60 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
61 |
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
|
62 |
"""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
|
63 |
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
|
64 |
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
|
65 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
66 |
def __init__(self, res, source, vc): |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
67 |
self.res = res |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
68 |
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
|
69 |
self.vc = vc |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
70 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
71 |
def __str__(self): |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
72 |
return _("The file dependency %(src)s has paths which resolve " |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
73 |
"to multiple packages under this combination of " |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
74 |
"variants:\n%(vars)s\nThe actions are as " |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
75 |
"follows:\n%(acts)s") % { |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
76 |
"src":self.source, |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
77 |
"acts":"\n".join(["\t%s" % a for a in self.res]), |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
78 |
"vars":"\n".join([ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
79 |
" ".join([ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
80 |
("%s:%s" % (name, val)) for name, val in grp |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
81 |
]) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
82 |
for grp in self.vc.sat_set]) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
83 |
} |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
84 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
85 |
class AmbiguousPathError(DependencyError): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
86 |
"""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
|
87 |
is depended upon.""" |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
88 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
89 |
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
|
90 |
self.pkgs = pkgs |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
91 |
self.source = source |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
92 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
93 |
def __str__(self): |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
94 |
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
|
95 |
"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
|
96 |
"are:%(pkgs)s") % { |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
97 |
"src":self.source, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
98 |
"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
|
99 |
} |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
100 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
101 |
class UnresolvedDependencyError(DependencyError): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
102 |
"""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
|
103 |
depended upon.""" |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
104 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
105 |
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
|
106 |
self.path = pth |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
107 |
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
|
108 |
self.pvars = pvars |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
109 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
110 |
def __str__(self): |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
111 |
return _("%(pth)s has unresolved dependency '%(dep)s' under " |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
112 |
"the following combinations of variants:\n%(combo)s") % \ |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
113 |
{ |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
114 |
"pth":self.path, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
115 |
"dep":self.file_dep, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
116 |
"combo":"\n".join([ |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
117 |
" ".join([ |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
118 |
("%s:%s" % (name, val)) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
119 |
for name, val in sorted(grp) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
120 |
]) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
121 |
for grp in self.pvars.not_sat_set |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
122 |
])} |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
123 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
124 |
class MissingPackageVariantError(DependencyError): |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
125 |
"""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
|
126 |
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
|
127 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
128 |
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
|
129 |
self.act_vars = act_vars |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
130 |
self.pkg_vars = pkg_vars |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
131 |
self.path = pth |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
132 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
133 |
def __str__(self): |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
134 |
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
|
135 |
"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
|
136 |
"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
|
137 |
"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
|
138 |
"variants are: %(pkg)s") % { |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
139 |
"path": self.path, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
140 |
"act": self.act_vars, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
141 |
"pkg": self.pkg_vars |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
142 |
} |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
143 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
144 |
def list_implicit_deps(file_path, proto_dirs, dyn_tok_conv, kernel_paths, |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
145 |
remove_internal_deps=True, convert=True): |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
146 |
"""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
|
147 |
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
|
148 |
the manifest have. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
149 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
150 |
'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
|
151 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
152 |
'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
|
153 |
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
|
154 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
155 |
'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
|
156 |
$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
|
157 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
158 |
'kernel_paths' contains the run paths which kernel modules should use. |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
159 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
160 |
'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
|
161 |
to DependencyActions prior to being returned. This is primarily an |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
162 |
option to facilitate testing and debugging.""" |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
163 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
deps, elist, missing, pkg_attrs = list_implicit_deps_for_manifest(m, |
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
167 |
proto_dirs, pkg_vars, dyn_tok_conv, kernel_paths) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
168 |
rid_errs = [] |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
169 |
if remove_internal_deps: |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
170 |
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
|
171 |
pkg_vars) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
172 |
if convert: |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
173 |
deps = 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
|
174 |
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
|
175 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
176 |
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
|
177 |
"""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
|
178 |
pkg.actions.dependency.Dependency objects.""" |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
179 |
|
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
180 |
res = [] |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
181 |
for d in deps: |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
182 |
tmp = [] |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
183 |
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
|
184 |
attrs = d.attrs.copy() |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
185 |
attrs.update(c) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
186 |
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
|
187 |
if not tmp: |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
188 |
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
|
189 |
res.extend(tmp) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
190 |
return res |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
191 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
192 |
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
|
193 |
"""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
|
194 |
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
|
195 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
196 |
'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
|
197 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
198 |
'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
|
199 |
found in deps. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
200 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
201 |
'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
|
202 |
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
|
203 |
|
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
|
204 |
'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
|
205 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
206 |
res = [] |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
207 |
errs = [] |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
208 |
delivered = {} |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
209 |
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
|
210 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
211 |
files = Entries({}, {}) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
212 |
links = Entries({}, {}) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
213 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
214 |
# 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
|
215 |
# 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
|
216 |
# a private construction which should not escape to the user. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
217 |
add_fmri_path_mapping(files.delivered, links.delivered, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
218 |
fmri.PkgFmri("INTERNAL@0-0", build_release="0"), mfst) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
else: |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
224 |
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
|
225 |
# 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
|
226 |
# 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
|
227 |
# 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
|
228 |
errs.append( |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
229 |
MissingPackageVariantError(pvars, pkg_vars, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
230 |
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
|
231 |
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
|
232 |
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
|
233 |
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
|
234 |
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
|
235 |
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
|
236 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
237 |
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
|
238 |
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
|
239 |
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
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
continue |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
244 |
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
|
245 |
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
|
246 |
res.append(d) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
247 |
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
|
248 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
249 |
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
|
250 |
"""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
|
251 |
|
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
252 |
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
|
253 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
254 |
# 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
|
255 |
# 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
|
256 |
dispatch_dict = { |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
} |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
262 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
263 |
def list_implicit_deps_for_manifest(mfst, proto_dirs, pkg_vars, dyn_tok_conv, |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
264 |
kernel_paths): |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
265 |
"""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
|
266 |
files it installs. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
267 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
268 |
'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
|
269 |
found in deps. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
270 |
|
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
271 |
'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
|
272 |
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
|
273 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
274 |
'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
|
275 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
276 |
'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
|
277 |
$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
|
278 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
279 |
'kernel_paths' contains the run paths which kernel modules should use. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
280 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
281 |
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
|
282 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
283 |
'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
|
284 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
285 |
'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
|
286 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
287 |
'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
|
288 |
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
|
289 |
|
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
290 |
'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
|
291 |
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
|
292 |
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
|
293 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
294 |
deps = [] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
295 |
elist = [] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
296 |
missing = {} |
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
297 |
pkg_attrs = {} |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
298 |
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
|
299 |
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
|
300 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
301 |
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
|
302 |
a = act_list[i] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
303 |
try: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
304 |
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
|
305 |
except KeyError: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
306 |
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
|
307 |
missing[file_type] = \ |
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
308 |
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
|
309 |
else: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
310 |
try: |
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
311 |
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
|
312 |
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
|
313 |
dyn_tok_conv=dyn_tok_conv, |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
314 |
kernel_paths=kernel_paths) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
315 |
deps.extend(ds) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
316 |
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
|
317 |
__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
|
318 |
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
|
319 |
elist.append(e) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
|
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
324 |
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
|
325 |
"""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
|
326 |
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
|
327 |
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
|
328 |
|
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
329 |
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
|
330 |
"""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
|
331 |
|
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
|
332 |
m = manifest.Manifest() |
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
333 |
fh = open(fp, "rb") |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
334 |
acts = [] |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
335 |
missing_files = [] |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
336 |
accumulate = "" |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
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
|
341 |
continue |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
342 |
elif accumulate: |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
343 |
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
|
344 |
accumulate = "" |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
345 |
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
|
346 |
continue |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
347 |
try: |
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
348 |
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
|
349 |
basedirs=basedirs, |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
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
|
361 |
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
|
362 |
else: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
363 |
path = e.path |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
364 |
# If the path was not set, then parse the |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
365 |
# action, without trying to load the data and |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
366 |
# use the path defined in the action. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
367 |
if not path: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
368 |
path = new_a.attrs["path"] |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
369 |
missing_files.append(base.MissingFile(path)) |
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
370 |
fh.close() |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
1934
diff
changeset
|
371 |
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
|
372 |
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
|
373 |
|
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
|
374 |
def choose_name(fp, mfst): |
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
|
375 |
"""Find the package name for this manifest. If it's defined in a set |
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
|
376 |
action in the manifest, use that. Otherwise use the basename of the |
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
|
377 |
path to the manifest as the name. |
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
|
378 |
'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
|
379 |
|
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
|
380 |
'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
|
381 |
|
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
|
382 |
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
|
383 |
return urllib.unquote(os.path.basename(fp)) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1337
diff
changeset
|
384 |
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
|
385 |
if name is not 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
|
386 |
return name |
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
|
387 |
return urllib.unquote(os.path.basename(fp)) |
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 |
|
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
389 |
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
|
390 |
"""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
|
391 |
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
|
392 |
|
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
|
393 |
'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
|
394 |
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
|
395 |
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
|
396 |
|
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
|
397 |
'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
|
398 |
|
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
|
399 |
'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
|
400 |
satisfied. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
401 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
402 |
'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
|
403 |
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
|
404 |
|
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
|
405 |
res = [] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
406 |
vars = [] |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
407 |
errs = set() |
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
|
408 |
for pfmri, delivered_vars in lst: |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
409 |
# 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
|
410 |
# 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
|
411 |
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
|
412 |
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
|
413 |
continue |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
414 |
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
|
415 |
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
|
416 |
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
|
417 |
# 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
|
418 |
# 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
|
419 |
# 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
|
420 |
# 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
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
errs.add(pfmri) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
425 |
# 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
|
426 |
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
|
427 |
# 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
|
428 |
# 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
|
429 |
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
|
430 |
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
|
431 |
attrs.update({"fmri":pfmri.get_short_fmri()}) |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
432 |
# 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
|
433 |
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
|
434 |
action_vars)) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
435 |
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
|
436 |
if errs: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
437 |
# If any packages are in errs, then more than one file delivered |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
438 |
# the same path under some configuaration of variants. This |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
439 |
# situation is unresolvable. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
443 |
def make_paths(file_dep): |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
444 |
"""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
|
445 |
'file_dep'.""" |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
446 |
|
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
if isinstance(files, basestring): |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
450 |
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
|
451 |
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
|
452 |
rps = [rps] |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
453 |
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
|
454 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
455 |
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
|
456 |
"""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
|
457 |
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
|
458 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
459 |
'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
|
460 |
real path. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
461 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
462 |
'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
|
463 |
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
|
464 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
465 |
'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
|
466 |
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
|
467 |
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
|
468 |
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
|
469 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
470 |
'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
|
471 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
472 |
'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
|
473 |
for 'path'. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
474 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
475 |
'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
|
476 |
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
|
477 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
478 |
res_paths = [] |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
479 |
res_links = [] |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
480 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
481 |
# 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
|
482 |
# the path. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
483 |
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
|
484 |
# 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
|
485 |
# 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
|
486 |
tmp_vars = copy.copy(path_vars) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
487 |
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
|
488 |
# 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
|
489 |
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
|
490 |
# 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
|
491 |
# 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
|
492 |
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
|
493 |
continue |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
494 |
# 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
|
495 |
# 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
|
496 |
# 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
|
497 |
# 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
|
498 |
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
|
499 |
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
|
500 |
tmp_vars.mark_as_satisfied(p_vc) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
501 |
res_paths.append((path, pfmri, inter)) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
502 |
# 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
|
503 |
# 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
|
504 |
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
|
505 |
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
|
506 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
507 |
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
|
508 |
# 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
|
509 |
# 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
|
510 |
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
|
511 |
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
|
512 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
513 |
# 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
|
514 |
cur_path = os.path.join(*lst[0:index]) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
515 |
# The links in delivered packages (ie, those current being resolved) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
516 |
# should be preferred over links from the installed system. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
517 |
rel_links = links.delivered.get(cur_path, []) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
518 |
tmp = set() |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
519 |
for pfmri, 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
|
520 |
tmp.add(pfmri.get_name()) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
521 |
# Only considered links from installed packages which are not also being |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
522 |
# resolved. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
523 |
for pfmri, vc, rel_target in links.installed.get(cur_path, []): |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
524 |
if pfmri.get_name() in tmp: |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
525 |
continue |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
526 |
rel_links.append((pfmri, vc, rel_target)) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
527 |
# 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
|
528 |
# 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
|
529 |
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
|
530 |
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
|
531 |
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
|
532 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
533 |
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
|
534 |
# If the variants needed to reach the current path and the |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
535 |
# variants for the link don't intersect, then the link |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
536 |
# is irrelevant. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
537 |
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
|
538 |
continue |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
539 |
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
|
540 |
# 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
|
541 |
# 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
|
542 |
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
|
543 |
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
|
544 |
continue |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
545 |
# 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
|
546 |
# path. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
547 |
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
|
548 |
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
|
549 |
*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
|
550 |
# 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
|
551 |
# 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
|
552 |
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
|
553 |
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
|
554 |
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
|
555 |
continue |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
556 |
# 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
|
557 |
# 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
|
558 |
# results. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
559 |
res_links.extend(link_deps) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
560 |
res_paths.extend(rec_paths) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
561 |
# Now add in the dependencies for the current link. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
562 |
for rec_path, rec_pfmri, rec_vc in rec_paths: |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
563 |
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
|
564 |
attrs.update({ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
565 |
"fmri": link_pfmri.get_short_fmri(), |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
566 |
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
|
567 |
target_prefix: next_path, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
568 |
files_prefix: path |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
569 |
}) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
570 |
attrs.pop(paths_prefix, None) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
571 |
assert vc_intersection.intersects(rec_vc), \ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
572 |
"vc:%s\nvc_intersection:%s" % \ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
573 |
(rec_vc, vc_intersection) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
574 |
# 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
|
575 |
# 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
|
576 |
# variants is restricted as links are applied so the |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
577 |
# variants used for the path are the intersection of |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
578 |
# the variants for each of the links used to reach the |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
579 |
# path and the variants under which the file is |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
580 |
# delivered. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
581 |
res_links.append(( |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
582 |
actions.depend.DependencyAction(**attrs), rec_vc)) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
583 |
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
|
584 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
585 |
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
|
586 |
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
|
587 |
"""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
|
588 |
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
|
589 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
590 |
'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
|
591 |
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
|
592 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
593 |
'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
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
|
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
|
598 |
'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
|
599 |
|
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
|
600 |
'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
|
601 |
resolved. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
602 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
603 |
'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
|
604 |
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
|
605 |
|
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
606 |
res = [] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
607 |
errs = [] |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
608 |
link_deps = [] |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
609 |
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
|
610 |
multiple_path_pkgs = set() |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
611 |
for p in make_paths(file_dep): |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
612 |
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
|
613 |
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
|
614 |
link_deps.extend(path_deps) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
615 |
delivered_list = \ |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
616 |
[(pfmri, vc) for (path, pfmri, vc) in paths_info] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
617 |
try: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
618 |
new_res, dep_vars = helper(delivered_list, file_dep, |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
619 |
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
|
620 |
except AmbiguousPathError, e: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
621 |
errs.append(e) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
622 |
else: |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
623 |
# We know which path satisfies this dependency, so |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
624 |
# remove the list of files and paths, and replace them |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
625 |
# with the single path that works. |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
626 |
for na, nv in new_res: |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
627 |
na.attrs.pop(paths_prefix, None) |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
628 |
na.attrs[files_prefix] = [p] |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
629 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
630 |
if not res: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
631 |
res = new_res |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
632 |
continue |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
633 |
# 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
|
634 |
# 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
|
635 |
# 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
|
636 |
# 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
|
637 |
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
|
638 |
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
|
639 |
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
|
640 |
new_a.attrs["fmri"]: |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
641 |
a.attrs[files_prefix].extend( |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
642 |
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
|
643 |
continue |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
644 |
# 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
|
645 |
# 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
|
646 |
# 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
|
647 |
# 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
|
648 |
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
|
649 |
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
|
650 |
new_a, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
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
|
655 |
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
|
656 |
new_a, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
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
|
660 |
else: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
661 |
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
|
662 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
667 |
# 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
|
668 |
# 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
|
669 |
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
|
670 |
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
|
671 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
672 |
def find_package(files, links, file_dep, 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
|
673 |
"""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
|
674 |
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
|
675 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
676 |
'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
|
677 |
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
|
678 |
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
|
679 |
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
|
680 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
681 |
'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
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
|
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
|
686 |
'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
|
687 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
688 |
'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
|
689 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
690 |
file_dep, orig_dep_vars = split_off_variants(file_dep, pkg_vars) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
691 |
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
|
692 |
# 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
|
693 |
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
|
694 |
files.delivered, links, file_dep, dep_vars, orig_dep_vars) |
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
|
695 |
if (res 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
|
696 |
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
|
697 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
698 |
# 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
|
699 |
# 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
|
700 |
# |
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
|
701 |
# 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
|
702 |
# above. |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
703 |
const_dep_vars = copy.copy(dep_vars) |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
704 |
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
|
705 |
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
|
706 |
res.extend(inst_res) |
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
707 |
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
|
708 |
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
|
709 |
|
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
|
710 |
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
|
711 |
return act.name == "depend" and \ |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
712 |
act.attrs.get("fmri", None) == base.Dependency.DUMMY_FMRI and \ |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
713 |
files_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
|
714 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
715 |
def merge_deps(dest, src): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
716 |
"""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
|
717 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
718 |
for k, v in src.attrs.items(): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
719 |
# 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
|
720 |
# then something's gone horribly wrong. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
721 |
assert(not k.startswith("variant.")) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
722 |
if k not in dest.attrs: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
723 |
dest.attrs[k] = v |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
724 |
elif v != dest.attrs[k]: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
725 |
# 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
|
726 |
# will be removed in a later step. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
727 |
if isinstance(v, basestring): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
728 |
v = [v] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
729 |
if isinstance(dest.attrs[k], list): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
730 |
dest.attrs[k].extend(v) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
731 |
else: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
732 |
t = [dest.attrs[k]] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
733 |
t.extend(v) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
734 |
dest.attrs[k] = t |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
735 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
736 |
def combine(deps, pkg_vars): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
737 |
"""Combine duplicate dependency actions. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
738 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
739 |
'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
|
740 |
the variants associated with that dependency. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
741 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
742 |
'pkg_vars' are the variants that the package for which dependencies are |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
743 |
being generated was published against.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
744 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
745 |
def action_group_key(d): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
746 |
"""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
|
747 |
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
|
748 |
in pkg.manifest notices.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
749 |
|
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
750 |
# d[0] is the action. d[1] is the VariantCombination for this |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
751 |
# action. |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
752 |
return d[0].name, d[0].attrs.get(d[0].key_attr, id(d[0])) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
753 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
754 |
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
|
755 |
"""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
|
756 |
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
|
757 |
|
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
758 |
d_vars.simplify(pkg_vars) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
759 |
res = [] |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
760 |
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
|
761 |
attrs = d.attrs.copy() |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
762 |
attrs.update(s) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
763 |
t = actions.depend.DependencyAction(**attrs) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
764 |
t.consolidate_attrs() |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
765 |
res.append(t) |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
766 |
if not res: |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
767 |
d.consolidate_attrs() |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
768 |
res = [d] |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
769 |
return res |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
770 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
771 |
def key_on_variants(a): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
772 |
"""Return the key (the VariantSets) to sort the grouped tuples |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
773 |
by.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
774 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
775 |
return a[1] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
776 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
777 |
def sort_by_variant_subsets(a, b): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
778 |
"""Sort the tuples so that those actions whose variants are |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
779 |
supersets of others are placed at the front of the list. This |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
780 |
function assumes that a and b are both VariantSets.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
781 |
|
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
782 |
if a.issubset(b, satisfied=True): |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
783 |
return 1 |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
784 |
elif b.issubset(a, satisfied=True): |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
785 |
return -1 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
786 |
return 0 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
787 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
788 |
# Here is an example of how this code should work. Assume that the code |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
789 |
# is looking at dependencies for a package published against |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
790 |
# variant.foo = bar, baz and variant.num = one, two. These are |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
791 |
# abbreviated below as v.f and v.n. The following dependencies have |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
792 |
# been found for this package: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
793 |
# 1) depend pkg_a reason=file_1, VariantSet is v.f=bar,baz v.n=one,two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
794 |
# 2) depend pkg_a reason=file_2, VariantSet is v.f=bar v.n=one |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
795 |
# 3) depend pkg_b reason=file_3, VariantSet is v.f=bar v.n=one |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
796 |
# 4) depend pkg_b reason=file_3, VariantSet is v.f=baz v.n=two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
797 |
# 5) depend pkg_b reason=file_3 path=p1, VariantSet is v.f=bar |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
798 |
# v.n=one,two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
799 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
800 |
# First, these dependencies are grouped by their fmris. This produces |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
801 |
# two lists, the first contains dependencies 1 and 2, the second |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
802 |
# contains dependencies 3, 4, and 5. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
803 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
804 |
# The first group of dependencies is sorted by their VariantSet's. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
805 |
# Dependency 1 comes before dependency 2 because 2's variants are a |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
806 |
# subset of 1's variants. Dependency 1 is put in the temporary result |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
807 |
# list (subres) since at least one dependency on pkg_a must exist. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
808 |
# Next, dependency 2 is compared to dependency 1 to see if it its |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
809 |
# variants are subset of 1's. Since they are, the two dependencies are |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
810 |
# merged. This means that values of all tags in either dependency |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
811 |
# appear in the merged dependency. In this case, the merged dependency |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
812 |
# would look something like: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
813 |
# depend pkg_a reason=file_1 reason=file_2 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
814 |
# The variant set associated with the merged dependency would still be |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
815 |
# dependency 1's variant set. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
816 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
817 |
# The last thing that happens with this group of dependencies is that |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
818 |
# add_vars is called on each result. This first removes those variants |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
819 |
# which match the package's identically. What remains is added to the |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
820 |
# dependency's attribute dictionary. Since the package variants and the |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
821 |
# dependency's variants are identical in this case, nothing is added. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
822 |
# Lastly, any duplicate values for a tag are removed. Again, since |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
823 |
# there are no duplicates, nothing is changed. The final dependency |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
824 |
# that's added to final_res is: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
825 |
# depend pkg_a reason=file_1 reason=file_2 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
826 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
827 |
# The second group of dependencies is also sorted by their VariantSet's. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
828 |
# This sort is a partial ordering. Dependency 5 must come before |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
829 |
# dependency 3, but dependency 4 can be anywhere in the list. Let's |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
830 |
# assume that the order is [4, 5, 3]. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
831 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
832 |
# Dependency 4 is added to the temporary result list (subres). |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
833 |
# Dependency 5 is checked to see if its variants are subset of 4's |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
834 |
# variants. Since they are not, dependency 5 is added to subres. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
835 |
# Dependency 3 is checked against 4 to see if its variants are a subset. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
836 |
# Since they're not, 3's variants are then checked against 5's variants. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
837 |
# Since 3's variants are a subset of 5's variants, 3 is merged with 5, |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
838 |
# producing this dependency: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
839 |
# depend pkg_b reason=file_3 reason=file_3 path=p1, VariantSet is |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
840 |
# v.f=bar v.n=one,two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
841 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
842 |
# The two results from this group (dependency 4 and the merge of 5 and |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
843 |
# 3) than has add_vars called on it. The final results are: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
844 |
# dependency pkg_b reason=file_3 v.f=baz v.n=two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
845 |
# dependency pkg_b reason=file_3 path=p1 v.f=bar |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
846 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
847 |
# The v.n tags have been removed from the second result because they |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
848 |
# were identical to the package's variants. The duplicate reasons have |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
849 |
# also been coalesced. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
850 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
851 |
# After everything is done, the final set of dependencies for this |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
852 |
# package are: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
853 |
# depend pkg_a reason=file_1 reason=file_2 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
854 |
# dependency pkg_b reason=file_3 v.f=baz v.n=two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
855 |
# dependency pkg_b reason=file_3 path=p1 v.f=bar |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
856 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
857 |
res = [] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
858 |
# For each group of dependencies (g) for a particular fmri (k) ... |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
859 |
for k, g in itertools.groupby(sorted(deps, key=action_group_key), |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
860 |
action_group_key): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
861 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
862 |
# Sort the dependencies so that any dependency whose variants |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
863 |
# are a subset of the variants of another dependency follow it. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
864 |
glist = sorted(g, cmp=sort_by_variant_subsets, |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
865 |
key=key_on_variants) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
866 |
subres = [glist[0]] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
867 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
868 |
# d is a dependency action. d_vars are the variants under which |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
869 |
# d will be applied. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
870 |
for d, d_vars in glist[1:]: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
871 |
found_subset = False |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
872 |
for rel_res, rel_vars in subres: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
873 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
874 |
# If d_vars is a subset of any variant set |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
875 |
# already in the results, then d should be |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
876 |
# combined with that dependency. |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
877 |
if d_vars.issubset(rel_vars, satisfied=True): |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
878 |
found_subset = True |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
879 |
merge_deps(rel_res, d) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
880 |
break |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
881 |
assert(not rel_vars.issubset(d_vars, |
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
882 |
satisfied=True)) |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
883 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
884 |
# If no subset was found, then d_vars is a new set of |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
885 |
# conditions under which the dependency d should apply |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
886 |
# so add it to the results. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
887 |
if not found_subset: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
888 |
subres.append((d, d_vars)) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
889 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
890 |
# Add the variants to the dependency action and remove any |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
891 |
# variants that are identical to those defined by the package. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
892 |
subres = [add_vars(d, d_vars, pkg_vars) for d, d_vars in subres] |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
893 |
res.extend(itertools.chain.from_iterable(subres)) |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
894 |
return res |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
895 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
896 |
def split_off_variants(dep, pkg_vars): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
897 |
"""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
|
898 |
tags into a VariantSet.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
899 |
|
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
900 |
dep_vars = dep.get_variant_template() |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
901 |
dep_vars.merge_unknown(pkg_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
902 |
# 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
|
903 |
# 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
|
904 |
# 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
|
905 |
dep.strip_variants() |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
906 |
return dep, variants.VariantCombinations(dep_vars, satisfied=False) |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
907 |
|
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
908 |
def prune_debug_attrs(action): |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
909 |
"""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
|
910 |
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
|
911 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
912 |
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
|
913 |
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
|
914 |
return actions.depend.DependencyAction(**attrs) |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
915 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
916 |
def add_fmri_path_mapping(files_dict, links_dict, pfmri, mfst): |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
917 |
"""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
|
918 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
919 |
'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
|
920 |
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
|
921 |
present. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
922 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
923 |
'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
|
924 |
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
|
925 |
present. |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
926 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
927 |
'pfmri' is the FMRI of the current manifest |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
928 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
929 |
'mfst' is the manifest to process.""" |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
930 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
931 |
pvariants = mfst.get_all_variants() |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
932 |
|
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
933 |
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
|
934 |
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
|
935 |
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
|
936 |
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
|
937 |
satisfied=True) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
938 |
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
|
939 |
(pfmri, vc)) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
940 |
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
|
941 |
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
|
942 |
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
|
943 |
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
|
944 |
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
|
945 |
satisfied=True) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
946 |
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
|
947 |
(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
|
948 |
|
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
|
949 |
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
|
950 |
"""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
|
951 |
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
|
952 |
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
|
953 |
|
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
|
954 |
'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
|
955 |
|
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
956 |
'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
|
957 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
958 |
'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
|
959 |
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
|
960 |
|
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
961 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
962 |
# 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
|
963 |
# 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
|
964 |
# 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
|
965 |
# 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
|
966 |
# 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
|
967 |
# 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
|
968 |
manifests = [ |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
969 |
(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
|
970 |
missing_files) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
971 |
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
|
972 |
((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
|
973 |
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
|
974 |
] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
975 |
|
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
976 |
files = Entries({}, {}) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
977 |
links = Entries({}, {}) |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
978 |
|
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
|
979 |
# Build a list of all files delivered in the manifests being resolved. |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
980 |
for mp, name, mfst, pkg_vars, miss_files in manifests: |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
981 |
pfmri = fmri.PkgFmri(name) |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
982 |
add_fmri_path_mapping(files.delivered, links.delivered, pfmri, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
983 |
mfst) |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
984 |
|
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
985 |
# 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
|
986 |
# 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
|
987 |
if use_system: |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
988 |
for (pub, stem, ver), summ, cats, states in \ |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
989 |
api_inst.get_pkg_list(api.ImageInterface.LIST_INSTALLED): |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
990 |
pfmri = fmri.PkgFmri("pkg:/%s@%s" % (stem, ver)) |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
991 |
mfst = api_inst.get_manifest(pfmri, all_variants=True) |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
992 |
add_fmri_path_mapping(files.installed, links.installed, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
993 |
pfmri, mfst) |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
994 |
|
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
|
995 |
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
|
996 |
errs = [] |
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
997 |
for mp, name, mfst, pkg_vars, miss_files in manifests: |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
continue |
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
|
1002 |
pkg_res = [ |
2159
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
1003 |
(d, find_package(files, links, d, pkg_vars, |
be07d9cad5a7
16013 ON build noise from pkgdepend about perl's complicated symlinks
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2091
diff
changeset
|
1004 |
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
|
1005 |
for d in mfst.gen_actions_by_type("depend") |
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
|
1006 |
if is_file_dependency(d) |
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
|
1007 |
] |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1008 |
# 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
|
1009 |
# manually. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1010 |
deps = [ |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1011 |
split_off_variants(d, pkg_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1012 |
for d in mfst.gen_actions_by_type("depend") |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1013 |
if not is_file_dependency(d) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1014 |
] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
1015 |
for file_dep, (res, dep_vars, pkg_errs) in pkg_res: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
1016 |
errs.extend(pkg_errs) |
2091
824491c11ff3
15958 generate gets partially satisfied internal dependencies wrong
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2073
diff
changeset
|
1017 |
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
|
1018 |
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
|
1019 |
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
|
1020 |
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
|
1021 |
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
|
1022 |
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
|
1023 |
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
|
1024 |
errs.append(UnresolvedDependencyError( |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
1025 |
mp, file_dep, dep_vars)) |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1026 |
# 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
|
1027 |
# what would otherwise be duplicate dependencies. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
1028 |
deps = combine(deps, pkg_vars) |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
1029 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
1030 |
if prune_attrs: |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
1031 |
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
|
1032 |
pkg_deps[mp] = deps |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
1033 |
|
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
|
1034 |
return pkg_deps, errs |