$search
00001 # Software License Agreement (BSD License) 00002 # 00003 # Copyright (c) 2009, Willow Garage, Inc. 00004 # All rights reserved. 00005 # 00006 # Redistribution and use in source and binary forms, with or without 00007 # modification, are permitted provided that the following conditions 00008 # are met: 00009 # 00010 # * Redistributions of source code must retain the above copyright 00011 # notice, this list of conditions and the following disclaimer. 00012 # * Redistributions in binary form must reproduce the above 00013 # copyright notice, this list of conditions and the following 00014 # disclaimer in the documentation and/or other materials provided 00015 # with the distribution. 00016 # * Neither the name of Willow Garage, Inc. nor the names of its 00017 # contributors may be used to endorse or promote products derived 00018 # from this software without specific prior written permission. 00019 # 00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00024 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00028 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00029 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00030 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 # POSSIBILITY OF SUCH DAMAGE. 00032 # 00033 # Revision $Id: stack_header.py 16306 2012-02-15 19:03:55Z kwc $ 00034 # $Author: kwc $ 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 # rosinstalls is a richer dictionary of rosinstall configurations 00086 # based on 'devel' and 'release' configurations for the repo. It 00087 # is only set for repos that are released stacks. 00088 if repo.rosinstalls: 00089 d['rosinstalls'] = repo.rosinstalls.copy() 00090 00091 if repo.is_released_stack: 00092 # no VCS information available on disk as we are using a 00093 # binary install. 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 # svn allows partial checkouts, DVCSs generally don't 00099 d['vcs_uri'] = get_svn_url(rosstack.get_path(s)) 00100 # update svn rules 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 # update git rules 00106 d['rosinstall']['git']['uri'] = repo_uri 00107 else: 00108 d['vcs_uri'] = repo.uri 00109 00110 # encode unicode entries 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 #print("generating stack wiki files for", s) 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