diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/envsetup.sh | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 7314111..c2f27c5 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh | |||
| @@ -1,51 +1,33 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | SCRIPT="envsetup.sh" | 3 | SCRIPT="envsetup.sh" |
| 4 | MACHINE=$1 | 4 | MACHINE="$1" |
| 5 | BUILDDIR="build" | ||
| 5 | 6 | ||
| 6 | if [ "$#" -lt 1 ]; then | 7 | [[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir]"; return 1; } |
| 7 | echo "Usage: ${SCRIPT} <machine> [builddir]" | 8 | [[ "$#" -eq 2 ]] && { BUILDDIR="$2"; } |
| 8 | return -1 | ||
| 9 | elif [ "$#" -eq 2 ]; then | ||
| 10 | BUILDDIR=$2 | ||
| 11 | else | ||
| 12 | BUILDDIR=build | ||
| 13 | fi | ||
| 14 | BULDDIR=$2 | ||
| 15 | 9 | ||
| 16 | # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 | 10 | # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 |
| 17 | SOURCED=0 | 11 | SOURCED=0 |
| 18 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then | 12 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then |
| 19 | [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $0) && pwd -P); } | 13 | [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); } |
| 20 | elif [ -n "$KSH_VERSION" ]; then | ||
| 21 | [[ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- ${.sh.file}) && pwd -P); } | ||
| 22 | elif [ -n "$BASH_VERSION" ]; then | 14 | elif [ -n "$BASH_VERSION" ]; then |
| 23 | [[ $0 != "$BASH_SOURCE" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $BASH_SOURCE) && pwd -P); } | 15 | [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); } |
| 24 | fi | 16 | fi |
| 25 | 17 | ||
| 26 | if [ $SOURCED -ne 1 ]; then | 18 | if [[ $SOURCED -ne 1 ]]; then |
| 27 | unset SOURCED | 19 | echo "Error: this script needs to be sourced in a supported shell" >&2 |
| 28 | unset SOURCEDIR | 20 | echo "Please check that the current shell is bash or zsh and run this script as '. $0 <args>'" >&2 |
| 29 | echo "Error: this script needs to be sourced in a supported shell" >&2 | 21 | exit 1 |
| 30 | echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2 | ||
| 31 | exit -1 | ||
| 32 | fi | 22 | fi |
| 33 | 23 | ||
| 34 | if [ -n "$ZSH_VERSION" ]; then | 24 | METADIR="${SOURCEDIR}/../.." |
| 35 | SCRIPTDIR=$(cd $(dirname $0) && pwd -P) | 25 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" |
| 36 | else | ||
| 37 | SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) | ||
| 38 | fi | ||
| 39 | METADIR="${SCRIPTDIR}/../.." | ||
| 40 | 26 | ||
| 41 | if [ -e ${BUILDDIR}/conf/local.conf ]; then | 27 | if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then |
| 42 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | 28 | echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf |
| 43 | else | 29 | cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf |
| 44 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | 30 | cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf |
| 45 | echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf | 31 | echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf |
| 46 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf | 32 | echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf |
| 47 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf | ||
| 48 | echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf | ||
| 49 | echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf | ||
| 50 | fi | 33 | fi |
| 51 | |||
