diff options
Diffstat (limited to 'scripts/envsetup.sh')
-rwxr-xr-x | scripts/envsetup.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh new file mode 100755 index 0000000..ff78681 --- /dev/null +++ b/scripts/envsetup.sh | |||
@@ -0,0 +1,35 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | SCRIPT="envsetup.sh" | ||
4 | MACHINE="$1" | ||
5 | BUILDDIR="build" | ||
6 | |||
7 | [[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir]"; return 1; } | ||
8 | [[ "$#" -eq 2 ]] && { BUILDDIR="$2"; } | ||
9 | |||
10 | # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 | ||
11 | SOURCED=0 | ||
12 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then | ||
13 | [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); } | ||
14 | elif [ -n "$BASH_VERSION" ]; then | ||
15 | [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); } | ||
16 | fi | ||
17 | |||
18 | if [[ $SOURCED -ne 1 ]]; then | ||
19 | echo "Error: this script needs to be sourced in a supported shell" >&2 | ||
20 | echo "Please check that the current shell is bash or zsh and run this script as '. $0 <args>'" >&2 | ||
21 | exit 1 | ||
22 | fi | ||
23 | |||
24 | METADIR="${SOURCEDIR}/../.." | ||
25 | |||
26 | if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then | ||
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 | ||
33 | else | ||
34 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" | ||
35 | fi | ||