From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=96.73.9.1; helo=muon.bluestop.org; envelope-from=rebecca@bluestop.org; receiver=edk2-devel@lists.01.org Received: from muon.bluestop.org (muon.bluestop.org [96.73.9.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A4ECC211CFBD4 for ; Mon, 25 Feb 2019 19:50:44 -0800 (PST) Received: from muon.bluestop.org (localhost [127.0.0.1]) by muon.bluestop.org (Postfix) with ESMTP id 69C7D78F77; Mon, 25 Feb 2019 20:51:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bluestop.org; s=mail; t=1551153093; bh=eXM1GrNoKVKp1q7ZpXNEmqtBytL1a75K7S2iIryqlxU=; h=Subject:To:References:From:Date:In-Reply-To:From; b=iyysCeI8E748fLkllfhKDqYyBUjmB6QhG2bWrT/lbfik16ZVVuAjMrlzSCMf5xAPW XeiuAsR9qWNd+29nN90yjjQna3jIRjPmbpeQmu+PEM055xqsEqNkRRGOa3CJl9PuEO nvWcfgzJ6Gh5uSnx8P9uk12wyl/e1E5spmP66C9Q= Received: from muon.bluestop.org ([127.0.0.1]) by muon.bluestop.org (muon.bluestop.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KbSSKrLnt7un; Mon, 25 Feb 2019 20:51:31 -0700 (MST) Received: from photon.int.bluestop.org (gw.bluestop.org [96.73.9.3]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by muon.bluestop.org (Postfix) with ESMTPSA; Mon, 25 Feb 2019 20:51:31 -0700 (MST) To: "Feng, Bob C" , "edk2-devel@lists.01.org" References: <20190222051253.51931-1-rebecca@bluestop.org> <20190222051253.51931-2-rebecca@bluestop.org> <08650203BA1BD64D8AD9B6D5D74A85D16008F224@SHSMSX101.ccr.corp.intel.com> From: Rebecca Cran Message-ID: <68b46f60-5887-259a-8a26-9c31946f1fd9@bluestop.org> Date: Mon, 25 Feb 2019 20:50:41 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <08650203BA1BD64D8AD9B6D5D74A85D16008F224@SHSMSX101.ccr.corp.intel.com> Subject: Re: [PATCH] Convert PosixLike scripts to sh, reduce duplication and fix some bugs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2019 03:50:44 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Thanks for the review. I have a macOS system, so I'll verify future changes work there too. The problem I'm trying to solve is to make it easier to get started building EDK2 under FreeBSD. Currently it needs symlinks in BaseTools/Bin/FreeBSD-amd64 for gcc, ld, make, objcopy and python, and obviously needs bash installed. Since there seems to be relatively little shell code in the repo, I was thinking that avoiding the dependency on bash might be a relatively easy way to reduce the steps needed to get things working. I'll try and remember about PatchCheck.py too. -- Rebecca On 2/25/19 8:11 PM, Feng, Bob C wrote: > Hi Rebecca, > > I like the change of moving duplicated code into common files and the bug fix looks good. > > I tested this patch on our CI system, it break the build on MacOS. There is no realpath command on MacOs shell. > > For the patch itself, it need to pass the check of BaseTools/Scripts/PatchCheck.py. > > Is there actual problem that need to be resolved by using sh instead of bash? > > Thanks, > Bob > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Rebecca Cran via edk2-devel > Sent: Friday, February 22, 2019 1:13 PM > To: edk2-devel@lists.01.org > Subject: [edk2] [PATCH] Convert PosixLike scripts to sh, reduce duplication and fix some bugs > > Since the scripts in the PosixLike directory are very simple, convert them to use /bin/sh, and move duplicated code into common files (one for python scripts, one for C binaries). > > Fix some bugs in edksetup.sh and BuildEnv: `test` uses single equals instead of double equals, and should have a space before the ending bracket. Fix some indentation, and if the user runs edksetup.sh with --help etc., quit after displaying the help message. > --- > BaseTools/BinWrappers/PosixLike/BPDG | 15 ++-------- > BaseTools/BinWrappers/PosixLike/Brotli | 30 ++----------------- > .../BinWrappers/PosixLike/BrotliCompress | 12 ++++---- > BaseTools/BinWrappers/PosixLike/DevicePath | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/Ecc | 15 ++-------- > BaseTools/BinWrappers/PosixLike/EfiRom | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/GenCrc32 | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/GenDepex | 15 ++-------- > BaseTools/BinWrappers/PosixLike/GenFds | 15 ++-------- > BaseTools/BinWrappers/PosixLike/GenFfs | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/GenFv | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/GenFw | 30 ++----------------- > .../BinWrappers/PosixLike/GenPatchPcdTable | 15 ++-------- > BaseTools/BinWrappers/PosixLike/GenSec | 30 ++----------------- > .../BinWrappers/PosixLike/GenerateCapsule | 15 ++-------- > BaseTools/BinWrappers/PosixLike/LzmaCompress | 30 ++----------------- > .../BinWrappers/PosixLike/LzmaF86Compress | 2 +- > BaseTools/BinWrappers/PosixLike/PatchPcdValue | 15 ++-------- > BaseTools/BinWrappers/PosixLike/Pkcs7Sign | 15 ++-------- > .../PosixLike/Rsa2048Sha256GenerateKeys | 15 ++-------- > .../BinWrappers/PosixLike/Rsa2048Sha256Sign | 15 ++-------- > BaseTools/BinWrappers/PosixLike/Split | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/TargetTool | 15 ++-------- > BaseTools/BinWrappers/PosixLike/TianoCompress | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/Trim | 15 ++-------- > BaseTools/BinWrappers/PosixLike/UPT | 15 ++-------- > BaseTools/BinWrappers/PosixLike/VfrCompile | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/VolInfo | 30 ++----------------- > BaseTools/BinWrappers/PosixLike/build | 15 ++-------- > BaseTools/BinWrappers/PosixLike/common.sh | 12 ++++++++ > BaseTools/BinWrappers/PosixLike/commonbin.sh | 28 +++++++++++++++++ > BaseTools/BuildEnv | 3 +- > edksetup.sh | 12 ++++---- > 33 files changed, 110 insertions(+), 559 deletions(-) create mode 100644 BaseTools/BinWrappers/PosixLike/common.sh > create mode 100644 BaseTools/BinWrappers/PosixLike/commonbin.sh > > diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG > index c894384908..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/BPDG > +++ b/BaseTools/BinWrappers/PosixLike/BPDG > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" -m $cmd.$cmd "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Brotli b/BaseTools/BinWrappers/PosixLike/Brotli > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/Brotli > +++ b/BaseTools/BinWrappers/PosixLike/Brotli > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/BrotliCompress b/BaseTools/BinWrappers/PosixLike/BrotliCompress > index ea86705a28..7cb26a3659 100755 > --- a/BaseTools/BinWrappers/PosixLike/BrotliCompress > +++ b/BaseTools/BinWrappers/PosixLike/BrotliCompress > @@ -1,4 +1,4 @@ > -#!/usr/bin/env bash > +#!/bin/sh > # > # This script will exec Brotli tool with -e/-d options. > # > @@ -20,21 +20,21 @@ do > -e) > ;; > -d) > - ARGS+="$1 " > + ARGS="$ARGS $1" > ;; > -o|-g) > - ARGS+="$1 $2 " > + ARGS="$ARGS $1 $2" > shift > ;; > -q) > - QLT="$1 $2 " > + QLT="$1 $2" > shift > ;; > *) > - ARGS+="$1 " > + ARGS="$ARGS $1" > ;; > esac > shift > done > > -exec Brotli $QLT $ARGS > +exec "$(dirname "$0")/Brotli" $QLT $ARGS > diff --git a/BaseTools/BinWrappers/PosixLike/DevicePath b/BaseTools/BinWrappers/PosixLike/DevicePath > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/DevicePath > +++ b/BaseTools/BinWrappers/PosixLike/DevicePath > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc > index 15edf52106..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/Ecc > +++ b/BaseTools/BinWrappers/PosixLike/Ecc > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" -m $cmd.EccMain "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/EfiRom b/BaseTools/BinWrappers/PosixLike/EfiRom > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/EfiRom > +++ b/BaseTools/BinWrappers/PosixLike/EfiRom > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenCrc32 b/BaseTools/BinWrappers/PosixLike/GenCrc32 > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenCrc32 > +++ b/BaseTools/BinWrappers/PosixLike/GenCrc32 > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex > index 183cf58224..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenDepex > +++ b/BaseTools/BinWrappers/PosixLike/GenDepex > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/AutoGen/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds > index c894384908..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenFds > +++ b/BaseTools/BinWrappers/PosixLike/GenFds > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" -m $cmd.$cmd "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenFfs b/BaseTools/BinWrappers/PosixLike/GenFfs > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenFfs > +++ b/BaseTools/BinWrappers/PosixLike/GenFfs > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenFv b/BaseTools/BinWrappers/PosixLike/GenFv > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenFv > +++ b/BaseTools/BinWrappers/PosixLike/GenFv > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenFw b/BaseTools/BinWrappers/PosixLike/GenFw > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenFw > +++ b/BaseTools/BinWrappers/PosixLike/GenFw > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable > +++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenSec b/BaseTools/BinWrappers/PosixLike/GenSec > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenSec > +++ b/BaseTools/BinWrappers/PosixLike/GenSec > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/GenerateCapsule b/BaseTools/BinWrappers/PosixLike/GenerateCapsule > index 023048c61d..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/GenerateCapsule > +++ b/BaseTools/BinWrappers/PosixLike/GenerateCapsule > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/Capsule/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/LzmaCompress b/BaseTools/BinWrappers/PosixLike/LzmaCompress > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/LzmaCompress > +++ b/BaseTools/BinWrappers/PosixLike/LzmaCompress > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/LzmaF86Compress b/BaseTools/BinWrappers/PosixLike/LzmaF86Compress > index 078cb1e21d..4049f9f596 100755 > --- a/BaseTools/BinWrappers/PosixLike/LzmaF86Compress > +++ b/BaseTools/BinWrappers/PosixLike/LzmaF86Compress > @@ -1,4 +1,4 @@ > -#!/usr/bin/env bash > +#!/bin/sh > # > # This script will exec LzmaCompress tool with --f86 option that enables converter for x86 code. > # > diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue > +++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign > +++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys > index ea71c7c61a..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys > +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/Rsa2048Sha256Sign/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign > +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Split b/BaseTools/BinWrappers/PosixLike/Split > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/Split > +++ b/BaseTools/BinWrappers/PosixLike/Split > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/TargetTool > +++ b/BaseTools/BinWrappers/PosixLike/TargetTool > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/TianoCompress b/BaseTools/BinWrappers/PosixLike/TianoCompress > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/TianoCompress > +++ b/BaseTools/BinWrappers/PosixLike/TianoCompress > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim > index 1dd28e9662..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/Trim > +++ b/BaseTools/BinWrappers/PosixLike/Trim > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -exe=$(basename "$full_cmd") > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/UPT > +++ b/BaseTools/BinWrappers/PosixLike/UPT > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/VfrCompile b/BaseTools/BinWrappers/PosixLike/VfrCompile > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/VfrCompile > +++ b/BaseTools/BinWrappers/PosixLike/VfrCompile > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/VolInfo b/BaseTools/BinWrappers/PosixLike/VolInfo > index 0945d86d92..3dfa26e517 100755 > --- a/BaseTools/BinWrappers/PosixLike/VolInfo > +++ b/BaseTools/BinWrappers/PosixLike/VolInfo > @@ -1,29 +1,3 @@ > -#!/usr/bin/env bash > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] -then > - exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > -elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] -then > - if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > - then > - echo "BaseTools C Tool binary was not found ($cmd)" > - echo "You may need to run:" > - echo " make -C $EDK_TOOLS_PATH/Source/C" > - else > - exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > - fi > -elif [ -e "$dir/../../Source/C/bin/$cmd" ] -then > - exec "$dir/../../Source/C/bin/$cmd" "$@" > -else > - echo "Unable to find the real '$cmd' to run" > - echo "This message was printed by" > - echo " $0" > - exit 127 > -fi > +#!/bin/sh > > +. "$(dirname "$(realpath "$0")")/commonbin.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build > index f3770eed42..a9da3afb4b 100755 > --- a/BaseTools/BinWrappers/PosixLike/build > +++ b/BaseTools/BinWrappers/PosixLike/build > @@ -1,14 +1,3 @@ > -#!/usr/bin/env bash > -#python `dirname $0`/RunToolFromSource.py `basename $0` $* > +#!/bin/sh > > -# If a ${PYTHON_COMMAND} command is available, use it in preference to python -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then > - python_exe=${PYTHON_COMMAND} > -fi > - > -full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here -dir=$(dirname "$full_cmd") -cmd=${full_cmd##*/} > - > -export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > -exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" > +. "$(dirname "$(realpath "$0")")/common.sh" > diff --git a/BaseTools/BinWrappers/PosixLike/common.sh b/BaseTools/BinWrappers/PosixLike/common.sh > new file mode 100644 > index 0000000000..63a45bb54c > --- /dev/null > +++ b/BaseTools/BinWrappers/PosixLike/common.sh > @@ -0,0 +1,12 @@ > +#!/bin/sh > + > +# If a ${PYTHON_COMMAND} command is available, use it in preference to > +python if command -v "${PYTHON_COMMAND}" >/dev/null 2>&1; then > + python_exe=${PYTHON_COMMAND} > +fi > + > +dir="$(dirname "$(realpath "$0")")" > +cmd=${0##*/} > + > +export PYTHONPATH="${dir}/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" > +exec "${python_exe:-python}" "${dir}/../../Source/Python/$cmd/${cmd}.py" "$@" > diff --git a/BaseTools/BinWrappers/PosixLike/commonbin.sh b/BaseTools/BinWrappers/PosixLike/commonbin.sh > new file mode 100644 > index 0000000000..948def9ce7 > --- /dev/null > +++ b/BaseTools/BinWrappers/PosixLike/commonbin.sh > @@ -0,0 +1,28 @@ > +#!/bin/sh > + > +dir="$(dirname "$(realpath "$0")")" > +cmd=${0##*/} > + > +if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ] > +then > + exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd" > +elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ] then > + if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ] > + then > + echo "BaseTools C Tool binary was not found ($cmd)" > + echo "You may need to run:" > + echo " make -C $EDK_TOOLS_PATH/Source/C" > + else > + exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@" > + fi > +elif [ -e "$dir/../../Source/C/bin/$cmd" ] then > + exec "$dir/../../Source/C/bin/$cmd" "$@" > +else > + echo "Unable to find the real '$cmd' to run" > + echo "This message was printed by" > + echo " $0" > + exit 127 > +fi > + > diff --git a/BaseTools/BuildEnv b/BaseTools/BuildEnv index ff0c5115a5..b321828471 100755 > --- a/BaseTools/BuildEnv > +++ b/BaseTools/BuildEnv > @@ -1,3 +1,4 @@ > +#!/usr/bin/env bash > ## @file > # Setup the environment for unix-like systems running a bash-like shell. > # This file must be "sourced" not merely executed. For example: ". edksetup.sh" > @@ -136,7 +137,7 @@ SetEdkToolsPath() { > # > # Try $PACKAGES_PATH > # > - if [ -n "$PACKAGES_PATH"] > + if [ -n "$PACKAGES_PATH" ] > then > PATH_LIST=${PACKAGES_PATH//:/ } > for DIR in $PATH_LIST > diff --git a/edksetup.sh b/edksetup.sh > index a8897d10f8..4457be6e96 100755 > --- a/edksetup.sh > +++ b/edksetup.sh > @@ -1,3 +1,4 @@ > +#!/usr/bin/env bash > # > # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
# Copyright (c) 2016, Linaro Ltd. All rights reserved.
@@ -115,8 +116,8 @@ function SetupPython3() { > if [ $origin_version ];then > origin_version= > - fi > - for python in $(whereis python3) > + fi > + for python in $(whereis python3) > do > python=$(echo $python | grep "[[:digit:]]$" || true) > python_version=${python##*python} @@ -133,8 +134,8 @@ function SetupPython3() > origin_version=$python_version > export PYTHON_COMMAND=$python > fi > - done > - return 0 > + done > + return 0 > } > > function SetupPython() > @@ -148,7 +149,7 @@ function SetupPython() > fi > fi > > - if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ] > + if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE = TRUE ] > then > SetupPython3 > fi > @@ -204,6 +205,7 @@ do > ;; > -?|-h|--help|*) > HelpMsg > + return 0 > break > ;; > esac > -- > 2.20.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >