/usr/lib/python2.7/dist-packages/roswtf/packages.py is in python-roswtf 1.11.16-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | # Software License Agreement (BSD License)
#
# Copyright (c) 2009, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Willow Garage, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id$
import os
import time
from roswtf.environment import paths, is_executable
from roswtf.rules import warning_rule, error_rule
import roslib.msgs
import roslib.srvs
from roslib.packages import get_pkg_dir, InvalidROSPkgException, PACKAGE_FILE
## look for unknown tags in manifest
def manifest_valid(ctx):
errors = []
if ctx.manifest is not None:
errors = ["<%s>"%t.tagName for t in ctx.manifest.unknown_tags]
return errors
def _manifest_msg_srv_export(ctx, type_):
exist = []
for pkg in ctx.pkgs:
pkg_dir = roslib.packages.get_pkg_dir(pkg)
d = os.path.join(pkg_dir, type_)
if os.path.isdir(d):
files = os.listdir(d)
if filter(lambda x: x.endswith('.'+type_), files):
try:
m_file = roslib.manifest.manifest_file(pkg, True)
except InvalidROSPkgException:
# ignore wet package from further investigation
env = os.environ
pkg_path = get_pkg_dir(pkg, True, ros_root=env['ROS_ROOT'])
if os.path.exists(os.path.join(pkg_path, PACKAGE_FILE)):
continue
raise
m = roslib.manifest.parse_file(m_file)
cflags = m.get_export('cpp', 'cflags')
include = '-I${prefix}/%s/cpp'%type_
if filter(lambda x: include in x, cflags):
exist.append(pkg)
return exist
def manifest_msg_srv_export(ctx):
msgs = set(_manifest_msg_srv_export(ctx, 'msg'))
srvs = set(_manifest_msg_srv_export(ctx, 'srv'))
errors = []
for pkg in msgs & srvs:
errors.append('%s: -I${prefix}/msg/cpp -I${prefix}/srv/cpp'%pkg)
for pkg in msgs - srvs:
errors.append('%s: -I${prefix}/msg/cpp'%pkg)
for pkg in srvs - msgs:
errors.append('%s: -I${prefix}/srv/cpp'%pkg)
return errors
def _check_for_rpath_flags(pkg, lflags):
if not lflags:
return
L_arg = '-L'
Wl_arg = '-Wl'
rpath_arg = '-rpath'
lflags_args = lflags.split()
# Collect the args we care about
L_args = []
rpath_args = []
i = 0
while i < len(lflags_args):
f = lflags_args[i]
if f.startswith(L_arg) and len(f) > len(L_arg):
# normpath avoids problems with trailing slash vs. no trailing
# slash, #2284
L_args.append(os.path.normpath(f[len(L_arg):]))
elif f == L_arg and (i+1) < len(lflags_args):
i += 1
# normpath avoids problems with trailing slash vs. no trailing
# slash, #2284
L_args.append(os.path.normpath(lflags_args[i]))
elif f.startswith(Wl_arg) and len(f) > len(Wl_arg):
# -Wl can be followed by multiple, comma-separated arguments,
# #2284.
args = f.split(',')
j = 1
while j < (len(args) - 1):
if args[j] == rpath_arg:
# normpath avoids problems with trailing slash vs. no trailing
# slash, #2284
rpath_args.append(os.path.normpath(args[j+1]))
j += 2
else:
j += 1
i += 1
# Check for parallelism; not efficient, but these strings are short
for f in L_args:
if f not in rpath_args:
return '%s: found flag "-L%s", but no matching "-Wl,-rpath,%s"'%(pkg, f,f)
for f in rpath_args:
if f not in L_args:
return '%s: found flag "-Wl,-rpath,%s", but no matching "-L%s"'%(pkg, f,f)
def manifest_rpath_flags(ctx):
warn = []
for pkg in ctx.pkgs:
# Use rospack to get lflags, so that they can be bash-expanded
# first, #2286.
import subprocess
lflags = subprocess.Popen(['rospack', 'export', '--lang=cpp', '--attrib=lflags', pkg], stdout=subprocess.PIPE).communicate()[0]
err_msg = _check_for_rpath_flags(pkg, lflags)
if err_msg:
warn.append(err_msg)
return warn
def cmakelists_package_valid(ctx):
missing = []
for pkg in ctx.pkgs:
found = False
pkg_dir = roslib.packages.get_pkg_dir(pkg)
p = os.path.join(pkg_dir, 'CMakeLists.txt')
if not os.path.isfile(p):
continue #covered by cmakelists_exists
f = open(p)
try:
for l in f:
# ignore all whitespace
l = l.strip().replace(' ', '')
if l.startswith('rospack('):
found = True
if not l.startswith('rospack(%s)'%pkg):
missing.append(pkg)
break
# there may be more than 1 rospack() declaration, so scan through entire
# CMakeLists
elif l.startswith("rosbuild_init()"):
found = True
finally:
f.close()
# rospack exists outside our build system
if 'rospack' in missing:
missing.remove('rospack')
return missing
warnings = [
# disabling as it is too common and regular
(cmakelists_package_valid,
"The following packages have incorrect rospack() declarations in CMakeLists.txt.\nPlease switch to using rosbuild_init():"),
(manifest_msg_srv_export,
'The following packages have msg/srv-related cflags exports that are no longer necessary\n\t<export>\n\t\t<cpp cflags="..."\n\t</export>:'),
(manifest_valid, "%(pkg)s/manifest.xml has unrecognized tags:"),
]
errors = [
(manifest_rpath_flags, "The following packages have rpath issues in manifest.xml:"),
]
def wtf_check(ctx):
# no package in context to verify
if not ctx.pkgs:
return
for r in warnings:
warning_rule(r, r[0](ctx), ctx)
for r in errors:
error_rule(r, r[0](ctx), ctx)
|