Package rosdeb :: Module core
[frames] | no frames]

Source Code for Module rosdeb.core

 1  # Software License Agreement (BSD License) 
 2  # 
 3  # Copyright (c) 2010, Willow Garage, Inc. 
 4  # All rights reserved. 
 5  # 
 6  # Redistribution and use in source and binary forms, with or without 
 7  # modification, are permitted provided that the following conditions 
 8  # are met: 
 9  # 
10  #  * Redistributions of source code must retain the above copyright 
11  #    notice, this list of conditions and the following disclaimer. 
12  #  * Redistributions in binary form must reproduce the above 
13  #    copyright notice, this list of conditions and the following 
14  #    disclaimer in the documentation and/or other materials provided 
15  #    with the distribution. 
16  #  * Neither the name of Willow Garage, Inc. nor the names of its 
17  #    contributors may be used to endorse or promote products derived 
18  #    from this software without specific prior written permission. 
19  # 
20  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
21  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
22  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
23  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
24  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
25  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
26  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
27  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
28  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
29  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
30  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
31  # POSSIBILITY OF SUCH DAMAGE. 
32  # 
33  # Revision $Id: __init__.py 10652 2010-08-11 22:01:37Z kwc $ 
34   
35  import os 
36  import sys 
37   
38  ubuntu_map = { 
39      '11.10': 'oneiric', 
40      '11.04': 'natty', 
41      '10.10': 'maverick', 
42      '10.04': 'lucid', 
43      } 
44   
45 -def get_ubuntu_map():
46 return ubuntu_map
47 -def ubuntu_release():
48 """ 49 WARNING: this can only be called on an Ubuntu system 50 """ 51 if not os.path.isfile('/etc/issue'): 52 raise Exception("this is not an ubuntu system") 53 f = open('/etc/issue') 54 for s in f: 55 if s.startswith('Ubuntu'): 56 v = s.split()[1] 57 v = '.'.join(v.split('.')[:2]) 58 try: 59 return ubuntu_map[v] 60 except KeyError: 61 raise Exception("unrecognized ubuntu version %s" % v) 62 raise Exception("could not parse ubuntu release version")
63
64 -def ubuntu_release_name(version):
65 return ubuntu_map[version]
66
67 -def debianize_name(name):
68 """ 69 Convert ROS stack name to debian conventions (dashes, not underscores) 70 """ 71 return name.replace('_', '-')
72
73 -def debianize_version(stack_version, distro_version, ubuntu_rel=None):
74 """ 75 WARNING: this can only be called on an Ubuntu system and will lock to the platform it is called on 76 """ 77 if ubuntu_rel is None: 78 ubuntu_rel = ubuntu_release() 79 return stack_version+'-'+distro_version+'~%s'%ubuntu_rel
80
81 -def platforms():
82 # calling this 'platforms' instead of ubuntu_platforms to allow easier conversion to any debian-based release 83 return ubuntu_map.values()
84