author | Mike Sullivan <Mike.Sullivan@Oracle.COM> |
Fri, 13 May 2016 17:33:30 -0700 | |
changeset 5983 | f10ab5ae99d7 |
parent 5684 | 7bc997011220 |
child 6859 | 569bef81e3c4 |
permissions | -rw-r--r-- |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
2 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
4 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
8 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
13 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
19 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
21 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
22 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
23 |
# |
5342
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
24 |
# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
25 |
# |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
26 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
27 |
# Some userland consolidation specific lint checks |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
28 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
29 |
import pkg.lint.base as base |
186
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
30 |
from pkg.lint.engine import lint_fmri_successor |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
31 |
import pkg.elf as elf |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
32 |
import pkg.fmri |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
33 |
import platform |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
34 |
import re |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
35 |
import os.path |
1138
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
36 |
import subprocess |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
37 |
import sys |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
38 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
39 |
class UserlandActionChecker(base.ActionChecker): |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
40 |
"""An opensolaris.org-specific class to check actions.""" |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
41 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
42 |
name = "userland.action" |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
43 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
44 |
def __init__(self, config): |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
45 |
self.description = _( |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
46 |
"checks Userland packages for common content errors") |
117
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
47 |
path = os.getenv('PROTO_PATH') |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
48 |
if path != None: |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
49 |
self.proto_path = path.split() |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
50 |
else: |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
51 |
self.proto_path = None |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
52 |
solaris_ver = os.getenv('SOLARIS_VERSION', '') |
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
53 |
# |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
54 |
# These lists are used to check if a 32/64-bit binary |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
55 |
# is in a proper 32/64-bit directory. |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
56 |
# |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
57 |
self.pathlist32 = [ |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
58 |
"i86", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
59 |
"sparcv7", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
60 |
"32", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
61 |
"i86pc-solaris-64int", # perl path |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
62 |
"sun4-solaris-64int", # perl path |
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
63 |
"i386-solaris" + solaris_ver, # ruby path |
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
64 |
"sparc-solaris" + solaris_ver # ruby path |
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
65 |
] |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
66 |
self.pathlist64 = [ |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
67 |
"amd64", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
68 |
"sparcv9", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
69 |
"64", |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
70 |
"i86pc-solaris-64", # perl path |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
71 |
"sun4-solaris-64", # perl path |
4193
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
72 |
"i86pc-solaris-thread-multi-64", # perl path |
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
73 |
"sun4-solaris-thread-multi-64", # perl path |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
74 |
"amd64-solaris" + solaris_ver, # ruby path |
5342
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
75 |
"sparcv9-solaris" + solaris_ver,# ruby path |
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
76 |
"sparcv9-sun-solaris" + solaris_ver,# ruby path |
5684
7bc997011220
23013143 Update 64 bit paths in userland.py for ruby
Geoffrey Gardella <geoffrey.gardella@oracle.com>
parents:
5342
diff
changeset
|
77 |
"amd64-solaris-" + solaris_ver, # ruby path |
7bc997011220
23013143 Update 64 bit paths in userland.py for ruby
Geoffrey Gardella <geoffrey.gardella@oracle.com>
parents:
5342
diff
changeset
|
78 |
"sparcv9-solaris-" + solaris_ver,# ruby path |
5342
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
79 |
"x86_64-pc-solaris" + solaris_ver # GCC path |
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
80 |
] |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
81 |
self.runpath_re = [ |
99
c15c9099bb44
6841644 OpenSolaris Python should support gdbm
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
84
diff
changeset
|
82 |
re.compile('^/lib(/.*)?$'), |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
83 |
re.compile('^/usr/'), |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
84 |
re.compile('^\$ORIGIN/') |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
85 |
] |
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
86 |
self.runpath_64_re = [ |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
87 |
re.compile('^.*/64(/.*)?$'), |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
88 |
re.compile('^.*/amd64(/.*)?$'), |
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
89 |
re.compile('^.*/sparcv9(/.*)?$'), |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
90 |
re.compile('^.*/i86pc-solaris-64(/.*)?$'), # perl path |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
91 |
re.compile('^.*/sun4-solaris-64(/.*)?$'), # perl path |
4193
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
92 |
re.compile('^.*/i86pc-solaris-thread-multi-64(/.*)?$'), |
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
93 |
# perl path |
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
94 |
re.compile('^.*/sun4-solaris-thread-multi-64(/.*)?$'), |
cdabb94af4f2
PSARC 2014/435 Update Perl to version 5.20.1
Bill Rushmore <bill.rushmore@oracle.com>
parents:
4144
diff
changeset
|
95 |
# perl path |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
96 |
re.compile('^.*/amd64-solaris2\.[0-9]+(/.*)?$'), |
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
97 |
# ruby path |
5342
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
98 |
re.compile('^.*/sparcv9-solaris2\.[0-9]+(/.*)?$'), |
1756
3579365335ef
17591620 ruby 1.9 should not have its *.rb text files under amd64/sparcv9 directories
April Chin <april.chin@oracle.com>
parents:
1742
diff
changeset
|
99 |
# ruby path |
5342
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
100 |
re.compile('^.*/sparcv9-sun-solaris2\.[0-9]+(/.*)?$'), |
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
101 |
# GCC path |
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
102 |
re.compile('^.*/x86_64-sun-solaris2\.[0-9]+(/.*)?$') |
e55d87e99ecd
PSARC/2015/499 GCC v5.3, v4.9.3, and more
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4952
diff
changeset
|
103 |
# GCC path |
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
104 |
] |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
105 |
self.initscript_re = re.compile("^etc/(rc.|init)\.d") |
186
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
106 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
107 |
self.lint_paths = {} |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
108 |
self.ref_paths = {} |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
109 |
|
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
110 |
super(UserlandActionChecker, self).__init__(config) |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
111 |
|
186
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
112 |
def startup(self, engine): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
113 |
"""Initialize the checker with a dictionary of paths, so that we |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
114 |
can do link resolution. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
115 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
116 |
This is copied from the core pkglint code, but should eventually |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
117 |
be made common. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
118 |
""" |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
119 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
120 |
def seed_dict(mf, attr, dic, atype=None, verbose=False): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
121 |
"""Updates a dictionary of { attr: [(fmri, action), ..]} |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
122 |
where attr is the value of that attribute from |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
123 |
actions of a given type atype, in the given |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
124 |
manifest.""" |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
125 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
126 |
pkg_vars = mf.get_all_variants() |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
127 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
128 |
if atype: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
129 |
mfg = (a for a in mf.gen_actions_by_type(atype)) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
130 |
else: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
131 |
mfg = (a for a in mf.gen_actions()) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
132 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
133 |
for action in mfg: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
134 |
if atype and action.name != atype: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
135 |
continue |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
136 |
if attr not in action.attrs: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
137 |
continue |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
138 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
139 |
variants = action.get_variant_template() |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
140 |
variants.merge_unknown(pkg_vars) |
4144
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
141 |
# Action attributes must be lists or strings. |
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
142 |
for k, v in variants.iteritems(): |
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
143 |
if isinstance(v, set): |
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
144 |
action.attrs[k] = list(v) |
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
145 |
else: |
d46329d3d81e
20861377 pkglint crashes in openssl on s12-70 sparc
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
4069
diff
changeset
|
146 |
action.attrs[k] = v |
186
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
147 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
148 |
p = action.attrs[attr] |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
149 |
dic.setdefault(p, []).append((mf.fmri, action)) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
150 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
151 |
# construct a set of FMRIs being presented for linting, and |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
152 |
# avoid seeding the reference dictionary with any for which |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
153 |
# we're delivering new packages. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
154 |
lint_fmris = {} |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
155 |
for m in engine.gen_manifests(engine.lint_api_inst, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
156 |
release=engine.release, pattern=engine.pattern): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
157 |
lint_fmris.setdefault(m.fmri.get_name(), []).append(m.fmri) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
158 |
for m in engine.lint_manifests: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
159 |
lint_fmris.setdefault(m.fmri.get_name(), []).append(m.fmri) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
160 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
161 |
engine.logger.debug( |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
162 |
_("Seeding reference action path dictionaries.")) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
163 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
164 |
for manifest in engine.gen_manifests(engine.ref_api_inst, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
165 |
release=engine.release): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
166 |
# Only put this manifest into the reference dictionary |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
167 |
# if it's not an older version of the same package. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
168 |
if not any( |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
169 |
lint_fmri_successor(fmri, manifest.fmri) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
170 |
for fmri |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
171 |
in lint_fmris.get(manifest.fmri.get_name(), []) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
172 |
): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
173 |
seed_dict(manifest, "path", self.ref_paths) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
174 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
175 |
engine.logger.debug( |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
176 |
_("Seeding lint action path dictionaries.")) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
177 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
178 |
# we provide a search pattern, to allow users to lint a |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
179 |
# subset of the packages in the lint_repository |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
180 |
for manifest in engine.gen_manifests(engine.lint_api_inst, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
181 |
release=engine.release, pattern=engine.pattern): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
182 |
seed_dict(manifest, "path", self.lint_paths) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
183 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
184 |
engine.logger.debug( |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
185 |
_("Seeding local action path dictionaries.")) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
186 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
187 |
for manifest in engine.lint_manifests: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
188 |
seed_dict(manifest, "path", self.lint_paths) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
189 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
190 |
self.__merge_dict(self.lint_paths, self.ref_paths, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
191 |
ignore_pubs=engine.ignore_pubs) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
192 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
193 |
def __merge_dict(self, src, target, ignore_pubs=True): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
194 |
"""Merges the given src dictionary into the target |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
195 |
dictionary, giving us the target content as it would appear, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
196 |
were the packages in src to get published to the |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
197 |
repositories that made up target. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
198 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
199 |
We need to only merge packages at the same or successive |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
200 |
version from the src dictionary into the target dictionary. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
201 |
If the src dictionary contains a package with no version |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
202 |
information, it is assumed to be more recent than the same |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
203 |
package with no version in the target.""" |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
204 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
205 |
for p in src: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
206 |
if p not in target: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
207 |
target[p] = src[p] |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
208 |
continue |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
209 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
210 |
def build_dic(arr): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
211 |
"""Builds a dictionary of fmri:action entries""" |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
212 |
dic = {} |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
213 |
for (pfmri, action) in arr: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
214 |
if pfmri in dic: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
215 |
dic[pfmri].append(action) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
216 |
else: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
217 |
dic[pfmri] = [action] |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
218 |
return dic |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
219 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
220 |
src_dic = build_dic(src[p]) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
221 |
targ_dic = build_dic(target[p]) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
222 |
|
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
223 |
for src_pfmri in src_dic: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
224 |
# we want to remove entries deemed older than |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
225 |
# src_pfmri from targ_dic. |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
226 |
for targ_pfmri in targ_dic.copy(): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
227 |
sname = src_pfmri.get_name() |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
228 |
tname = targ_pfmri.get_name() |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
229 |
if lint_fmri_successor(src_pfmri, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
230 |
targ_pfmri, |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
231 |
ignore_pubs=ignore_pubs): |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
232 |
targ_dic.pop(targ_pfmri) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
233 |
targ_dic.update(src_dic) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
234 |
l = [] |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
235 |
for pfmri in targ_dic: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
236 |
for action in targ_dic[pfmri]: |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
237 |
l.append((pfmri, action)) |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
238 |
target[p] = l |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
239 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
240 |
def __realpath(self, path, target): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
241 |
"""Combine path and target to get the real path.""" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
242 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
243 |
result = os.path.dirname(path) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
244 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
245 |
for frag in target.split(os.sep): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
246 |
if frag == '..': |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
247 |
result = os.path.dirname(result) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
248 |
elif frag == '.': |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
249 |
pass |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
250 |
else: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
251 |
result = os.path.join(result, frag) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
252 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
253 |
return result |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
254 |
|
1138
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
255 |
def __elf_aslr_check(self, path, engine): |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
256 |
result = None |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
257 |
|
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
258 |
ei = elf.get_info(path) |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
259 |
type = ei.get("type"); |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
260 |
if type != "exe": |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
261 |
return result |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
262 |
|
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
263 |
# get the ASLR tag string for this binary |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
264 |
aslr_tag_process = subprocess.Popen( |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
265 |
"/usr/bin/elfedit -r -e 'dyn:sunw_aslr' " |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
266 |
+ path, shell=True, |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
267 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
268 |
|
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
269 |
# aslr_tag_string will get stdout; err will get stderr |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
270 |
aslr_tag_string, err = aslr_tag_process.communicate() |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
271 |
|
1742
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
272 |
# No ASLR tag was found; everything must be tagged |
1138
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
273 |
if aslr_tag_process.returncode != 0: |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
274 |
engine.error( |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
275 |
_("'%s' is not tagged for aslr") % (path), |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
276 |
msgid="%s%s.5" % (self.name, "001")) |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
277 |
return result |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
278 |
|
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
279 |
# look for "ENABLE" anywhere in the string; |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
280 |
# warn about binaries which are not ASLR enabled |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
281 |
if re.search("ENABLE", aslr_tag_string) is not None: |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
282 |
return result |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
283 |
engine.warning( |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
284 |
_("'%s' does not have aslr enabled") % (path), |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
285 |
msgid="%s%s.6" % (self.name, "001")) |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
286 |
return result |
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
287 |
|
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
288 |
def __elf_runpath_check(self, path, engine): |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
289 |
result = None |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
290 |
list = [] |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
291 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
292 |
ed = elf.get_dynamic(path) |
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
293 |
ei = elf.get_info(path) |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
294 |
bits = ei.get("bits") |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
295 |
for dir in ed.get("runpath", "").split(":"): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
296 |
if dir == None or dir == '': |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
297 |
continue |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
298 |
|
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
299 |
match = False |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
300 |
for expr in self.runpath_re: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
301 |
if expr.match(dir): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
302 |
match = True |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
303 |
break |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
304 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
305 |
if match == False: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
306 |
list.append(dir) |
1742
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
307 |
# Make sure RUNPATH matches against a packaged path. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
308 |
# Don't check runpaths starting with $ORIGIN, which |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
309 |
# is specially handled by the linker. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
310 |
|
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
311 |
elif not dir.startswith('$ORIGIN/'): |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
312 |
|
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
313 |
# Strip out leading and trailing '/' in the |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
314 |
# runpath, since the reference paths don't start |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
315 |
# with '/' and trailing '/' could cause mismatches. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
316 |
# Check first if there is an exact match, then check |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
317 |
# if any reference path starts with this runpath |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
318 |
# plus a trailing slash, since it may still be a link |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
319 |
# to a directory that has no action because it uses |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
320 |
# the default attributes. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
321 |
|
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
322 |
relative_dir = dir.strip('/') |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
323 |
if not relative_dir in self.ref_paths and \ |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
324 |
not any(key.startswith(relative_dir + '/') |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
325 |
for key in self.ref_paths): |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
326 |
|
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
327 |
# If still no match, if the runpath contains |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
328 |
# an embedded symlink, emit a warning; it may or may |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
329 |
# not resolve to a legitimate path. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
330 |
# E.g., for usr/openwin/lib, usr/openwin->X11 and |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
331 |
# usr/X11/lib are packaged, but usr/openwin/lib is not. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
332 |
# Otherwise, runpath is bad; add it to list. |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
333 |
embedded_link = False |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
334 |
pdir = os.path.dirname(relative_dir) |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
335 |
while pdir != '': |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
336 |
if (pdir in self.ref_paths and |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
337 |
self.ref_paths[pdir][0][1].name == "link"): |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
338 |
embedded_link = True |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
339 |
engine.warning( |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
340 |
_("runpath '%s' in '%s' not found in reference paths but contains symlink at '%s'") % (dir, path, pdir), |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
341 |
msgid="%s%s.3" % (self.name, "001")) |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
342 |
break |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
343 |
pdir = os.path.dirname(pdir) |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
344 |
if not embedded_link: |
1bfc3321abb4
18202547 memcached lib comes with erroneous RPATH and RUNPATH
April Chin <april.chin@oracle.com>
parents:
1512
diff
changeset
|
345 |
list.append(dir) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
346 |
|
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
347 |
if bits == 32: |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
348 |
for expr in self.runpath_64_re: |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
349 |
if expr.search(dir): |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
350 |
engine.warning( |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
351 |
_("64-bit runpath in 32-bit binary, '%s' includes '%s'") % (path, dir), |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
352 |
msgid="%s%s.3" % (self.name, "001")) |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
353 |
else: |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
354 |
match = False |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
355 |
for expr in self.runpath_64_re: |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
356 |
if expr.search(dir): |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
357 |
match = True |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
358 |
break |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
359 |
if match == False: |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
360 |
engine.warning( |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
361 |
_("32-bit runpath in 64-bit binary, '%s' includes '%s'") % (path, dir), |
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
362 |
msgid="%s%s.3" % (self.name, "001")) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
363 |
if len(list) > 0: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
364 |
result = _("bad RUNPATH, '%%s' includes '%s'" % |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
365 |
":".join(list)) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
366 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
367 |
return result |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
368 |
|
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
369 |
def __elf_wrong_location_check(self, path, inspath): |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
370 |
result = None |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
371 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
372 |
ei = elf.get_info(path) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
373 |
bits = ei.get("bits") |
495
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
374 |
type = ei.get("type"); |
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
375 |
elems = os.path.dirname(inspath).split("/") |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
376 |
|
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
377 |
path64 = False |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
378 |
for p in self.pathlist64: |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
379 |
if (p in elems): |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
380 |
path64 = True |
168
5884bc1edfdf
7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents:
145
diff
changeset
|
381 |
|
1146
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
382 |
path32 = False |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
383 |
for p in self.pathlist32: |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
384 |
if (p in elems): |
94088715b2bf
PSARC/2012/379 Add Perl 5.16 64-bit and make it the system default
Craig Mohrman <craig.mohrman@oracle.com>
parents:
1138
diff
changeset
|
385 |
path32 = True |
495
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
386 |
|
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
387 |
# ignore 64-bit executables in normal (non-32-bit-specific) |
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
388 |
# locations, that's ok now. |
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
389 |
if (type == "exe" and bits == 64 and path32 == False and path64 == False): |
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
390 |
return result |
4153db6738f5
7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
464
diff
changeset
|
391 |
|
168
5884bc1edfdf
7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents:
145
diff
changeset
|
392 |
if bits == 32 and path64: |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
393 |
result = _("32-bit object '%s' in 64-bit path") |
168
5884bc1edfdf
7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents:
145
diff
changeset
|
394 |
elif bits == 64 and not path64: |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
395 |
result = _("64-bit object '%s' in 32-bit path") |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
396 |
return result |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
397 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
398 |
def file_action(self, action, manifest, engine, pkglint_id="001"): |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
399 |
"""Checks for existence in the proto area.""" |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
400 |
|
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
401 |
if action.name not in ["file"]: |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
402 |
return |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
403 |
|
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
404 |
inspath=action.attrs["path"] |
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
405 |
|
117
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
406 |
path = action.hash |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
407 |
if path == None or path == 'NOHASH': |
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
408 |
path = inspath |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
409 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
410 |
# check for writable files without a preserve attribute |
145
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
411 |
if "mode" in action.attrs: |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
412 |
mode = action.attrs["mode"] |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
413 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
414 |
if (int(mode, 8) & 0222) != 0 and "preserve" not in action.attrs: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
415 |
engine.error( |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
416 |
_("%(path)s is writable (%(mode)s), but missing a preserve" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
417 |
" attribute") % {"path": path, "mode": mode}, |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
418 |
msgid="%s%s.0" % (self.name, pkglint_id)) |
145
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
419 |
elif "preserve" in action.attrs: |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
420 |
if "mode" in action.attrs: |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
421 |
mode = action.attrs["mode"] |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
422 |
if (int(mode, 8) & 0222) == 0: |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
423 |
engine.error( |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
424 |
_("%(path)s has a preserve action, but is not writable (%(mode)s)") % {"path": path, "mode": mode}, |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
425 |
msgid="%s%s.4" % (self.name, pkglint_id)) |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
426 |
else: |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
427 |
engine.error( |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
428 |
_("%(path)s has a preserve action, but no mode") % {"path": path, "mode": mode}, |
1e2390f5555e
7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
117
diff
changeset
|
429 |
msgid="%s%s.3" % (self.name, pkglint_id)) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
430 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
431 |
# checks that require a physical file to look at |
117
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
432 |
if self.proto_path is not None: |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
433 |
for directory in self.proto_path: |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
434 |
fullpath = directory + "/" + path |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
435 |
|
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
436 |
if os.path.exists(fullpath): |
8f634eb6f66b
7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
99
diff
changeset
|
437 |
break |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
438 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
439 |
if not os.path.exists(fullpath): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
440 |
engine.info( |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
441 |
_("%s missing from proto area, skipping" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
442 |
" content checks") % path, |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
443 |
msgid="%s%s.1" % (self.name, pkglint_id)) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
444 |
elif elf.is_elf_object(fullpath): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
445 |
# 32/64 bit in wrong place |
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
446 |
result = self.__elf_wrong_location_check(fullpath, inspath) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
447 |
if result != None: |
1512
f57514e19ede
17596443 nm -p output change breaks userland
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
1251
diff
changeset
|
448 |
engine.error(result % inspath, |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
449 |
msgid="%s%s.2" % (self.name, pkglint_id)) |
623
15f87c23a86e
7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
495
diff
changeset
|
450 |
result = self.__elf_runpath_check(fullpath, engine) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
451 |
if result != None: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
452 |
engine.error(result % path, |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
453 |
msgid="%s%s.3" % (self.name, pkglint_id)) |
1138
6e1f85fa0151
15801420 SUNBT7180909 tag the Userland consolidation binaries for ASLR
April Chin <april.chin@oracle.com>
parents:
1020
diff
changeset
|
454 |
result = self.__elf_aslr_check(fullpath, engine) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
455 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
456 |
file_action.pkglint_desc = _("Paths should exist in the proto area.") |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
457 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
458 |
def link_resolves(self, action, manifest, engine, pkglint_id="002"): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
459 |
"""Checks for link resolution.""" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
460 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
461 |
if action.name not in ["link", "hardlink"]: |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
462 |
return |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
463 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
464 |
path = action.attrs["path"] |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
465 |
target = action.attrs["target"] |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
466 |
realtarget = self.__realpath(path, target) |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
467 |
|
186
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
468 |
# Check against the target image (ref_paths), since links might |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
469 |
# resolve outside the packages delivering a particular |
3adedf0f9f4d
7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents:
181
diff
changeset
|
470 |
# component. |
1251
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
471 |
|
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
472 |
# links to files should directly match a patch in the reference |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
473 |
# repo. |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
474 |
if self.ref_paths.get(realtarget, None): |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
475 |
return |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
476 |
|
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
477 |
# If it didn't match a path in the reference repo, it may still |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
478 |
# be a link to a directory that has no action because it uses |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
479 |
# the default attributes. Look for a path that starts with |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
480 |
# this value plus a trailing slash to be sure this it will be |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
481 |
# resolvable on a fully installed system. |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
482 |
realtarget += '/' |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
483 |
for key in self.ref_paths: |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
484 |
if key.startswith(realtarget): |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
485 |
return |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
486 |
|
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
487 |
engine.error(_("%s %s has unresolvable target '%s'") % |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
488 |
(action.name, path, target), |
f1fb66b52f41
16611225 foomatic-rip delivers obsolete LP functionality
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
1146
diff
changeset
|
489 |
msgid="%s%s.0" % (self.name, pkglint_id)) |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
490 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
491 |
link_resolves.pkglint_desc = _("links should resolve.") |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
492 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
493 |
def init_script(self, action, manifest, engine, pkglint_id="003"): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
494 |
"""Checks for SVR4 startup scripts.""" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
495 |
|
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
496 |
if action.name not in ["file", "dir", "link", "hardlink"]: |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
497 |
return |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
498 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
499 |
path = action.attrs["path"] |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
500 |
if self.initscript_re.match(path): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
501 |
engine.warning( |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
502 |
_("SVR4 startup '%s', deliver SMF" |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
503 |
" service instead") % path, |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
504 |
msgid="%s%s.0" % (self.name, pkglint_id)) |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
505 |
|
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
506 |
init_script.pkglint_desc = _( |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
507 |
"SVR4 startup scripts should not be delivered.") |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
508 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
509 |
class UserlandManifestChecker(base.ManifestChecker): |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
510 |
"""An opensolaris.org-specific class to check manifests.""" |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
511 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
512 |
name = "userland.manifest" |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
513 |
|
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
514 |
def __init__(self, config): |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
515 |
super(UserlandManifestChecker, self).__init__(config) |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
516 |
|
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
517 |
def component_check(self, manifest, engine, pkglint_id="001"): |
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
518 |
manifest_paths = [] |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
519 |
files = False |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
520 |
license = False |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
521 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
522 |
for action in manifest.gen_actions_by_type("file"): |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
523 |
files = True |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
524 |
break |
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
525 |
|
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
526 |
if files == False: |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
527 |
return |
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
528 |
|
84
b80cfd4e0a16
7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
45
diff
changeset
|
529 |
for action in manifest.gen_actions_by_type("license"): |
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
530 |
license = True |
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
531 |
break |
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
532 |
|
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
533 |
if license == False: |
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
534 |
engine.error( _("missing license action"), |
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
535 |
msgid="%s%s.0" % (self.name, pkglint_id)) |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
536 |
|
464
08f94c414553
7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
186
diff
changeset
|
537 |
if 'org.opensolaris.arc-caseid' not in manifest: |
08f94c414553
7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
186
diff
changeset
|
538 |
engine.error( _("missing ARC data (org.opensolaris.arc-caseid)"), |
181
87e11e685b1f
7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
168
diff
changeset
|
539 |
msgid="%s%s.0" % (self.name, pkglint_id)) |
45
536ea324b223
initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff
changeset
|
540 |
|
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
541 |
component_check.pkglint_desc = _( |
464
08f94c414553
7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
186
diff
changeset
|
542 |
"license actions and ARC information are required if you deliver files.") |
1020
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
543 |
|
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
544 |
def publisher_in_fmri(self, manifest, engine, pkglint_id="002"): |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
545 |
lint_id = "%s%s" % (self.name, pkglint_id) |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
546 |
allowed_pubs = engine.get_param( |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
547 |
"%s.allowed_pubs" % lint_id).split(" ") |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
548 |
|
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
549 |
fmri = manifest.fmri |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
550 |
if fmri.publisher and fmri.publisher not in allowed_pubs: |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
551 |
engine.error(_("package %s has a publisher set!") % |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
552 |
manifest.fmri, |
4740049105f5
7030489 userland pkglint should check for publisher information in pkg.fmris
Rich Burridge <rich.burridge@oracle.com>
parents:
623
diff
changeset
|
553 |
msgid="%s%s.2" % (self.name, pkglint_id)) |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
554 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
555 |
publisher_in_fmri.pkglint_desc = _( |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
556 |
"Publishers mentioned in package FMRIs must be in fixed set.") |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
557 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
558 |
# CFFI names the modules it creates with a hash that includes the |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
559 |
# version of CFFI (since the schema may change from one version to |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
560 |
# another). This means that if a package depends on CFFI, then it must |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
561 |
# also incorporate the version it builds with, which should be the |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
562 |
# version in the gate. |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
563 |
def uses_cffi(self, manifest, engine, pkglint_id="003"): |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
564 |
cffi_match = {"fmri": "*/cffi*"} |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
565 |
cffi_require = None |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
566 |
cffi_incorp = None |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
567 |
for action in manifest.gen_actions_by_type("depend"): |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
568 |
if not any( |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
569 |
f |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
570 |
for f in action.attrlist("fmri") |
4952
8e5c57e2792a
21954564 Userland pkglint needs tweak for FOSS evaluation project
John Beck <John.Beck@Oracle.COM>
parents:
4193
diff
changeset
|
571 |
if "/cffi-" in pkg.fmri.PkgFmri(f, "5.12").pkg_name): |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
572 |
continue |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
573 |
if action.attrs["type"] in ("require", "require-any"): |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
574 |
cffi_require = action |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
575 |
elif action.attrs["type"] == "incorporate": |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
576 |
cffi_incorp = action |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
577 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
578 |
try: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
579 |
sys.path[0:0] = [os.path.join(os.getenv("WS_TOP", ""), |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
580 |
"components/python/cffi/build/prototype/" |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
581 |
"%s/usr/lib/python%d.%d/vendor-packages" % |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
582 |
((platform.processor(),) + sys.version_info[:2]))] |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
583 |
import cffi |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
584 |
cffi_version = cffi.__version__ |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
585 |
del sys.path[0] |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
586 |
except ImportError: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
587 |
cffi_version = None |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
588 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
589 |
if not cffi_require: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
590 |
return |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
591 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
592 |
if not cffi_version: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
593 |
engine.warning(_("package %s depends on CFFI, but we " |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
594 |
"cannot determine the version of CFFI needed") % |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
595 |
manifest.fmri, |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
596 |
msgid="%s%s.1" % (self.name, pkglint_id)) |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
597 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
598 |
if not cffi_incorp: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
599 |
engine.error(_("package %(pkg)s depends on CFFI, but " |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
600 |
"does not incorporate it (should be at %(should)s)") |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
601 |
% {"pkg": manifest.fmri, "should": cffi_version}, |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
602 |
msgid="%s%s.2" % (self.name, pkglint_id)) |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
603 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
604 |
# The final check can only be done if neither of the previous |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
605 |
# checks have fired. |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
606 |
if not cffi_version or not cffi_incorp: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
607 |
return |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
608 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
609 |
cffi_incorp_ver = str(pkg.fmri.PkgFmri( |
4952
8e5c57e2792a
21954564 Userland pkglint needs tweak for FOSS evaluation project
John Beck <John.Beck@Oracle.COM>
parents:
4193
diff
changeset
|
610 |
cffi_incorp.attrs["fmri"], "5.12").version.release) |
1846
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
611 |
if cffi_incorp_ver != cffi_version: |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
612 |
engine.error(_("package %(pkg)s depends on CFFI, but " |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
613 |
"incorporates it at the wrong version (%(actual)s " |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
614 |
"instead of %(should)s)") % {"pkg": manifest.fmri, |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
615 |
"actual": cffi_incorp_ver, "should": cffi_version}, |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
616 |
msgid="%s%s.3" % (self.name, pkglint_id)) |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
617 |
|
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
618 |
uses_cffi.pkglint_desc = _( |
df40919e04fa
PSARC/2014/110 CFFI: foreign function interface for Python calling C code
Danek Duvall <danek.duvall@oracle.com>
parents:
1756
diff
changeset
|
619 |
"Packages using CFFI incorporate CFFI at the correct version.") |