示例#1
0
def missing_stack_rosdeps(stack_name, stack_dir, platform):
    """
    Calculate list of rosdeps that are missing definitions on platform.
    
    NOTE: one flaw in this implementation is that it uses the rosdep
    view from the *active environment* to generate the rosdeps. It
    does not generate them from specific versions of stacks. The hope
    is that rosdeps improve monotonically over time, so that this will
    not be a major issue.

    @param platform: platform name (e.g. lucid)
    @return: dictionary mapping packages to their missing rosdep mappings
    @rtype: {str: [str]}
    """
    
    # hardcode OS for now as we don't build straight debian
    os_name = 'ubuntu'
    # reverse lookup version number, which is the key for rosdep
    os_version = [k for k, v in rosdeb.get_ubuntu_map().iteritems() if v == platform][0]
    
    yc = YamlCache(os_name, os_version)
    package_manifests = package_manifests_of(stack_dir)
    packages = {}
    for p, m_file in package_manifests:
        missing = []
        packages[p] = missing
        m = roslib.manifest.parse_file(m_file)
        rosdeps = [d.name for d in m.rosdeps]
        if not rosdeps:
            continue
            
        rdlp = RosdepLookupPackage(os_name, os_version, p, yc)
        for r in rosdeps:
            value = rdlp.lookup_rosdep(r)
            if not value or '\n' in value:
                missing.append(r)
    return packages
示例#2
0
def stack_rosdeps(stack_name, stack_dir, platform):
    """
    Calculate dependencies of stack on an 'ubuntu' OS, including both
    ROS stacks and their rosdep dependencies, for the specified
    ubuntu release version.
    
    NOTE: one flaw in this implementation is that it uses the rosdep
    view from the *active environment* to generate the rosdeps. It
    does not generate them from specific versions of stacks. The hope
    is that rosdeps improve monotonically over time, so that this will
    not be a major issue.

    @param platform: platform name (e.g. lucid)
    
    @return: list of debian package deps
    @rtype: [str]
    @raise Exception: if stack rosdeps cannot be fully resolved
    """
    
    # - implicit deps of all ROS packages
    deb_deps = IMPLICIT_DEPS[:]

    # hardcode OS for now as we don't build straight debian
    os_name = 'ubuntu'
    # reverse lookup version number, which is the key for rosdep
    os_version = [k for k, v in rosdeb.get_ubuntu_map().iteritems() if v == platform][0]
    
    try:
        # REP 111 API
        import rosdep.installers
        installers = {'apt': rosdep.installers.AptInstaller, 'source': rosdep.installers.SourceInstaller}
        os_version = platform
        yc = YamlCache(os_name, os_version, installers)

    except ImportError:
        yc = YamlCache(os_name, os_version)

    package_manifests = package_manifests_of(stack_dir)
    for p, m_file in package_manifests:
        m = roslib.manifest.parse_file(m_file)
        rosdeps = [d.name for d in m.rosdeps]
        if not rosdeps:
            continue
            
        rdlp = RosdepLookupPackage(os_name, os_version, p, yc)
        for r in rosdeps:
            value = rdlp.lookup_rosdep(r)
            if value is False:
                raise Exception("cannot generate rosdeps for stack [%s] on platform [%s]:\n\trosdep lookup of [%s] failed"%(stack_name, os_version, r))                
            if type(value) == dict:
                if 'apt' in value:
                    packages = value['apt']['packages']
                    if type(packages) == list:
                        deb_deps.extend(packages)
                    else:
                        deb_deps.append(packages)
            else:
                if '\n' in value:
                    raise Exception("cannot generate rosdeps for stack [%s] on platform [%s]:\n\trosdep [%s] has a script binding"%(stack_name, os_version, r))

                deb_deps.extend([x for x in value.split(' ') if x.strip()])

    return list(set(deb_deps))