コード例 #1
0
def gather_rosdeps(
    docker_client: DockerClient,
    platform: Platform,
    workspace: Path,
    skip_rosdep_keys: List[str] = [],
    custom_script: Optional[Path] = None,
    custom_data_dir: Optional[Path] = None,
) -> None:
    """
    Run the rosdep Docker image, which outputs a script for dependency installation.

    :param docker_client: Will be used to run the container
    :param platform: The name of the image produced by `build_rosdep_image`
    :param workspace: Absolute path to the colcon source workspace.
    :param custom_script: Optional absolute path of a script that does custom setup for rosdep
    :param custom_data_dir: Optional absolute path of a directory containing custom data for setup
    :return None
    """
    out_path = rosdep_install_script(platform)

    logger.info('Building rosdep collector image: %s', _IMG_NAME)
    docker_client.build_image(
        dockerfile_name='rosdep.Dockerfile',
        tag=_IMG_NAME,
    )

    logger.info(
        'Running rosdep collector image on workspace {}'.format(workspace))
    volumes = {
        workspace: '/ws',
    }
    if custom_script:
        volumes[custom_script] = CUSTOM_SETUP
    if custom_data_dir:
        volumes[custom_data_dir] = CUSTOM_DATA

    docker_client.run_container(
        image_name=_IMG_NAME,
        environment={
            'CUSTOM_SETUP': CUSTOM_SETUP,
            'OUT_PATH': str(out_path),
            'OWNER_USER': str(os.getuid()),
            'ROSDISTRO': platform.ros_distro,
            'SKIP_ROSDEP_KEYS': ' '.join(skip_rosdep_keys),
            'COLCON_DEFAULTS_FILE': 'defaults.yaml',
            'TARGET_OS': '{}:{}'.format(platform.os_name, platform.os_distro),
        },
        volumes=volumes,
    )
コード例 #2
0
    def create_workspace_sysroot_image(self, docker_client: DockerClient) -> str:
        """Build the target sysroot docker image and return its full name."""
        image_tag = self._platform.sysroot_image_tag

        logger.info('Building sysroot image: %s', image_tag)
        docker_client.build_image(
            dockerfile_dir=self._target_sysroot,
            dockerfile_name=ROS_DOCKERFILE_NAME,
            tag=image_tag,
            buildargs={
                'BASE_IMAGE': self._platform.target_base_image,
                'ROS_WORKSPACE': self._ros_workspace_relative_to_sysroot,
                'ROS_VERSION': self._platform.ros_version,
                'ROS_DISTRO': self._platform.ros_distro,
                'TARGET_ARCH': self._platform.arch,
            }
        )
        logger.info('Successfully created sysroot docker image: %s', image_tag)
コード例 #3
0
def create_workspace_sysroot_image(
    docker_client: DockerClient,
    platform: Platform,
) -> None:
    """
    Create the target platform sysroot image.

    :param docker_client Docker client to use for building
    :param platform Information about the target platform
    :param build_context Directory containing all assets needed by sysroot.Dockerfile
    """
    image_tag = platform.sysroot_image_tag

    logger.info('Building sysroot image: %s', image_tag)
    docker_client.build_image(dockerfile_name='sysroot.Dockerfile',
                              tag=image_tag,
                              buildargs={
                                  'BASE_IMAGE': platform.target_base_image,
                                  'ROS_VERSION': platform.ros_version,
                              })
    logger.info('Successfully created sysroot docker image: %s', image_tag)