Skip to content

Commit

Permalink
Make _tue-repos-do configurable (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh authored Nov 13, 2023
2 parents b70407a + 12f209b commit 804e1a5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 49 deletions.
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <targets_repo_git_url>
```

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
Expand Down Expand Up @@ -72,13 +72,13 @@ cat ~/.ssh/<KEY_NAME>.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 <TARGET_NAME>
```

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
Expand All @@ -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.
Expand All @@ -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):

Expand All @@ -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 <environment> # 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`
Expand All @@ -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`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -229,7 +238,7 @@ Depending on Ubuntu distribution:
name: [null/<Name of the candidate>]
```
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
Expand Down Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.0
1.15.2
2 changes: 1 addition & 1 deletion setup/generate_setup_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup/tue-env-config.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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-")
Expand Down
29 changes: 18 additions & 11 deletions setup/tue-env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]]
Expand Down Expand Up @@ -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" ]]
Expand Down Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions setup/tue-functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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[*]}"
Expand All @@ -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
Expand Down

0 comments on commit 804e1a5

Please sign in to comment.