diff options
author | Anton Gerasimov <anton@advancedtelematic.com> | 2017-07-05 12:11:52 +0200 |
---|---|---|
committer | Anton Gerasimov <anton@advancedtelematic.com> | 2017-07-05 12:11:52 +0200 |
commit | 69a0db9291725b1ddfa643dc00d6d2f1bf6c5caf (patch) | |
tree | c9e4c89bce12a81ddd364b2676c8a005fff725dd /scripts | |
parent | b0d9d7018502a29f062895f853efd41e7b760d5a (diff) | |
parent | b56329a3745c93060888492db8e5762ba2628783 (diff) | |
download | meta-updater-69a0db9291725b1ddfa643dc00d6d2f1bf6c5caf.tar.gz |
Merge branch 'morty' into pyro
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/envsetup.sh | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 5adf319..ff78681 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh | |||
@@ -1,48 +1,35 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | SCRIPT="envsetup.sh" | 3 | SCRIPT="envsetup.sh" |
4 | MACHINE="$1" | ||
5 | BUILDDIR="build" | ||
4 | 6 | ||
5 | MACHINE=$1 | 7 | [[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir]"; return 1; } |
6 | 8 | [[ "$#" -eq 2 ]] && { BUILDDIR="$2"; } | |
7 | if [ "$#" -lt 1 ]; then | ||
8 | echo "Usage: ${SCRIPT} <machine> [builddir]" | ||
9 | return -1 | ||
10 | elif [ "$#" -eq 2 ]; then | ||
11 | BUILDDIR=$2 | ||
12 | else | ||
13 | BUILDDIR=build | ||
14 | fi | ||
15 | BULDDIR=$2 | ||
16 | 9 | ||
17 | # 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 |
18 | SOURCED=0 | 11 | SOURCED=0 |
19 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then | 12 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then |
20 | [[ $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); } |
21 | elif [ -n "$KSH_VERSION" ]; then | ||
22 | [[ "$(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); } | ||
23 | elif [ -n "$BASH_VERSION" ]; then | 14 | elif [ -n "$BASH_VERSION" ]; then |
24 | [[ $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); } |
25 | fi | 16 | fi |
26 | 17 | ||
27 | if [ $SOURCED -ne 1 ]; then | 18 | if [[ $SOURCED -ne 1 ]]; then |
28 | unset SOURCED | 19 | echo "Error: this script needs to be sourced in a supported shell" >&2 |
29 | unset SOURCEDIR | 20 | echo "Please check that the current shell is bash or zsh and run this script as '. $0 <args>'" >&2 |
30 | echo "Error: this script needs to be sourced in a supported shell" >&2 | 21 | exit 1 |
31 | echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2 | ||
32 | exit -1 | ||
33 | fi | 22 | fi |
34 | 23 | ||
35 | SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) | 24 | METADIR="${SOURCEDIR}/../.." |
36 | METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) | ||
37 | 25 | ||
38 | if [ -e ${BUILDDIR}/conf/local.conf ]; then | 26 | if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then |
39 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | 27 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" |
28 | echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf | ||
29 | cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf | ||
30 | cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf | ||
31 | echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf | ||
32 | echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf | ||
40 | else | 33 | else |
41 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | 34 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" |
42 | echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf | ||
43 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf | ||
44 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf | ||
45 | echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf | ||
46 | echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf | ||
47 | fi | 35 | fi |
48 | |||