summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAnton Gerasimov <anton@advancedtelematic.com>2017-07-05 12:11:52 +0200
committerAnton Gerasimov <anton@advancedtelematic.com>2017-07-05 12:11:52 +0200
commit69a0db9291725b1ddfa643dc00d6d2f1bf6c5caf (patch)
treec9e4c89bce12a81ddd364b2676c8a005fff725dd /scripts
parentb0d9d7018502a29f062895f853efd41e7b760d5a (diff)
parentb56329a3745c93060888492db8e5762ba2628783 (diff)
downloadmeta-updater-69a0db9291725b1ddfa643dc00d6d2f1bf6c5caf.tar.gz
Merge branch 'morty' into pyro
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/envsetup.sh53
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
3SCRIPT="envsetup.sh" 3SCRIPT="envsetup.sh"
4MACHINE="$1"
5BUILDDIR="build"
4 6
5MACHINE=$1 7[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir]"; return 1; }
6 8[[ "$#" -eq 2 ]] && { BUILDDIR="$2"; }
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 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
18SOURCED=0 11SOURCED=0
19if [ -n "$ZSH_EVAL_CONTEXT" ]; then 12if [ -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); }
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 14elif [ -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); }
25fi 16fi
26 17
27if [ $SOURCED -ne 1 ]; then 18if [[ $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
33fi 22fi
34 23
35SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) 24METADIR="${SOURCEDIR}/../.."
36METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)
37 25
38if [ -e ${BUILDDIR}/conf/local.conf ]; then 26if [[ ! -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
40else 33else
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
47fi 35fi
48