summaryrefslogtreecommitdiffstats
path: root/scripts/envsetup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/envsetup.sh')
-rwxr-xr-xscripts/envsetup.sh35
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
3SCRIPT="envsetup.sh"
4MACHINE="$1"
5BUILDDIR="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
11SOURCED=0
12if [ -n "$ZSH_EVAL_CONTEXT" ]; then
13 [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); }
14elif [ -n "$BASH_VERSION" ]; then
15 [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); }
16fi
17
18if [[ $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
22fi
23
24METADIR="${SOURCEDIR}/../.."
25
26if [[ ! -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
33else
34 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
35fi