userland.py revision 4304
45N/A# The contents of this file are subject to the terms of the 45N/A# Common Development and Distribution License (the "License"). 45N/A# You may not use this file except in compliance with the License. 45N/A# See the License for the specific language governing permissions 45N/A# and limitations under the License. 45N/A# When distributing Covered Code, include this CDDL HEADER in each 45N/A# If applicable, add the following below this CDDL HEADER, with the 45N/A# fields enclosed by brackets "[]" replaced with your own identifying 45N/A# information: Portions Copyright [yyyy] [name of copyright owner] 4304N/A# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 45N/A# Some userland consolidation specific lint checks 45N/A """An opensolaris.org-specific class to check actions.""" 45N/A "checks Userland packages for common content errors")
1531N/A # These lists are used to check if a 32/64-bit binary 1531N/A # is in a proper 32/64-bit directory. 1531N/A "i86pc-solaris-64int",
# perl path 2541N/A "sun4-solaris-64int",
# perl path 1531N/A "i86pc-solaris-64",
# perl path 2541N/A "sun4-solaris-64",
# perl path 186N/A """Initialize the checker with a dictionary of paths, so that we 186N/A can do link resolution. 186N/A This is copied from the core pkglint code, but should eventually 186N/A """Updates a dictionary of { attr: [(fmri, action), ..]} 186N/A where attr is the value of that attribute from 186N/A actions of a given type atype, in the given 4304N/A # Action attributes must be lists or strings. 186N/A # construct a set of FMRIs being presented for linting, and 186N/A # avoid seeding the reference dictionary with any for which 186N/A # we're delivering new packages. 186N/A _(
"Seeding reference action path dictionaries."))
186N/A # Only put this manifest into the reference dictionary 186N/A # if it's not an older version of the same package. 186N/A _(
"Seeding lint action path dictionaries."))
186N/A # we provide a search pattern, to allow users to lint a 186N/A # subset of the packages in the lint_repository 186N/A _(
"Seeding local action path dictionaries."))
186N/A """Merges the given src dictionary into the target 186N/A dictionary, giving us the target content as it would appear, 186N/A were the packages in src to get published to the 186N/A repositories that made up target. 186N/A We need to only merge packages at the same or successive 186N/A version from the src dictionary into the target dictionary. 186N/A If the src dictionary contains a package with no version 186N/A information, it is assumed to be more recent than the same 186N/A package with no version in the target.""" 186N/A """Builds a dictionary of fmri:action entries""" 186N/A # we want to remove entries deemed older than 186N/A # src_pfmri from targ_dic. 84N/A """Combine path and target to get the real path.""" 2337N/A # get the ASLR tag string for this binary 2337N/A # aslr_tag_string will get stdout; err will get stderr 2337N/A # No ASLR tag was found; everything must be tagged 2337N/A # look for "ENABLE" anywhere in the string; 2337N/A # warn about binaries which are not ASLR enabled 2498N/A # Make sure RUNPATH matches against a packaged path. 2498N/A # Don't check runpaths starting with $ORIGIN, which 2498N/A # is specially handled by the linker. 2498N/A # Strip out leading and trailing '/' in the 2498N/A # runpath, since the reference paths don't start 2498N/A # with '/' and trailing '/' could cause mismatches. 2498N/A # Check first if there is an exact match, then check 2498N/A # if any reference path starts with this runpath 2498N/A # plus a trailing slash, since it may still be a link 2498N/A # to a directory that has no action because it uses 2498N/A # If still no match, if the runpath contains 2498N/A # an embedded symlink, emit a warning; it may or may 2498N/A # not resolve to a legitimate path. 2498N/A # Otherwise, runpath is bad; add it to list. 2498N/A _(
"runpath '%s' in '%s' not found in reference paths but contains symlink at '%s'") % (
dir,
path,
pdir),
634N/A _(
"64-bit runpath in 32-bit binary, '%s' includes '%s'") % (
path,
dir),
634N/A _(
"32-bit runpath in 64-bit binary, '%s' includes '%s'") % (
path,
dir),
495N/A # ignore 64-bit executables in normal (non-32-bit-specific) 495N/A # locations, that's ok now. 45N/A """Checks for existence in the proto area.""" 84N/A # check for writable files without a preserve attribute 84N/A _(
"%(path)s is writable (%(mode)s), but missing a preserve" 145N/A _(
"%(path)s has a preserve action, but is not writable (%(mode)s)") % {
"path":
path,
"mode":
mode},
145N/A _(
"%(path)s has a preserve action, but no mode") % {
"path":
path,
"mode":
mode},
84N/A # checks that require a physical file to look at 84N/A _(
"%s missing from proto area, skipping" 84N/A # 32/64 bit in wrong place 84N/A """Checks for link resolution.""" 186N/A # Check against the target image (ref_paths), since links might 186N/A # resolve outside the packages delivering a particular 1923N/A # links to files should directly match a patch in the reference 1923N/A # If it didn't match a path in the reference repo, it may still 1923N/A # be a link to a directory that has no action because it uses 1923N/A # the default attributes. Look for a path that starts with 1923N/A # this value plus a trailing slash to be sure this it will be 1923N/A # resolvable on a fully installed system. 84N/A """Checks for SVR4 startup scripts.""" 84N/A _(
"SVR4 startup '%s', deliver SMF" 84N/A "SVR4 startup scripts should not be delivered.")
45N/A """An opensolaris.org-specific class to check manifests.""" 464N/A "license actions and ARC information are required if you deliver files.")
2756N/A # CFFI names the modules it creates with a hash that includes the 2756N/A # version of CFFI (since the schema may change from one version to 2756N/A # another). This means that if a package depends on CFFI, then it must 2756N/A # also incorporate the version it builds with, which should be the 2756N/A "cannot determine the version of CFFI needed") %
2756N/A "does not incorporate it (should be at %(should)s)")
2756N/A # The final check can only be done if neither of the previous 2756N/A "incorporates it at the wrong version (%(actual)s " 2756N/A "Packages using CFFI incorporate CFFI at the correct version.")