|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | ############################################################################### |
4 | | -# Copyright 2018 The Apollo Authors. All Rights Reserved. |
| 4 | +# Copyright 2025 The WheelOS Team. All Rights Reserved. |
5 | 5 | # |
6 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | # you may not use this file except in compliance with the License. |
|
15 | 15 | # See the License for the specific language governing permissions and |
16 | 16 | # limitations under the License. |
17 | 17 | ############################################################################### |
18 | | -APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" |
19 | 18 |
|
20 | | -PYTHON_USER_BASE=$(python3 -c 'import site; print(site.USER_BASE)') |
21 | | -PYTHON_INSTALL_PATH="${PYTHON_USER_BASE}/apollo/tools" |
22 | | -PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))') |
| 19 | +LOCAL_BIN_PATH="$HOME/.local/bin" |
| 20 | +BASHRC="$HOME/.bashrc" |
| 21 | +MARKER="# [apollo-deploy] Added by host_env.sh" |
23 | 22 |
|
24 | | -source ${APOLLO_ROOT_DIR}/scripts/common.bashrc |
| 23 | +echo "Setup host environment..." |
25 | 24 |
|
26 | | -pathprepend "${PYTHON_INSTALL_PATH}/lib/python${PYTHON_VERSION}/site-packages" PYTHONPATH |
27 | | -pathprepend "${PYTHON_INSTALL_PATH}/bin/" PATH |
| 25 | +mkdir -p "$LOCAL_BIN_PATH" |
| 26 | + |
| 27 | +if ! grep -qF "$MARKER" "$BASHRC"; then |
| 28 | + echo "Writing PATH update snippet to $BASHRC..." |
| 29 | + cat << EOF >> "$BASHRC" |
| 30 | +$MARKER |
| 31 | +if [ -d "\$HOME/.local/bin" ] && [[ ":\$PATH:" != *":\$HOME/.local/bin:"* ]]; then |
| 32 | + export PATH="\$HOME/.local/bin:\$PATH" |
| 33 | +fi |
| 34 | +EOF |
| 35 | +else |
| 36 | + echo "Environment variables already configured in $BASHRC." |
| 37 | +fi |
| 38 | + |
| 39 | +# Apply immediately to the current shell |
| 40 | +if [ -d "$LOCAL_BIN_PATH" ] && [[ ":$PATH:" != *":$LOCAL_BIN_PATH:"* ]]; then |
| 41 | + export PATH="$LOCAL_BIN_PATH:$PATH" |
| 42 | + echo "Updated PATH for current shell." |
| 43 | +fi |
| 44 | + |
| 45 | +echo "Current PATH: $PATH" |
0 commit comments