00001
00002
00003
00004 import roslib; roslib.load_manifest("job_generation")
00005 import rosdistro
00006 from jobs_common import *
00007 import sys
00008 import os
00009 import optparse
00010 import subprocess
00011 import urllib
00012
00013 def main():
00014
00015 (options, args) = get_options(['rosdistro'], [])
00016 if not options:
00017 return -1
00018
00019
00020 env = get_environment()
00021 env['PATH'] = '/opt/ros/%s/ros/bin:%s'%(options.rosdistro, os.environ['PATH'])
00022 env['ROS_PACKAGE_PATH'] = '%s:/opt/ros/%s/stacks'%(env['WORKSPACE'], options.rosdistro)
00023 env['ROS_ROOT'] = '/opt/ros/%s/ros'%options.rosdistro
00024 env['PYTHONPATH'] = env['ROS_ROOT']+'/core/roslib/src'
00025
00026
00027
00028 rosdistro_obj = rosdistro.Distro(get_rosdistro_file(options.rosdistro))
00029 print 'Operating on ROS distro %s'%rosdistro_obj.release_name
00030
00031
00032 call('sudo apt-get update', env)
00033 print 'Installing all stacks of ros distro %s: %s'%(options.rosdistro, str(rosdistro_obj.stacks.keys()))
00034 for stack in rosdistro_obj.stacks:
00035 call('sudo apt-get install %s --yes'%(stack_to_deb(stack, options.rosdistro)), env, ignore_fail=True)
00036
00037
00038 res = call('rospack list', env, 'Getting list of all packages')
00039 packages = [p.split(' ')[0] for p in res.split('\n') if p != '']
00040 for pkg in packages:
00041 if not pkg in rosdistro_obj.stacks:
00042 res = call('rospack find %s'%pkg, env, 'Check if package is blacklisted')
00043 if not os.path.isfile(res[0:len(res)-1]+'/ROS_BUILD_BLACKLIST'):
00044 call('rosdep install -y %s'%pkg, env, 'Installing system dependencies of package %s'%pkg)
00045
00046
00047
00048 print 'Running Hudson Helper'
00049 helper = subprocess.Popen(('./hudson_helper --dir-test %s build'%env['WORKSPACE']).split(' '), env=env)
00050 helper.communicate()
00051 return helper.returncode
00052
00053
00054 if __name__ == '__main__':
00055 try:
00056 res = main()
00057 sys.exit( res )
00058 except Exception:
00059 sys.exit(-1)
00060
00061
00062
00063