diff --git a/README.md b/README.md index e07682b0c..80461cf0a 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,13 @@ Standard tue-env installation with targets from [tue-env-targets](https://github ### Customization -A customized targets repository can be setup with this package manager (currently only one git repository is supported). If `tue-env` is already installed, to setup the targets repository run: +A customized targets repository can be setup with this package manager (currently only one git repository is supported). If `tue-env` is already installed, to set up the targets repository run: ```bash tue-env init ENVIRONMENT DIRECTORY ``` -This will do the same as running the commands seperately: +This will do the same as running the commands separately: ```bash tue-env init ENVIRONMENT [DIRECTORY] # Will not result in an environment being loaded. Unless one was already loaded before @@ -72,13 +72,13 @@ cat ~/.ssh/.pub ## Usage With `tue-get` you can install various targets which mostly are ros packages. -The list of packages can be seen [here](https://github.com/tue-robotics/tue-env-targets). +The list of default packages can be seen [here](https://github.com/tue-robotics/tue-env-targets). ```bash tue-get install ``` -For example, to install a default developement installation for working with +For example, to install a default development installation for working with TU/e robots, run the following command: ```bash @@ -88,8 +88,8 @@ tue-get install hero-dev # For Hero ``` **Note:** Any ROS package which has a source installation must be built. In the -current implementation of `tue-get` this doesn't happen automatically. However -we provide an alias to `catkin build` as `tue-make` which would build the +current implementation of `tue-get` this doesn't happen automatically. However, +we provide an alias to `catkin build`/`colcon build` as `tue-make` which would build the `tue-env` workspace. Upon executing the installation instructions mentioned in the previous section, `~/.tue/setup.bash` is automatically added in `.bashrc`. Sourcing `.bashrc` would make `tue-env` available to the bash session. @@ -98,11 +98,11 @@ Upon executing the installation instructions mentioned in the previous section, This repository provides various pre-built docker images. To use them, first install the docker target (`tue-get install docker`). -A list of ready to use docker images generated by this repository can be found [here](https://hub.docker.com/r/tuerobotics/tue-env) +A list of ready to use docker images generated by this repository can be found [here](https://github.com/orgs/tue-robotics/packages) ## Different environments -To isolate builds you can use different environments. Each environment will contain a different copy of the repositories used. These environments can also be useful to seperate ROS1 from ROS2 installs. +To isolate builds you can use different environments. Each environment will contain a different copy of the repositories used. These environments can also be useful to separate ROS1 from ROS2 installs. To initialise a new environment (for example the Pico robot): @@ -121,6 +121,16 @@ Or use `tue-env set-default` if you want this to be de default. ## Guidelines on creating a new target +The targets directory is located at `.env/targets` relative to the root of the environment directory. The target directory of each environment can be accessed by: + +```bash +tue-env targets # Will change the directory to the targets directory of the current environment +# or +tue-env targets # Will change the directory to the targets directory of the specified environment +``` + +The targets directory contains a list of targets. Each target is a directory with the name of the target. + A target can consist of the following files: 1. `install.yaml` @@ -138,14 +148,13 @@ or installable packages must be specified there. They should not be moved to `install.bash` as `tue-env` has many controls in place to parse the YAML file. Some (parts of) targets are not used for testing, but do take a long time -to install. Therefore it is prefferable to skip these (parts of) targets -during CI. +to install. Therefore, it is preferable to skip these (parts of) targets during CI. To ignore an entire target in CI, add a `.ci_ignore` file to the target. To either ignore the bash script or the yaml file add respectively `.ci_ignore_bash` or `.ci_ignore_yaml`. ### Naming conventions -Name of the target must start with `ros-` only if it is a `catkin` (ROS) package. It's `install.yaml` file must be in the format of [ROS target](#ros-package-install). +Name of the target must start with `ros-` only if it is a `catkin`/`colcon` (ROS) package. It's `install.yaml` file must be in the format of [ROS target](#ros-package-install). ### Writing `install.yaml` @@ -196,7 +205,7 @@ Taking the above into account, the following combinations for `install.yaml` are source: null ``` -Both ROS distro specific as default can be 'null'. Prevered usage is default for current and feature distributions and exceptions for old distributions. +Both ROS distro specific as default can be 'null'. Preferred usage is default for current and feature distributions and exceptions for old distributions. #### Catkin package install @@ -229,7 +238,7 @@ Depending on Ubuntu distribution: name: [null/] ``` -Both Ubuntu distribution specific as default can be 'null'. Prefered usage is default for current and feature distributions and exceptions for old distributions. +Both Ubuntu distribution specific as default can be 'null'. Preferred usage is default for current and feature distributions and exceptions for old distributions. #### (Target / System / PIP / PIP3 / PPA / Snap / Gem)-now @@ -284,7 +293,7 @@ generally used methods of installing packages: | `tue-install-system-now` | To install `deb` packages with `apt-get` right away, but ignores it if already installed | | `tue-install-get-releases` | To get a released asset from a github repository and place it in the requested directory | -The input arguments for each of the above mentioned commands can be found by +The input arguments for each of the above-mentioned commands can be found by simply executing the command in a bash session (provided tue-env is correctly installed). diff --git a/VERSION b/VERSION index 850e74240..42cf0675c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.14.0 +1.15.2 diff --git a/setup/generate_setup_file.py b/setup/generate_setup_file.py index 98172410a..8b3eeef1e 100755 --- a/setup/generate_setup_file.py +++ b/setup/generate_setup_file.py @@ -25,7 +25,7 @@ def __init__(self, tue_env_dir=None): def generate_setup_file(self) -> None: installed_targets_dir = os.path.join(self._tue_env_dir, ".env", "installed") - lines = ["# This file was auto-generated by tue-get. Do not change this file.\n"] + lines = ["#! /usr/bin/env bash\n", "# This file was auto-generated by tue-get. Do not change this file.\n"] if os.path.isdir(self._tue_dependencies_dir): for target in os.listdir(installed_targets_dir): diff --git a/setup/tue-env-config.bash b/setup/tue-env-config.bash index 6d783cfc9..bcc79bf40 100755 --- a/setup/tue-env-config.bash +++ b/setup/tue-env-config.bash @@ -145,7 +145,7 @@ function _main if [ -z "$1" ] then - edit "${tue_env_dir}/.env/setup/user_setup.bash" + edit "$(file --mime-type "${tue_env_dir}/.env/setup/user_setup.bash" | awk '{print $2}')":"${tue_env_dir}/.env/setup/user_setup.bash" else local functions functions=$(compgen -A function | grep "tue-env-") diff --git a/setup/tue-env.bash b/setup/tue-env.bash index ebfe57980..fb5ec1235 100644 --- a/setup/tue-env.bash +++ b/setup/tue-env.bash @@ -119,18 +119,25 @@ options: dir=$(cat "$TUE_DIR"/user/envs/"$env") rm "$TUE_DIR"/user/envs/"$env" - if [ $PURGE == "false" ] + if [[ -d ${dir} ]] then - dir_moved=$dir.$(date +%F_%R) - mv "$dir" "$dir_moved" - # shellcheck disable=SC1078,SC1079 - echo """[tue-env] Removed environment '$env' -Moved environment directory of '$env' to '$dir_moved'""" + if [ $PURGE == "false" ] + then + dir_moved=$dir.$(date +%F_%R) + mv "${dir}" "${dir_moved}" + # shellcheck disable=SC1078,SC1079 + echo """[tue-env] Removed environment '${env}' +Moved environment directory from '${dir}' to '${dir_moved}'""" + else + rm -rf "${dir}" + # shellcheck disable=SC1078,SC1079 + echo """[tue-env] Removed environment '$env' +Purged environment directory '${dir}'""" + fi else - rm -rf "$dir" # shellcheck disable=SC1078,SC1079 - echo """[tue-env] Removed environment '$env' -Purged environment directory of '$env'""" + echo """[tue-env] Removed environment '${env}' +Environment directory '${dir}' didn't exist (anymore)""" fi elif [[ $cmd == "switch" ]] @@ -215,7 +222,7 @@ Purged environment directory of '$env'""" then local tue_env_dir tue_env_dir=$(cat "$TUE_DIR"/user/envs/"$env") - cd "$tue_env_dir"/.env/targets || { echo -e "Targets directory '$tue_env_dir/.env/targets' (environment '$TUE_ENV') does not exist"; return 1; } + cd "${tue_env_dir}"/.env/targets || { echo -e "Targets directory '${tue_env_dir}/.env/targets' (environment '${env}') does not exist"; return 1; } fi elif [[ $cmd == "config" ]] @@ -245,7 +252,7 @@ Purged environment directory of '$env'""" then local tue_env_dir tue_env_dir=$(cat "$TUE_DIR"/user/envs/"$env") - cd "$tue_env_dir" || { echo -e "Environment directory '$tue_env_dir' (environment '$TUE_ENV') does not exist"; return 1; } + cd "${tue_env_dir}" || { echo -e "Environment directory '${tue_env_dir}' (environment '${env}') does not exist"; return 1; } else echo "[tue-env](cd) no enviroment set or provided" return 1 diff --git a/setup/tue-functions.bash b/setup/tue-functions.bash index 065a39ac7..8fef3f9ae 100644 --- a/setup/tue-functions.bash +++ b/setup/tue-functions.bash @@ -1423,6 +1423,15 @@ function _tue-repos-do local -a cmd_array cmd_array=("$@") + local repos_dirs + if [[ -n ${TUE_REPOS_DO_DIRS} ]] + then + repos_dirs=${TUE_REPOS_DO_DIRS} + else + repos_dirs=${TUE_REPOS_DIR}/github.com/tue-robotics + echo -e "No 'TUE_REPOS_DO_DIRS' set, using: \e[1m${repos_dirs}\e[0m" + fi + { [ -n "$TUE_DIR" ] && cd "$TUE_DIR"; } || { echo -e "TUE_DIR '$TUE_DIR' does not exist"; return 1; } echo -e "\e[1m[tue-env]\e[0m" eval "${cmd_array[*]}" @@ -1431,33 +1440,24 @@ function _tue-repos-do echo -e "\e[1m[tue-env-targets]\e[0m" eval "${cmd_array[*]}" - local repos_dir - repos_dir=$TUE_REPOS_DIR/github.com/tue-robotics - if [ ! -d "$repos_dir" ] - then - echo -e "No other repos found" - # shellcheck disable=SC2164 - cd "${mem_pwd}" - return 0 - fi - - local fs - fs=$(ls "$repos_dir") - for repo in $fs + for repos_dir in $(echo "${repos_dirs}" | tr ':' '\n') do - local repo_dir - repo_dir=$repos_dir/$repo - - if [ -d "$repo_dir" ] - then - cd "$repo_dir" || { echo -e "Directory '$TUE_ENV_TARGETS_DIR' does not exist"; return 1; } + for repo_dir in $(find "$(realpath --no-symlinks "${repos_dir}")" -name '.git' -type d -prune -print0 | xargs -0 dirname) + do + local repo + repo=$(realpath --relative-to="${repos_dir}" "${repo_dir}") + if [[ ${repo} == "." ]] + then + repo=$(basename "${repo_dir}") + fi + cd "${repo_dir}" || { echo -e "Directory '${repo_dir}' does not exist"; return 1; } echo -e "\e[1m[${repo%.git}]\e[0m" eval "${cmd_array[*]}" - fi + done done # shellcheck disable=SC2164 - cd "$mem_pwd" + cd "${mem_pwd}" } function _tue-add-git-remote