Package rosdep :: Module debian
[frames] | no frames]

Source Code for Module rosdep.debian

  1  #!/usr/bin/env python 
  2  # Copyright (c) 2009, Willow Garage, Inc. 
  3  # All rights reserved. 
  4  #  
  5  # Redistribution and use in source and binary forms, with or without 
  6  # modification, are permitted provided that the following conditions are met: 
  7  #  
  8  #     * Redistributions of source code must retain the above copyright 
  9  #       notice, this list of conditions and the following disclaimer. 
 10  #     * Redistributions in binary form must reproduce the above copyright 
 11  #       notice, this list of conditions and the following disclaimer in the 
 12  #       documentation and/or other materials provided with the distribution. 
 13  #     * Neither the name of the Willow Garage, Inc. nor the names of its 
 14  #       contributors may be used to endorse or promote products derived from 
 15  #       this software without specific prior written permission. 
 16  #  
 17  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 18  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 19  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 20  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 21  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 22  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 23  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 24  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 25  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 26  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 27  # POSSIBILITY OF SUCH DAMAGE. 
 28   
 29  # Author Tully Foote/tfoote@willowgarage.com 
 30   
 31  import subprocess 
 32  import os.path  
 33  import roslib.os_detect 
 34   
 35  import rosdep.base_rosdep 
 36   
 37  ###### DEBIAN SPECIALIZATION ######################### 
 38   
 39  ###### Rosdep Test OS ######################### 
40 -class RosdepTestOS(rosdep.base_rosdep.RosdepBaseOS):
41 - def __init__(self):
42 self.name = "uninitialized"
43 - def check_presence(self):
44 if "ROSDEP_TEST_OS" in os.environ: 45 return True 46 return False
47
48 - def get_name(self):
49 return os.environ.get("ROSDEP_TEST_OS", "rosdep_test_os")
50
51 - def get_version(self):
52 return os.environ.get("ROSDEP_TEST_VERSION", "rosdep_test_version")
53
54 - def strip_detected_packages(self, packages):
55 return packages
56
57 - def generate_package_install_command(self, packages, default_yes):
58 if default_yes: 59 return "#yes" 60 else: 61 return "#no"
62 63
64 -class AptGetInstall():
65
66 - def dpkg_detect(self, pkgs):
67 ret_list = [] 68 cmd = ['dpkg-query', '-W', '-f=\'${Package} ${Status}\n\''] 69 cmd.extend(pkgs) 70 pop = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 71 (std_out, std_err) = pop.communicate() 72 std_out = std_out.replace('\'','') 73 pkg_list = std_out.split('\n') 74 for pkg in pkg_list: 75 pkg_row = pkg.split() 76 if len(pkg_row) == 4 and (pkg_row[3] =='installed'): 77 ret_list.append( pkg_row[0]) 78 return ret_list
79
80 - def strip_detected_packages(self, packages):
81 return list(set(packages) - set(self.dpkg_detect(packages)))
82
83 - def generate_package_install_command(self, packages, default_yes):
84 if not packages: 85 return "#No Packages to install" 86 if default_yes: 87 return "#Packages\nsudo apt-get install -y " + ' '.join(packages) 88 else: 89 return "#Packages\nsudo apt-get install " + ' '.join(packages)
90 91 ###### Debian SPECIALIZATION #########################
92 -class Debian(roslib.os_detect.Debian, AptGetInstall, rosdep.base_rosdep.RosdepBaseOS):
93 """ This is an implementation of a standard interface for 94 interacting with rosdep. This defines all Ubuntu sepecific 95 methods, including detecting the OS/Version number. As well as 96 how to check for and install packages.""" 97 pass
98 ###### END Debian SPECIALIZATION ######################## 99 100 ###### UBUNTU SPECIALIZATION #########################
101 -class Ubuntu(roslib.os_detect.Ubuntu, AptGetInstall, rosdep.base_rosdep.RosdepBaseOS):
102 """ This is an implementation of a standard interface for 103 interacting with rosdep. This defines all Ubuntu sepecific 104 methods, including detecting the OS/Version number. As well as 105 how to check for and install packages.""" 106 pass
107 108 ###### END UBUNTU SPECIALIZATION ######################## 109 110 ###### Mint SPECIALIZATION #########################
111 -class Mint(AptGetInstall, rosdep.base_rosdep.RosdepBaseOS):
112 """ This is an implementation of a standard interface for 113 interacting with rosdep. Mint is closely coupled to Ubuntu, it 114 will masquerade as ubuntu for the purposes of rosdep. """ 115
116 - def __init__(self):
117 self.mint_detector = roslib.os_detect.Mint() 118 self.version_map = {'9':'10.04', 119 '8':'9.10', 120 '7':'9.04', 121 '6':'8.10', 122 '5':'8.04'}
123 - def get_version(self):
124 return self.version_map[self.mint_detector.get_version()]
125
126 - def get_name(self):
127 return 'ubuntu'
128
129 - def check_presence(self):
130 return self.mint_detector.check_presence()
131 132 133 pass
134 135 ###### END Mint SPECIALIZATION ######################## 136