author | Shawn Walker <shawn.walker@oracle.com> |
Tue, 14 Sep 2010 17:19:10 -0700 | |
changeset 2073 | 9fcacc9e5eaa |
parent 1934 | 4afdb552a5ec |
child 2091 | 824491c11ff3 |
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 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
27 |
import itertools |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
28 |
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
|
29 |
import urllib |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
30 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
43 |
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
|
44 |
files_prefix = "%s.file" % base.Dependency.DEPEND_DEBUG_PREFIX |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
45 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
46 |
class DependencyError(Exception): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
47 |
"""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
|
48 |
pass |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
49 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
50 |
class MultiplePackagesPathError(DependencyError): |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
51 |
"""This exception is used when a file dependency has paths which |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
52 |
cause two packages to deliver files which fulfill the dependency.""" |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
53 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
54 |
def __init__(self, res, source): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
55 |
self.res = res |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
56 |
self.source = source |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
57 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
58 |
def __str__(self): |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
59 |
return _("The file dependency %s has paths which resolve " |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
60 |
"to multiple packages. The actions are as follows:\n%s" % |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
61 |
(self.source, "\n".join(["\t%s" % a for a in self.res]))) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
62 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
63 |
class AmbiguousPathError(DependencyError): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
64 |
"""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
|
65 |
is depended upon.""" |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
66 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
67 |
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
|
68 |
self.pkgs = pkgs |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
69 |
self.source = source |
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): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
72 |
return _("The file dependency %s depends on a path delivered " |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
73 |
"by multiple packages. Those packages are:%s" % |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
74 |
(self.source, " ".join([str(p) for p in self.pkgs]))) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
75 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
76 |
class UnresolvedDependencyError(DependencyError): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
77 |
"""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
|
78 |
depended upon.""" |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
79 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
80 |
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
|
81 |
self.path = pth |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
82 |
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
|
83 |
self.pvars = pvars |
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 |
def __str__(self): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
86 |
return _("%s has unresolved dependency '%s' under the " |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
87 |
"following combinations of variants:\n%s") % \ |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
88 |
(self.path, self.file_dep, |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
89 |
"\n".join([ |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
90 |
" ".join([("%s:%s" % (name, val)) for name, val in grp]) |
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
|
91 |
for grp in self.pvars.get_unsatisfied().groups() |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
92 |
])) |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
93 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
94 |
def list_implicit_deps(file_path, proto_dirs, dyn_tok_conv, kernel_paths, |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
95 |
remove_internal_deps=True): |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
96 |
"""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
|
97 |
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
|
98 |
the manifest have. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
99 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
100 |
'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
|
101 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
102 |
'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
|
103 |
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
|
104 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
105 |
'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
|
106 |
$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
|
107 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
108 |
'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
|
109 |
""" |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
110 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
proto_dirs, pkg_vars, dyn_tok_conv, kernel_paths) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
115 |
if remove_internal_deps: |
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
116 |
deps = resolve_internal_deps(deps, m, proto_dirs, pkg_vars) |
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
117 |
return deps, missing_manf_files + elist, missing, pkg_attrs |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
118 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
119 |
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
|
120 |
"""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
|
121 |
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
|
122 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
123 |
'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
|
124 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
125 |
'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
|
126 |
found in deps. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
127 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
128 |
'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
|
129 |
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
|
130 |
|
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
|
131 |
'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
|
132 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
133 |
res = [] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
134 |
delivered = {} |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
135 |
delivered_bn = {} |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
136 |
for a in mfst.gen_actions_by_type("file"): |
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
|
137 |
pvars = variants.VariantSets(a.get_variants()) |
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
|
138 |
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
|
139 |
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
|
140 |
else: |
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
141 |
pvars.merge_unknown(pkg_vars) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
142 |
p = a.attrs["path"] |
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
|
143 |
delivered.setdefault(p, variants.VariantSets()).merge(pvars) |
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
144 |
p = os.path.join(a.attrs[portable.PD_PROTO_DIR], p) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
145 |
np = os.path.normpath(p) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
146 |
rp = os.path.realpath(p) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
147 |
# adding the normalized path |
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
|
148 |
delivered.setdefault(np, variants.VariantSets()).merge(pvars) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
149 |
# adding the real path |
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
|
150 |
delivered.setdefault(rp, variants.VariantSets()).merge(pvars) |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
151 |
bn = os.path.basename(p) |
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
|
152 |
delivered_bn.setdefault(bn, variants.VariantSets()).merge(pvars) |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
153 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
154 |
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
|
155 |
etype, pvars = d.resolve_internal(delivered_files=delivered, |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
156 |
delivered_base_names=delivered_bn) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
157 |
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
|
158 |
continue |
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
|
159 |
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
|
160 |
res.append(d) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
161 |
return res |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
162 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
163 |
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
|
164 |
"""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
|
165 |
|
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
166 |
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
|
167 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
168 |
# 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
|
169 |
# 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
|
170 |
dispatch_dict = { |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
} |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
176 |
|
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
177 |
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
|
178 |
kernel_paths): |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
179 |
"""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
|
180 |
files it installs. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
181 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
182 |
'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
|
183 |
found in deps. |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
184 |
|
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
185 |
'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
|
186 |
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
|
187 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
188 |
'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
|
189 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
190 |
'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
|
191 |
$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
|
192 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
193 |
'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
|
194 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
195 |
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
|
196 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
197 |
'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
|
198 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
199 |
'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
|
200 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
201 |
'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
|
202 |
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
|
203 |
|
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
204 |
'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
|
205 |
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
|
206 |
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
|
207 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
208 |
deps = [] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
209 |
elist = [] |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
210 |
missing = {} |
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
211 |
pkg_attrs = {} |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
|
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
215 |
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
|
216 |
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
|
217 |
try: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
218 |
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
|
219 |
except KeyError: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
220 |
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
|
221 |
missing[file_type] = \ |
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
222 |
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
|
223 |
else: |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
224 |
try: |
1933
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
225 |
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
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
deps.extend(ds) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
230 |
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
|
231 |
__update_pkg_attrs(pkg_attrs, attrs) |
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
232 |
|
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
233 |
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
|
234 |
elist.append(e) |
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
|
5193ac03ad9f
15305 need to generate dependency information from SMF manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
1908
diff
changeset
|
239 |
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
|
240 |
"""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
|
241 |
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
|
242 |
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
|
243 |
|
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
244 |
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
|
245 |
"""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
|
246 |
|
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
|
247 |
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
|
248 |
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
|
249 |
acts = [] |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
250 |
missing_files = [] |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
251 |
accumulate = "" |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
continue |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
257 |
elif accumulate: |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
258 |
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
|
259 |
accumulate = "" |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
260 |
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
|
261 |
continue |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
262 |
try: |
1908
4bdaf0463bae
15843 pkgdepend can't handle more than one proto area
Brock Pytlik <bpytlik@sun.com>
parents:
1887
diff
changeset
|
263 |
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
|
264 |
basedirs=basedirs, |
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
else: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
278 |
path = e.path |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
279 |
# 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
|
280 |
# 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
|
281 |
# 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
|
282 |
if not path: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
283 |
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
|
284 |
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
|
285 |
fh.close() |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
1934
diff
changeset
|
286 |
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
|
287 |
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
|
288 |
|
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
|
289 |
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
|
290 |
"""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
|
291 |
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
|
292 |
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
|
293 |
'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
|
294 |
|
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
|
295 |
'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
|
296 |
|
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
|
297 |
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
|
298 |
return urllib.unquote(os.path.basename(fp)) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1337
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
|
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
304 |
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
|
305 |
"""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
|
306 |
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
|
307 |
|
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
|
308 |
'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
|
309 |
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
|
310 |
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
|
311 |
|
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
|
312 |
'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
|
313 |
|
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
|
314 |
'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
|
315 |
satisfied. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
316 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
317 |
'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
|
318 |
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
|
319 |
|
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
|
320 |
res = [] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
321 |
vars = [] |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
322 |
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
|
323 |
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
|
324 |
# 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
|
325 |
# where the dependency is, skip it. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
326 |
if not orig_dep_vars.intersects(delivered_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
|
327 |
continue |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
328 |
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
|
329 |
# 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
|
330 |
# 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
|
331 |
# 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
|
332 |
# 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
|
333 |
if found_fmri != pfmri and \ |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
334 |
(delivered_vars.intersects(found_vars) or |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
335 |
found_vars.intersects(delivered_vars)): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
336 |
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
|
337 |
errs.add(pfmri) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
338 |
# Find the variants under which pfmri is relevant. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
339 |
action_vars = orig_dep_vars.intersection(delivered_vars) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
340 |
# 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
|
341 |
# 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
|
342 |
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
|
343 |
attrs = file_dep.attrs.copy() |
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
|
344 |
attrs.update({"fmri":str(pfmri)}) |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
345 |
# 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
|
346 |
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
|
347 |
action_vars)) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
348 |
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
|
349 |
if errs: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
350 |
# 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
|
351 |
# 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
|
352 |
# situation is unresolvable. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
353 |
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
|
354 |
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
|
355 |
|
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
356 |
def make_paths(file_dep): |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
357 |
"""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
|
358 |
'file_dep'.""" |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
359 |
|
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
if isinstance(files, basestring): |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
363 |
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
|
364 |
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
|
365 |
rps = [rps] |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
366 |
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
|
367 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
368 |
def find_package_using_delivered_files(delivered, 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
|
369 |
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
|
370 |
"""Uses a dictionary mapping file paths to packages to determine which |
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
|
371 |
package delivers the dependency under which variants. |
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
|
372 |
|
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 |
'delivered' is a dictionary mapping paths to a list of fmri, variants |
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 |
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
|
375 |
|
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 |
'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
|
377 |
|
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 |
'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
|
379 |
resolved. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
380 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
381 |
'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
|
382 |
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
|
383 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
384 |
res = None |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
385 |
errs = [] |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
386 |
multiple_path_errs = {} |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
387 |
for p in make_paths(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
|
388 |
delivered_list = [] |
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
|
389 |
if p in delivered: |
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 |
delivered_list = delivered[p] |
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
|
391 |
|
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
|
392 |
# XXX Eventually, this needs to be changed to use 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
|
393 |
# link information provided by the manifests being |
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 |
# resolved against, including the packages currently being |
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 |
# published. |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
396 |
try: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
397 |
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
|
398 |
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
|
399 |
except AmbiguousPathError, e: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
400 |
errs.append(e) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
401 |
else: |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
402 |
# 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
|
403 |
# 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
|
404 |
# 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
|
405 |
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
|
406 |
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
|
407 |
na.attrs[files_prefix] = [p] |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
408 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
409 |
if not res: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
410 |
res = new_res |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
411 |
continue |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
412 |
# 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
|
413 |
# 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
|
414 |
# 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
|
415 |
# 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
|
416 |
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
|
417 |
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
|
418 |
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
|
419 |
new_a.attrs["fmri"]: |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
420 |
a.attrs[files_prefix].extend( |
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
421 |
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
|
422 |
continue |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
423 |
# 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
|
424 |
# 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
|
425 |
# 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
|
426 |
# satisfies the dependencies. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
427 |
if v.intersects(new_v) or \ |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
428 |
new_v.intersects(v): |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
429 |
multiple_path_errs.setdefault(a, |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
430 |
set([a])) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
431 |
multiple_path_errs[a].add(new_a) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
432 |
else: |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
433 |
res.append((new_a, new_v)) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
434 |
for a in multiple_path_errs: |
1580
2763f36d0eda
13136 pkgdep test cases shouldn't reference installed image
Brock Pytlik <bpytlik@sun.com>
parents:
1544
diff
changeset
|
435 |
errs.append(MultiplePackagesPathError(multiple_path_errs[a], |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
436 |
file_dep)) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
437 |
|
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
438 |
# 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
|
439 |
# multiple path errors. |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
440 |
return [(a, v) for a, v in res if a not in multiple_path_errs], \ |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
441 |
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
|
442 |
|
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
|
443 |
def find_package(delivered, installed, 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
|
444 |
"""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
|
445 |
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
|
446 |
|
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
|
447 |
'delivered' and 'installed' are dictionaries mapping paths to |
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
|
448 |
a list of fmri, variants pairs. |
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
|
449 |
|
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
|
450 |
'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
|
451 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
452 |
'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
|
453 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
454 |
file_dep, orig_dep_vars = split_off_variants(file_dep, pkg_vars) |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
455 |
dep_vars = orig_dep_vars.copy() |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
456 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
457 |
# First try to resolve the dependency against the delivered files. |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
458 |
res, dep_vars, errs = find_package_using_delivered_files(delivered, |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
459 |
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
|
460 |
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
|
461 |
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
|
462 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
463 |
# 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
|
464 |
# 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
|
465 |
# |
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
|
466 |
# 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
|
467 |
# above. |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
468 |
inst_res, dep_vars, inst_errs = find_package_using_delivered_files( |
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
|
469 |
installed, file_dep, dep_vars, dep_vars.get_unsatisfied()) |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
470 |
res.extend(inst_res) |
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
471 |
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
|
472 |
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
|
473 |
|
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
|
474 |
def is_file_dependency(act): |
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
|
475 |
return (act.name == "depend" and |
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
|
476 |
act.attrs.get("fmri", None) == base.Dependency.DUMMY_FMRI |
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
|
477 |
and 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
|
478 |
|
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
479 |
def merge_deps(dest, src): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
480 |
"""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
|
481 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
482 |
for k, v in src.attrs.items(): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
483 |
# 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
|
484 |
# then something's gone horribly wrong. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
485 |
assert(not k.startswith("variant.")) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
486 |
if k not in dest.attrs: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
487 |
dest.attrs[k] = v |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
488 |
elif v != dest.attrs[k]: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
489 |
# 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
|
490 |
# will be removed in a later step. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
491 |
if isinstance(v, basestring): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
492 |
v = [v] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
493 |
if isinstance(dest.attrs[k], list): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
494 |
dest.attrs[k].extend(v) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
495 |
else: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
496 |
t = [dest.attrs[k]] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
497 |
t.extend(v) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
498 |
dest.attrs[k] = t |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
499 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
500 |
def combine(deps, pkg_vars): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
501 |
"""Combine duplicate dependency actions. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
502 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
503 |
'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
|
504 |
the variants associated with that dependency. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
505 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
506 |
'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
|
507 |
being generated was published against.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
508 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
509 |
def action_group_key(d): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
510 |
"""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
|
511 |
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
|
512 |
in pkg.manifest notices.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
513 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
514 |
# d[0] is the action. d[1] is the VariantSet for this action. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
515 |
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
|
516 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
517 |
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
|
518 |
"""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
|
519 |
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
|
520 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
521 |
d_vars.remove_identical(pkg_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
522 |
d.attrs.update(d_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
523 |
# Remove any duplicate values for any attributes. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
524 |
d.consolidate_attrs() |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
525 |
return d |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
526 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
527 |
def key_on_variants(a): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
528 |
"""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
|
529 |
by.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
530 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
531 |
return a[1] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
532 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
533 |
def sort_by_variant_subsets(a, b): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
534 |
"""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
|
535 |
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
|
536 |
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
|
537 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
538 |
if a.issubset(b): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
539 |
return 1 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
540 |
elif b.issubset(a): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
541 |
return -1 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
542 |
return 0 |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
543 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
544 |
# 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
|
545 |
# 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
|
546 |
# 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
|
547 |
# 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
|
548 |
# been found for this package: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
549 |
# 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
|
550 |
# 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
|
551 |
# 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
|
552 |
# 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
|
553 |
# 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
|
554 |
# v.n=one,two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
555 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
556 |
# 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
|
557 |
# 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
|
558 |
# contains dependencies 3, 4, and 5. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
559 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
560 |
# 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
|
561 |
# 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
|
562 |
# 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
|
563 |
# 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
|
564 |
# 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
|
565 |
# 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
|
566 |
# 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
|
567 |
# 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
|
568 |
# would look something like: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
569 |
# 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
|
570 |
# 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
|
571 |
# dependency 1's variant set. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
572 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
573 |
# 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
|
574 |
# 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
|
575 |
# 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
|
576 |
# 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
|
577 |
# 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
|
578 |
# 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
|
579 |
# 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
|
580 |
# that's added to final_res is: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
581 |
# 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
|
582 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
583 |
# 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
|
584 |
# 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
|
585 |
# 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
|
586 |
# 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
|
587 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
588 |
# 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
|
589 |
# 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
|
590 |
# 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
|
591 |
# 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
|
592 |
# 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
|
593 |
# 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
|
594 |
# producing this dependency: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
595 |
# 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
|
596 |
# v.f=bar v.n=one,two |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
597 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
598 |
# 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
|
599 |
# 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
|
600 |
# 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
|
601 |
# 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
|
602 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
603 |
# 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
|
604 |
# 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
|
605 |
# also been coalesced. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
606 |
# |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
607 |
# 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
|
608 |
# package are: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
609 |
# 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
|
610 |
# 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
|
611 |
# 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
|
612 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
613 |
res = [] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
614 |
# 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
|
615 |
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
|
616 |
action_group_key): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
617 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
618 |
# 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
|
619 |
# 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
|
620 |
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
|
621 |
key=key_on_variants) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
622 |
subres = [glist[0]] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
623 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
624 |
# 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
|
625 |
# d will be applied. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
626 |
for d, d_vars in glist[1:]: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
627 |
found_subset = False |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
628 |
for rel_res, rel_vars in subres: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
629 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
630 |
# 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
|
631 |
# 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
|
632 |
# combined with that dependency. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
633 |
if d_vars.issubset(rel_vars): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
634 |
found_subset = True |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
635 |
merge_deps(rel_res, d) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
636 |
break |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
637 |
assert(not rel_vars.issubset(d_vars)) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
638 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
639 |
# 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
|
640 |
# 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
|
641 |
# so add it to the results. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
642 |
if not found_subset: |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
643 |
subres.append((d, d_vars)) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
644 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
645 |
# 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
|
646 |
# 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
|
647 |
subres = [add_vars(d, d_vars, pkg_vars) for d, d_vars in subres] |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
648 |
res.extend(subres) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
649 |
return res |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
650 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
651 |
def split_off_variants(dep, pkg_vars): |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
652 |
"""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
|
653 |
tags into a VariantSet.""" |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
654 |
|
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
655 |
dep_vars = variants.VariantSets(dep.get_variants()) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
656 |
dep_vars.merge_unknown(pkg_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
657 |
# 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
|
658 |
# 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
|
659 |
# 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
|
660 |
dep.strip_variants() |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
661 |
return dep, dep_vars |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
662 |
|
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
663 |
def prune_debug_attrs(action): |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
664 |
"""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
|
665 |
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
|
666 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
667 |
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
|
668 |
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
|
669 |
return actions.depend.DependencyAction(**attrs) |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
670 |
|
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
|
671 |
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
|
672 |
"""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
|
673 |
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
|
674 |
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
|
675 |
|
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1231
diff
changeset
|
676 |
'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
|
677 |
|
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
678 |
'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
|
679 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
680 |
'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
|
681 |
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
|
682 |
|
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
683 |
def add_fmri_path_mapping(pathdict, pfmri, mfst): |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
684 |
"""Add mappings from path names to FMRIs and variants. |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
685 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
686 |
'pathdict' is a dict path -> (fmri, variants) to which |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
687 |
entries are added. |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
688 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
689 |
'pfmri' is the FMRI of the current manifest |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
690 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
691 |
'mfst' is the manifest to process.""" |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
692 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
693 |
pvariants = mfst.get_all_variants() |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
694 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
695 |
for f in itertools.chain(mfst.gen_actions_by_type("file"), |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
696 |
mfst.gen_actions_by_type("hardlink"), |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
697 |
mfst.gen_actions_by_type("link")): |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
698 |
dep_vars = variants.VariantSets(f.get_variants()) |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
699 |
dep_vars.merge_unknown(pvariants) |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
700 |
pathdict.setdefault(f.attrs["path"], []).append( |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
701 |
(pfmri, dep_vars)) |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
702 |
|
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
703 |
|
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
704 |
# 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
|
705 |
# 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
|
706 |
# 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
|
707 |
# 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
|
708 |
# 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
|
709 |
# 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
|
710 |
manifests = [ |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
711 |
(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
|
712 |
missing_files) |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
713 |
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
|
714 |
((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
|
715 |
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
|
716 |
] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
717 |
|
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
|
718 |
delivered_files = {} |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
719 |
installed_files = {} |
1856
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
720 |
|
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
|
721 |
# 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
|
722 |
for mp, name, mfst, pkg_vars, miss_files in manifests: |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
723 |
pfmri = fmri.PkgFmri(name).get_short_fmri() |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
724 |
add_fmri_path_mapping(delivered_files, pfmri, mfst) |
68eb900fbed5
14869 pkgdepend shouldn't include the timestamp in resolved dependencies
Richard Lowe <richlowe@richlowe.net>
parents:
1845
diff
changeset
|
725 |
|
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
726 |
# 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
|
727 |
# 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
|
728 |
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
|
729 |
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
|
730 |
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
|
731 |
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
|
732 |
mfst = api_inst.get_manifest(pfmri, all_variants=True) |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
733 |
add_fmri_path_mapping(installed_files, |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1856
diff
changeset
|
734 |
pfmri.get_short_fmri(), mfst) |
1581
37d9bf54ee23
13058 search makes resolve go slow
Brock Pytlik <bpytlik@sun.com>
parents:
1580
diff
changeset
|
735 |
|
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
|
736 |
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
|
737 |
errs = [] |
1500
fb15a23b6915
11805 pkgdep generate doesn't respect the payload path for file actions
Brock Pytlik <bpytlik@sun.com>
parents:
1431
diff
changeset
|
738 |
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
|
739 |
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
|
740 |
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
|
741 |
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
|
742 |
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
|
743 |
pkg_res = [ |
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
|
744 |
(d, find_package(delivered_files, installed_files, |
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
|
745 |
d, 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
|
746 |
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
|
747 |
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
|
748 |
] |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
749 |
# 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
|
750 |
# manually. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
751 |
deps = [ |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
752 |
split_off_variants(d, pkg_vars) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
753 |
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
|
754 |
if not is_file_dependency(d) |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
755 |
] |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
756 |
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
|
757 |
errs.extend(pkg_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
|
758 |
if not 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
|
759 |
dep_vars.merge_unknown(pkg_vars) |
1544
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
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
|
764 |
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
|
765 |
errs.append(UnresolvedDependencyError( |
e0ce5081236a
12697 pkgdep throws an exception for $PLATFORM or $ISALIST in runpath
Brock Pytlik <bpytlik@sun.com>
parents:
1516
diff
changeset
|
766 |
mp, file_dep, dep_vars)) |
1756
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
767 |
# 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
|
768 |
# what would otherwise be duplicate dependencies. |
0dd15313e977
14118 pkgdepend resolve results in repeated dependencies
Brock Pytlik <bpytlik@sun.com>
parents:
1674
diff
changeset
|
769 |
deps = combine(deps, pkg_vars) |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
770 |
|
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
771 |
if prune_attrs: |
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
772 |
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
|
773 |
pkg_deps[mp] = deps |
1845
d9a33bd442b5
14870 pkgdep should strip dependency debugging information
Richard Lowe <richlowe@richlowe.net>
parents:
1756
diff
changeset
|
774 |
|
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
|
775 |
return pkg_deps, errs |