diff options
author | Rebecca Cran <rebecca@bsdio.com> | 2023-04-24 23:59:14 +0300 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-05-10 15:02:34 +0300 |
commit | e6447d2a08f5ca585816d093e79a01dad3781f98 (patch) | |
tree | 76e15689e427477950f9fa3e88d443df6749bd00 /edksetup.sh | |
parent | 373a95532a785108f625877d993451d4a6d36713 (diff) | |
download | edk2-e6447d2a08f5ca585816d093e79a01dad3781f98.tar.xz |
Remove bashisms from edksetup.sh and BaseTools/BuildEnv
Remove bashisms from edksetup.sh and BaseTools/BuildEnv. This allows any
POSIX shell to use those scripts, removing the dependency on bash.
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'edksetup.sh')
-rwxr-xr-x | edksetup.sh | 89 |
1 files changed, 11 insertions, 78 deletions
diff --git a/edksetup.sh b/edksetup.sh index 06d2f041e6..cab3a8c113 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -20,7 +20,7 @@ SCRIPTNAME="edksetup.sh" RECONFIG=FALSE -function HelpMsg() +HelpMsg() { echo "Usage: $SCRIPTNAME [Options]" echo @@ -38,7 +38,7 @@ function HelpMsg() echo "source $SCRIPTNAME" } -function SetWorkspace() +SetWorkspace() { # # If WORKSPACE is already set, then we can return right now @@ -49,10 +49,10 @@ function SetWorkspace() return 0 fi - if [ ! ${BASH_SOURCE[0]} -ef ./$SCRIPTNAME ] && [ -z "$PACKAGES_PATH" ] + if [ ! -f ${SCRIPTNAME} ] && [ -z "$PACKAGES_PATH" ] then - echo Run this script from the base of your tree. For example: - echo " cd /Path/To/Edk/Root" + echo Source this script from the base of your tree. For example: + echo " cd /Path/To/Edk2/Clone" echo " . $SCRIPTNAME" return 1 fi @@ -75,7 +75,7 @@ function SetWorkspace() return 0 } -function SetupEnv() +SetupEnv() { if [ -n "$EDK_TOOLS_PATH" ] then @@ -85,9 +85,7 @@ function SetupEnv() . $WORKSPACE/BaseTools/BuildEnv elif [ -n "$PACKAGES_PATH" ] then - PATH_LIST=$PACKAGES_PATH - PATH_LIST=${PATH_LIST//:/ } - for DIR in $PATH_LIST + for DIR in $(echo $PACKAGES_PATH | tr ':' ' ') do if [ -f "$DIR/BaseTools/BuildEnv" ] then @@ -105,81 +103,16 @@ function SetupEnv() fi } -function SetupPython3() +SetupPython3() { - if [ $origin_version ];then - origin_version= - fi - for python in $(whereis python3) - do - python=$(echo $python | grep "[[:digit:]]$" || true) - python_version=${python##*python} - if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then - continue - fi - if [ -z $origin_version ];then - origin_version=$python_version - export PYTHON_COMMAND=$python - continue - fi - if [[ "$origin_version" < "$python_version" ]]; then - origin_version=$python_version - export PYTHON_COMMAND=$python - fi - done - return 0 + export PYTHON_COMMAND=python3 } -function SetupPython() +SourceEnv() { - if [ $PYTHON_COMMAND ] && [ -z $PYTHON3_ENABLE ];then - if ( command -v $PYTHON_COMMAND >/dev/null 2>&1 );then - return 0 - else - echo $PYTHON_COMMAND Cannot be used to build or execute the python tools. - return 1 - fi - fi - - if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ] - then - SetupPython3 - fi - - if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE ] - then - if [ $origin_version ];then - origin_version= - fi - for python in $(whereis python2) - do - python=$(echo $python | grep "[[:digit:]]$" || true) - python_version=${python##*python} - if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then - continue - fi - if [ -z $origin_version ] - then - origin_version=$python_version - export PYTHON_COMMAND=$python - continue - fi - if [[ "$origin_version" < "$python_version" ]]; then - origin_version=$python_version - export PYTHON_COMMAND=$python - fi - done - return 0 - fi - SetupPython3 -} - -function SourceEnv() -{ - SetWorkspace && + SetWorkspace SetupEnv - SetupPython } I=$# |