00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 """
00037 The stack header is a YAML file that is used by the ROS.org wiki as
00038 well as rosinstall. It is similar in concept to the stack manifest
00039 (stack.xml), but it contains additional data and is in YAML format for
00040 easier processing in python scripts.
00041
00042 The data in the stack header is not formally specified, but includes:
00043
00044 * manifest data (description, license, author, depends, review status, url)
00045 * rosinstall configuration information (VCS URI, branches, etc...)
00046 * packages in stack
00047 * depends-on information
00048 """
00049
00050 from __future__ import print_function
00051
00052 import os
00053 import sys
00054 import codecs
00055 import traceback
00056
00057 import rospkg
00058 import yaml
00059
00060 from .core import Repo, safe_encode
00061 from .repo_util import guess_vcs_uri, get_svn_url
00062
00063 def _generate_stack_headers(ctx, filename, s, repo, rospack, rosstack):
00064 m = ctx.stack_manifests[s]
00065 rospack = rospkg.RosPack()
00066 rosstack = rospkg.RosStack()
00067 d = {
00068 'name': s,
00069 'brief': m.brief,
00070 'description': m.description.strip() or '',
00071 'license': m.license or '',
00072 'authors': m.author or '',
00073 'depends': [d.stack for d in m.depends],
00074 'review_status': m.status or '',
00075 'review_notes': m.notes or '',
00076 'url': m.url,
00077 'packages': rosstack.packages_of(s),
00078 'depends_on': rosstack.get_depends_on(s, implicit=False),
00079 }
00080
00081 d['vcs'] = repo.type
00082 d['repository'] = repo.aggregate_name or repo.name
00083 d['repository-actual'] = repo.name
00084 d['rosinstall'] = repo.rosinstall.copy()
00085
00086
00087
00088 if repo.rosinstalls:
00089 d['rosinstalls'] = repo.rosinstalls.copy()
00090
00091 if repo.is_released_stack:
00092
00093
00094 print("[%s] stack is a released stack, using repo URI [%s]"%(s, repo.uri))
00095 print("loading vcs URI", repo.uri)
00096 d['vcs_uri'] = repo.uri
00097 elif repo.type == 'svn':
00098
00099 d['vcs_uri'] = get_svn_url(rosstack.get_path(s))
00100
00101 d['rosinstall']['svn']['uri'] = d['vcs_uri']
00102 elif repo.type == 'git':
00103 repo_type, repo_uri = guess_vcs_uri(rosstack.get_path(s))
00104 d['vcs_uri'] = repo_uri
00105
00106 d['rosinstall']['git']['uri'] = repo_uri
00107 else:
00108 d['vcs_uri'] = repo.uri
00109
00110
00111 d = safe_encode(d)
00112
00113 if not ctx.quiet:
00114 print("writing stack properties to", filename)
00115 with codecs.open(filename, mode='w', encoding='utf-8') as f:
00116 f.write(yaml.safe_dump(d, default_style="'"))
00117
00118 def generate_stack_headers(ctx, repo, stacks):
00119 """
00120 Generate stack.yaml files for MoinMoin PackageHeader macro
00121
00122 @return: list of stack.yaml files
00123 @rtype: [str]
00124 """
00125 rospack = rospkg.RosPack()
00126 rosstack = rospkg.RosStack()
00127
00128 artifacts = []
00129 for s in stacks:
00130
00131 filename = os.path.join(ctx.docdir, s, 'stack.yaml')
00132 filename_dir = os.path.dirname(filename)
00133 if not os.path.isdir(filename_dir):
00134 os.makedirs(filename_dir)
00135 artifacts.append(filename)
00136
00137 try:
00138
00139 _generate_stack_headers(ctx, filename, s, repo, rospack, rosstack)
00140 except Exception as e:
00141 traceback.print_exc()
00142 print("Unable to generate stack.yaml for %s: %s"%(s, e), file=sys.stderr)
00143
00144 return artifacts