From f9d04b4e17f001b568c2a8c476cb7fbd7f578eab Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 3 Sep 2024 15:05:11 +0200 Subject: [PATCH 1/3] small cleanup --- installer/parse_install_yaml.py | 54 ++++++++++++++++----------------- setup/tue-functions.bash | 12 ++++---- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/installer/parse_install_yaml.py b/installer/parse_install_yaml.py index 54490991b..dc8b74b49 100755 --- a/installer/parse_install_yaml.py +++ b/installer/parse_install_yaml.py @@ -17,7 +17,7 @@ def show_error(error: str) -> int: def type_git(install_item: Mapping, allowed_keys: Optional[List[str]] = None) -> str: """ - Function to check the parsed yaml for install type git and generate the command string. + Function to check the parsed YAML for install type git and generate the command string. The structure of a git install type is: - type: git @@ -25,7 +25,7 @@ def type_git(install_item: Mapping, allowed_keys: Optional[List[str]] = None) -> path: [LOCAL_CLONE_PATH] version: [BRANCH_COMMIT_TAG] - :param install_item: Extracted yaml component corresponding to install type git + :param install_item: Extracted YAML component corresponding to install type git :param allowed_keys: Additional keys to allow apart from the keys defined in install type git :return: Command string containing repository url and optional arguments target-dir and version """ @@ -94,7 +94,7 @@ def type_apt_key_source(install_item: Mapping) -> str: def catkin_git(source: Mapping) -> str: """ - Function to generate installation command for catkin git targets from the extracted yaml + Function to generate installation command for catkin git targets from the extracted YAML The structure of a catkin git install type is: - type: catkin/ros @@ -105,7 +105,7 @@ def catkin_git(source: Mapping) -> str: version: [BRANCH_COMMIT_TAG] sub-dir: [PACKAGE_SUB_DIRECTORY] - :param source: Extracted yaml component for the key 'source' corresponding to install type catkin/ros + :param source: Extracted YAML component for the key 'source' corresponding to install type catkin/ros :return: Command string containing arguments to the primary catkin target installation command """ @@ -119,28 +119,6 @@ def catkin_git(source: Mapping) -> str: return command -def main() -> int: - if not 2 <= len(sys.argv) <= 3: - return show_error("Usage: parse_install_yaml install.yaml [--now]") - - now = False - if len(sys.argv) == 3: - if sys.argv[2] == "--now": - now = True - else: - return show_error(f"Unknown option: {sys.argv[2]}") - - try: - result = install_yaml_parser(sys.argv[1], now) - except Exception as e: - return show_error(str(e)) - - if result["commands"]: - print(result["commands"]) - - return 0 - - def install_yaml_parser(path: str, now: bool = False) -> Mapping[str, str]: with open(path) as f: try: @@ -202,7 +180,7 @@ def get_distro_item( # TODO(anyone): Remove the use of TUE_XXX, when migration to TUE_ENV_XXX is complete try: ros_release = environ["TUE_ENV_ROS_DISTRO"] - except KeyError as e: + except KeyError: try: ros_release = environ["TUE_ROS_DISTRO"] except KeyError: @@ -311,5 +289,27 @@ def get_distro_item( return {"system_packages": system_packages, "commands": " ".join(commands)} +def main() -> int: + if not 2 <= len(sys.argv) <= 3: + return show_error("Usage: parse_install_yaml install.yaml [--now]") + + now: bool = False + if len(sys.argv) == 3: + if sys.argv[2] == "--now": + now = True + else: + return show_error(f"Unknown option: {sys.argv[2]}") + + try: + result = install_yaml_parser(sys.argv[1], now) + except Exception as e: + return show_error(str(e)) + + if result["commands"]: + print(result["commands"]) + + return 0 + + if __name__ == "__main__": sys.exit(main()) diff --git a/setup/tue-functions.bash b/setup/tue-functions.bash index b93286956..18aa98c57 100644 --- a/setup/tue-functions.bash +++ b/setup/tue-functions.bash @@ -873,18 +873,18 @@ function _remove_recursively return 1 fi - local target tue_dependencies_dir tue_dependencies_on_dir error_code - target=$1 - tue_dependencies_dir="$TUE_ENV_DIR"/.env/dependencies - tue_dependencies_on_dir="$TUE_ENV_DIR"/.env/dependencies-on + local error_code target tue_dependencies_dir tue_dependencies_on_dir error_code=0 + target=$1 + tue_dependencies_dir="${TUE_ENV_DIR}"/.env/dependencies + tue_dependencies_on_dir="${TUE_ENV_DIR}"/.env/dependencies-on # If packages depend on the target to be removed, just remove the installed status. if [ -f "$tue_dependencies_on_dir"/"$target" ] then if [[ -n $(cat "$tue_dependencies_on_dir"/"$target") ]] then - # depend-on is not empty, so removing the installed status + # depend-on is not empty, so only removing the installed status echo "[tue-get] Other targets still depend on $target, so ignoring it" return 0 else @@ -909,7 +909,7 @@ function _remove_recursively while read -r line do [[ $line != "$target" ]] && echo "$line" - done <"$dep_dep_on_file" >"$tmp_file" + done < "${dep_dep_on_file}" > "${tmp_file}" mv "$tmp_file" "$dep_dep_on_file" echo "[tue-get] Removed '$target' from depend-on file of '$dep'" else From 8423c883a1afa5442f6b38d23f230944ebb4ed64 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Wed, 23 Oct 2024 07:41:13 +0200 Subject: [PATCH 2/3] rename main; unset function after using it --- setup.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.bash b/setup.bash index 245e92461..89b634f42 100644 --- a/setup.bash +++ b/setup.bash @@ -11,7 +11,7 @@ function _tue-check-env-vars } export -f _tue-check-env-vars -function main +function _tue-env-main { # ----------------------------------------- # Set the TUE_DIR variable @@ -108,4 +108,6 @@ function main fi } -main "$@" +_tue-env-main "$@" + +unset -f _tue-env-main From 341b4cf50d1676b0ac0e3844bef52ca1408cd8f2 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Wed, 23 Oct 2024 07:45:29 +0200 Subject: [PATCH 3/3] Bump VERSION to 1.27.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5db08bf2d..08002f86c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.27.0 +1.27.1