From 3103bf334820ff4505ce6b30af7ee7466858eae5 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Tue, 22 Jan 2019 16:30:27 +0000 Subject: [PATCH 1/2] lisa: shell: Force shell to rescan $PATH folders Calling lisa-install will lead to new content in directories listed in $PATH. Shells typically cache the content of these folders, so force them to refresh their view. --- init_env | 5 ----- shell/lisa_shell | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/init_env b/init_env index 3918459ff..e908781db 100644 --- a/init_env +++ b/init_env @@ -31,12 +31,9 @@ setup_paths() { if [[ -n $BASH_VERSION ]]; then # Get base installation path of LISA export LISA_HOME=$(readlink -f "$(dirname "$BASH_SOURCE")") - source "$(dirname "$BASH_SOURCE")/shell/lisa_shell"; _lisa_shell_ret=$? PS1="\[${LISASHELL_BLUE}\][LISAShell \[${LISASHELL_LCYAN}\]\W\[${LISASHELL_BLUE}\]] \> \[${LISASHELL_RESET}\]" - # Make sure that bash picks up new location for all binaries - hash -r # Running under ZSH elif [[ -n $ZSH_VERSION ]]; then @@ -47,8 +44,6 @@ elif [[ -n $ZSH_VERSION ]]; then # functions declared there to be executed in emulated mode, so they will # work as well emulate sh -c "source "$LISA_HOME/shell/lisa_shell""; _lisa_shell_ret=$? - # Make sure that zsh picks up new location for all binaries - hash -r else echo "WARNING: Current shell is not a BASH" diff --git a/shell/lisa_shell b/shell/lisa_shell index ac95a4680..b02d8638b 100755 --- a/shell/lisa_shell +++ b/shell/lisa_shell @@ -94,6 +94,13 @@ PYTHON_VERSION=$(_lisa-python -c 'import sys; print("{}.{}".format(*sys.version_ export LISA_USE_VENV=${LISA_USE_VENV:-1} export LISA_VENV_PATH=${LISA_VENV_PATH:-"$LISA_HOME/.lisa-venv-$PYTHON_VERSION"} + +# Force the shell to rescan the folders listed in $PATH +function _lisa-reload-PATH { + # that should work for most shells (at least bash and zsh) + hash -r +} + function _lisa-venv-create { if [[ "$LISA_USE_VENV" == 1 ]]; then # Make sure we don't nest venv, by calling deactivate if it exists, @@ -121,6 +128,10 @@ function lisa-venv-activate { VIRTUAL_ENV_DISABLE_PROMPT=1 source "$LISA_VENV_PATH/bin/activate" fi + # Make sure the shell takes into account the new content of folders listed + # in $PATH, even if we did not actually activate a venv + _lisa-reload-PATH + # Check if lisa-install needs to be run again, but ignore the return value # so it won't make activation fail just because of that (check-setuppy; exit 0) @@ -181,6 +192,10 @@ function lisa-install { echo _lisa-python -m pip install -r "$custom_requirements" "$@" fi + + # Make sure the shell has taken into account the new content of directories + # listed in $PATH. + _lisa-reload-PATH } ################################################################################ -- GitLab From 819583654756f7f9ea72ee6116c6d6b458440c5b Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Tue, 22 Jan 2019 16:46:28 +0000 Subject: [PATCH 2/2] lisa: shell: remove lisa-update Only keep _lisa-update-subtrees. Since all LISA users are familiar with git, they can just pull from github. --- shell/README.txt | 1 - shell/lisa_shell | 66 ------------------------------------------------ 2 files changed, 67 deletions(-) diff --git a/shell/README.txt b/shell/README.txt index 5765cce3f..4468ce0fa 100644 --- a/shell/README.txt +++ b/shell/README.txt @@ -15,7 +15,6 @@ lisa-buildroot-create-rootfs - Create a buildroot based rootfs to be used as u .:: Maintenance commands ------------------------ -lisa-update - Update submodules and LISA notebooks/tests lisa-install - Remove the previous venv and do a fresh ven install lisa-activate-venv - Activate the LISA venv, and create it if it does not exist lisa-deactivate-venv - Deactivate the LISA venv, and create it if it does not exist diff --git a/shell/lisa_shell b/shell/lisa_shell index b02d8638b..9978d3b65 100755 --- a/shell/lisa_shell +++ b/shell/lisa_shell @@ -202,15 +202,6 @@ function lisa-install { # LISA Update utility functions ################################################################################ -function _lisa-update-usage { - echo "Usage: lisa-update (CMD)" - echo " CMD: what to update (default: all)" - echo " all - update lisa and all the external dependencies" - echo " subtrees - update external dependencies provided by subtrees" - echo - echo "Update subtrees (if LISA_DEVMODE enabled)" -} - function _lisa-update-subtrees { echo -ne "${LISASHELL_BLUE}" if [[ "$LISA_DEVMODE" == 1 ]]; then @@ -223,63 +214,6 @@ function _lisa-update-subtrees { echo -ne "$LISASHELL_DEFAULT" } -function _lisa-update-all { - echo -ne "${LISASHELL_BLUE}" - echo -e "*** Update LISA installation" - - - if git update-index -q --refresh; then - echo "LISA internal error: git update-index failed" - echo "Please report it: https://github.com/ARM-software/lisa/issues" - return $ret - fi - - if git diff-index --quiet HEAD; then - echo "There are outstanding uncommitted changes." - echo "Please, commit your changes or stash them before you can update lisa" - return $ret - fi - - curr_commit=$(git rev-parse HEAD) - remote_name=$(git remote -v | grep -i ARM-software/lisa | grep -m 1 fetch | awk '{print $1}') - if [[ -z "$remote_name" ]]; then - echo "Couldn't find ARM-Software upstream remote, can't automatically update" - return 1 - fi - - if git merge-base --is-ancestor $curr_commit $remote_name/master; then - echo "You have committed changes that are not part of $remote_name/master" - echo "Please move to the master branch before running lisa-update" - return $ret - fi - - - if git pull --ff-only $remote_name master; then - # git pull should have printed some error. Abort and propagate the error code. - return $ret - fi - - echo -ne "$LISASHELL_DEFAULT" -} - -function lisa-update { - CMD=${1:-all} - echo - case "$CMD" in - subtrees) - _lisa-update-subtrees - ;; - all) - _lisa-update-all - ;; - help|*) - _lisa-update-usage - ;; - esac - echo - echo -} - ################################################################################ # LISA Notebooks utility functions ################################################################################ -- GitLab