From 0c1d836614ce5d51608b16e92655461721959c2e Mon Sep 17 00:00:00 2001 From: yaymalaga Date: Tue, 19 Sep 2023 16:43:07 +0200 Subject: [PATCH] Add option to skip .repo files in the cloned repository --- docker/Dockerfile | 3 ++- docker/recursive_vcs_import.py | 7 +++++-- scripts/build.sh | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 599b65a..14c5efd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -56,7 +56,8 @@ COPY docker/docker-ros/docker/recursive_vcs_import.py /usr/local/bin RUN apt-get update && \ apt-get install -y python-is-python3 && \ rm -rf /var/lib/apt/lists/* -RUN /usr/local/bin/recursive_vcs_import.py src src/upstream +ARG ENABLE_RECURSIVE_CLONED="True" +RUN /usr/local/bin/recursive_vcs_import.py src src/upstream ${ENABLE_RECURSIVE_CLONED} # create install script with list of rosdep dependencies RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ diff --git a/docker/recursive_vcs_import.py b/docker/recursive_vcs_import.py index 160460a..52a2a08 100755 --- a/docker/recursive_vcs_import.py +++ b/docker/recursive_vcs_import.py @@ -6,7 +6,7 @@ from typing import List, Optional -def findDotRepos(search_path: str, clone_path: Optional[str]=None) -> List[pathlib.Path]: +def findDotRepos(search_path: str, clone_path: Optional[str] = None) -> List[pathlib.Path]: repos = list(pathlib.Path(search_path).glob("**/*.repos")) if clone_path is not None: @@ -17,11 +17,14 @@ def main(): search_path = sys.argv[1] if len(sys.argv) > 1 else "." clone_path = sys.argv[2] if len(sys.argv) > 2 else "." + recursive_cloned = sys.argv[3].lower() == "true" if len(sys.argv) > 3 else True cloned_repos = [] + found_repos = [] while True: - found_repos = findDotRepos(search_path, clone_path) + if recursive_cloned or not found_repos: + found_repos = findDotRepos(search_path, clone_path) remaining_repos = set(found_repos) - set(cloned_repos) if not remaining_repos: diff --git a/scripts/build.sh b/scripts/build.sh index 23a94ad..e603c7d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -30,6 +30,7 @@ build_image() { $(if [[ -n "${ENABLE_RECURSIVE_ADDITIONAL_PIP}" ]]; then echo "--build-arg ENABLE_RECURSIVE_ADDITIONAL_PIP=${ENABLE_RECURSIVE_ADDITIONAL_PIP}"; fi) \ $(if [[ -n "${CUSTOM_SCRIPT_FILE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_FILE=${CUSTOM_SCRIPT_FILE}"; fi) \ $(if [[ -n "${ENABLE_RECURSIVE_CUSTOM_SCRIPT}" ]]; then echo "--build-arg ENABLE_RECURSIVE_CUSTOM_SCRIPT=${ENABLE_RECURSIVE_CUSTOM_SCRIPT}"; fi) \ + $(if [[ -n "${ENABLE_RECURSIVE_CLONED}" ]]; then echo "--build-arg ENABLE_RECURSIVE_CLONED=${ENABLE_RECURSIVE_CLONED}"; fi) \ . echo "Successfully built stage '${TARGET}' for platform '${PLATFORM}' as '${IMAGE}'" }