tools/python/pkglint/userland.py
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 19 Nov 2012 17:59:12 -0800
branchs11-update
changeset 2425 ef005fd07371
parent 623 15f87c23a86e
child 1020 4740049105f5
child 2528 788328aeec2a
permissions -rw-r--r--
Close of build 03.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
#
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
    24
# Copyright (c) 2010, 2011, 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
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    32
import re
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    33
import os.path
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    34
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    35
class UserlandActionChecker(base.ActionChecker):
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    36
        """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
    37
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    38
        name = "userland.action"
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    39
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    40
        def __init__(self, config):
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    41
                self.description = _(
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    42
                    "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
    43
		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
    44
		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
    45
			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
    46
		else:
8f634eb6f66b 7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 99
diff changeset
    47
			self.proto_path = None
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    48
		self.runpath_re = [
99
c15c9099bb44 6841644 OpenSolaris Python should support gdbm
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 84
diff changeset
    49
			re.compile('^/lib(/.*)?$'),
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    50
			re.compile('^/usr/'),
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    51
			re.compile('^\$ORIGIN/')
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    52
		]
623
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
    53
		self.runpath_64_re = [
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
    54
			re.compile('^.*/64(/.*)?$'),
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
    55
			re.compile('^.*/amd64(/.*)?$'),
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
    56
			re.compile('^.*/sparcv9(/.*)?$')
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
    57
		]
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
    58
		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
    59
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    60
                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
    61
                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
    62
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    63
                super(UserlandActionChecker, self).__init__(config)
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    64
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
    65
        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
    66
                """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
    67
                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
    68
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    69
                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
    70
                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
    71
                """
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    72
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    73
                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
    74
                        """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
    75
                        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
    76
                        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
    77
                        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
    78
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    79
                        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
    80
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    81
                        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
    82
                                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
    83
                        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
    84
                                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
    85
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    86
                        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
    87
                                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
    88
                                        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
    89
                                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
    90
                                        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
    91
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    92
                                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
    93
                                variants.merge_unknown(pkg_vars)
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    94
                                action.attrs.update(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
    95
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    96
                                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
    97
                                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
    98
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
    99
                # 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
   100
                # 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
   101
                # 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
   102
                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
   103
                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
   104
                    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
   105
                        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
   106
                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
   107
                        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
   108
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
                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
   110
                    _("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
   111
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
                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
   113
                    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
   114
                        # 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
   115
                        # 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
   116
                        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
   117
                            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
   118
                            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
   119
                            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
   120
                        ):
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
                                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
   122
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
                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
   124
                    _("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
   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
                # 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
   127
                # 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
   128
                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
   129
                    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
   130
                        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
   131
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
                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
   133
                    _("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
   134
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
                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
   136
                        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
   137
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
                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
   139
                    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
   140
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
   141
        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
   142
                """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
   143
                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
   144
                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
   145
                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
   146
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
                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
   148
                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
   149
                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
   150
                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
   151
                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
   152
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
                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
   154
                        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
   155
                                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
   156
                                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
   157
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
                        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
   159
                                """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
   160
                                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
   161
                                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
   162
                                        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
   163
                                                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
   164
                                        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
   165
                                                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
   166
                                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
   167
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
                        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
   169
                        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
   170
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
                        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
   172
                                # 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
   173
                                # 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
   174
                                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
   175
                                        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
   176
                                        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
   177
                                        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
   178
                                            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
   179
                                            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
   180
                                                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
   181
                        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
   182
                        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
   183
                        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
   184
                                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
   185
                                        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
   186
                        target[p] = l
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   187
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   188
        def __realpath(self, path, target):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   189
		"""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
   190
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   191
		result = os.path.dirname(path)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   192
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   193
		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
   194
			if frag == '..':
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   195
				result = os.path.dirname(result)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   196
			elif frag == '.':
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   197
				pass
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   198
			else:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   199
				result = os.path.join(result, frag)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   200
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   201
		return result
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   202
623
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   203
	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
   204
		result = None
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   205
		list = []
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   206
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   207
		ed = elf.get_dynamic(path)
623
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   208
		ei = elf.get_info(path)
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   209
		bits = ei.get("bits")
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   210
		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
   211
			if dir == None or dir == '':
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   212
				continue
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   213
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   214
			match = False
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   215
			for expr in self.runpath_re:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   216
				if expr.match(dir):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   217
					match = True
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   218
					break
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   219
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   220
			if match == False:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   221
				list.append(dir)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   222
623
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   223
			if bits == 32:
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   224
				for expr in self.runpath_64_re:
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   225
					if expr.search(dir):
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   226
						engine.warning(
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   227
							_("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
   228
							msgid="%s%s.3" % (self.name, "001"))
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   229
			else:
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   230
				match = False
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   231
				for expr in self.runpath_64_re:
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   232
					if expr.search(dir):
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   233
						match = True
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   234
						break
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   235
				if match == False:
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   236
					engine.warning(
15f87c23a86e 7109831 userland pkglint should audit runpaths
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 495
diff changeset
   237
						_("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
   238
						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
   239
		if len(list) > 0:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   240
			result = _("bad RUNPATH, '%%s' includes '%s'" %
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   241
				   ":".join(list))
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
		return result
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
	def __elf_wrong_location_check(self, path):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   246
		result = None
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   247
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   248
		ei = elf.get_info(path)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   249
		bits = ei.get("bits")
495
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   250
		type = ei.get("type");
168
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   251
                elems = os.path.dirname(path).split("/")
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   252
168
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   253
                if ("amd64" in elems) or ("sparcv9" in elems) or ("64" in elems):
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   254
                    path64 = True
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   255
                else:
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   256
                    path64 = False
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   257
495
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   258
                if ("i86" in elems) or ("sparcv7" in elems) or ("32" in elems):
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   259
                    path32 = True
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   260
                else:
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   261
                    path32 = False
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   262
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   263
		# 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
   264
		# locations, that's ok now.
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   265
		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
   266
			return result
4153db6738f5 7083378 clean up some unneeded pkg.linted attributes
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 464
diff changeset
   267
168
5884bc1edfdf 7026850 move ImageMagick to userland
Lukas Rovensky <Lukas.Rovensky@oracle.com>
parents: 145
diff changeset
   268
		if bits == 32 and path64:
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   269
			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
   270
		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
   271
			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
   272
		return result
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   273
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   274
	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
   275
		"""Checks for existence in the proto area."""
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   276
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   277
		if action.name not in ["file"]:
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   278
			return
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   279
117
8f634eb6f66b 7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 99
diff changeset
   280
		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
   281
		if path == None or path == 'NOHASH':
8f634eb6f66b 7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 99
diff changeset
   282
			path = action.attrs["path"]
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   283
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   284
		# 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
   285
		if "mode" in action.attrs:
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   286
			mode = action.attrs["mode"]
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   287
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   288
			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
   289
				engine.error(
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   290
				_("%(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
   291
				  " attribute") %  {"path": path, "mode": mode},
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   292
				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
   293
		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
   294
			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
   295
				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
   296
				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
   297
					engine.error(
1e2390f5555e 7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 117
diff changeset
   298
					_("%(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
   299
				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
   300
			else:
1e2390f5555e 7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 117
diff changeset
   301
				engine.error(
1e2390f5555e 7020836 revert workaround in 7014413 now that pkglint doesn't complain
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 117
diff changeset
   302
				_("%(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
   303
				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
   304
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   305
		# 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
   306
		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
   307
			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
   308
				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
   309
8f634eb6f66b 7023683 userland pkglint checks should look in more places for content
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 99
diff changeset
   310
				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
   311
					break
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   312
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   313
			if not os.path.exists(fullpath):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   314
				engine.info(
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   315
					_("%s missing from proto area, skipping"
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   316
					  " content checks") % path, 
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   317
					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
   318
			elif elf.is_elf_object(fullpath):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   319
				# 32/64 bit in wrong place
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   320
				result = self.__elf_wrong_location_check(fullpath)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   321
				if result != None:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   322
					engine.error(result % path, 
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   323
						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
   324
				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
   325
				if result != None:
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   326
					engine.error(result % path, 
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   327
						msgid="%s%s.3" % (self.name, pkglint_id))
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   328
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   329
	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
   330
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   331
	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
   332
		"""Checks for link resolution."""
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   333
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   334
		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
   335
			return
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   336
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   337
		path = action.attrs["path"]
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   338
		target = action.attrs["target"]
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   339
		realtarget = self.__realpath(path, target)
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   340
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
   341
		# 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
   342
		# 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
   343
		# component.
3adedf0f9f4d 7034764 dangling link check fails when links and targets are in different packages
Danek Duvall <danek.duvall@oracle.com>
parents: 181
diff changeset
   344
		if not self.ref_paths.get(realtarget, None):
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   345
			engine.error(
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   346
				_("%s %s has unresolvable target '%s'") %
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   347
					(action.name, path, target),
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   348
				msgid="%s%s.0" % (self.name, pkglint_id))
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   349
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   350
	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
   351
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   352
	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
   353
		"""Checks for SVR4 startup scripts."""
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   354
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   355
		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
   356
			return
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   357
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   358
		path = action.attrs["path"]
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   359
		if self.initscript_re.match(path):
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   360
			engine.warning(
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   361
				_("SVR4 startup '%s', deliver SMF"
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   362
				  " service instead") % path,
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   363
				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
   364
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   365
	init_script.pkglint_desc = _(
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   366
		"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
   367
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   368
class UserlandManifestChecker(base.ManifestChecker):
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   369
        """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
   370
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   371
        name = "userland.manifest"
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   372
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   373
	def __init__(self, config):
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   374
		super(UserlandManifestChecker, self).__init__(config)
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   375
181
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   376
	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
   377
		manifest_paths = []
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   378
		files = False
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   379
		license = False
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   380
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   381
		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
   382
			files = True
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   383
			break
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   384
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   385
		if files == False:
45
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   386
			return
536ea324b223 initial content validation check extension for pkglint
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
   387
84
b80cfd4e0a16 7000952 Userland package validation needs some love
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 45
diff changeset
   388
		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
   389
			license = True
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   390
			break
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   391
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   392
		if license == False:
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   393
			engine.error( _("missing license action"),
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   394
				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
   395
464
08f94c414553 7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 186
diff changeset
   396
		if 'org.opensolaris.arc-caseid' not in manifest:
08f94c414553 7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 186
diff changeset
   397
			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
   398
				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
   399
181
87e11e685b1f 7003927 userland should postprocess packaged files
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 168
diff changeset
   400
	component_check.pkglint_dest = _(
464
08f94c414553 7073736 need to turn _ into -
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 186
diff changeset
   401
		"license actions and ARC information are required if you deliver files.")