summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAnton Gerasimov <anton@advancedtelematic.com>2017-04-03 12:08:39 +0200
committerAnton Gerasimov <anton@advancedtelematic.com>2017-04-04 12:01:58 +0200
commit82a3c13a0b0c9979fa0812143d619748aa89c85d (patch)
treebd18751638ce99904dcd68ad2eba6e6db7851f41 /scripts
parentb49c2631b6bc48ead4d352e2bd00cdfbca7af5e8 (diff)
downloadmeta-updater-82a3c13a0b0c9979fa0812143d619748aa89c85d.tar.gz
Replace TEMPLATECONF with agl-like config snippets
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/envsetup.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
new file mode 100755
index 0000000..316a782
--- /dev/null
+++ b/scripts/envsetup.sh
@@ -0,0 +1,53 @@
1#!/bin/sh
2
3SCRIPT="envsetup.sh"
4
5MACHINE=$1
6
7if [ "$#" -lt 1 ]; then
8 echo "Usage: ${SCRIPT} <machine> [builddir]"
9 return -1
10elif [ "$#" -eq 2 ]; then
11 BUILDDIR=$2
12else
13 BUILDDIR=build
14fi
15BULDDIR=$2
16
17# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594
18SOURCED=0
19if [ -n "$ZSH_EVAL_CONTEXT" ]; then
20 [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $0) && pwd -P); }
21elif [ -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); }
23elif [ -n "$BASH_VERSION" ]; then
24 [[ $0 != "$BASH_SOURCE" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $BASH_SOURCE) && pwd -P); }
25fi
26
27if [ $SOURCED -ne 1 ]; then
28 unset SOURCED
29 unset SOURCEDIR
30 echo "Error: this script needs to be sourced in a supported shell" >&2
31 echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2
32 exit -1
33fi
34
35SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P)
36METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)
37
38if ! [[ -e ${SCRIPTDIR}/../conf/include/local/sota_${MACHINE}.inc && -e ${SCRIPTDIR}/../conf/include/bblayers/sota_${MACHINE}.inc ]]; then
39 echo "Error: invalid machine: ${MACHINE}" >&2
40 return -1
41fi
42
43if [ -e ${BUILDDIR}/conf/local.conf ]; then
44 source $METADIR/poky/oe-init-build-env ${BUILDDIR}
45else
46 source $METADIR/poky/oe-init-build-env ${BUILDDIR}
47 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf
48 cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf
49 cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf
50 echo "include conf/include/local/sota_${MACHINE}.inc" >> conf/local.conf
51 echo "include conf/distro/sota.conf.inc" >> conf/local.conf
52fi
53