summaryrefslogtreecommitdiffstats
path: root/scripts/envsetup.sh
diff options
context:
space:
mode:
authorShaun Taheri <shaun@advancedtelematic.com>2017-06-23 14:26:56 +0200
committerPhil Wise <phil@advancedtelematic.com>2017-06-26 16:22:31 +0200
commita33124a4592820f4b3c4deaf6853476df2a2f105 (patch)
tree9a4bdce2ffdd7c5f34d9ad0d2ffdb78c0705adeb /scripts/envsetup.sh
parent30109fe78e93bf2f88ebe866577bd957af35c98b (diff)
downloadmeta-updater-a33124a4592820f4b3c4deaf6853476df2a2f105.tar.gz
Quote all bash variables
Diffstat (limited to 'scripts/envsetup.sh')
-rwxr-xr-xscripts/envsetup.sh54
1 files changed, 18 insertions, 36 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
index 7314111..c2f27c5 100755
--- a/scripts/envsetup.sh
+++ b/scripts/envsetup.sh
@@ -1,51 +1,33 @@
1#!/bin/bash 1#!/bin/bash
2 2
3SCRIPT="envsetup.sh" 3SCRIPT="envsetup.sh"
4MACHINE=$1 4MACHINE="$1"
5BUILDDIR="build"
5 6
6if [ "$#" -lt 1 ]; then 7[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir]"; return 1; }
7 echo "Usage: ${SCRIPT} <machine> [builddir]" 8[[ "$#" -eq 2 ]] && { BUILDDIR="$2"; }
8 return -1
9elif [ "$#" -eq 2 ]; then
10 BUILDDIR=$2
11else
12 BUILDDIR=build
13fi
14BULDDIR=$2
15 9
16# 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
17SOURCED=0 11SOURCED=0
18if [ -n "$ZSH_EVAL_CONTEXT" ]; then 12if [ -n "$ZSH_EVAL_CONTEXT" ]; then
19 [[ $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); }
20elif [ -n "$KSH_VERSION" ]; then
21 [[ "$(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); }
22elif [ -n "$BASH_VERSION" ]; then 14elif [ -n "$BASH_VERSION" ]; then
23 [[ $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); }
24fi 16fi
25 17
26if [ $SOURCED -ne 1 ]; then 18if [[ $SOURCED -ne 1 ]]; then
27 unset SOURCED 19 echo "Error: this script needs to be sourced in a supported shell" >&2
28 unset SOURCEDIR 20 echo "Please check that the current shell is bash or zsh and run this script as '. $0 <args>'" >&2
29 echo "Error: this script needs to be sourced in a supported shell" >&2 21 exit 1
30 echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2
31 exit -1
32fi 22fi
33 23
34if [ -n "$ZSH_VERSION" ]; then 24METADIR="${SOURCEDIR}/../.."
35 SCRIPTDIR=$(cd $(dirname $0) && pwd -P) 25source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
36else
37 SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P)
38fi
39METADIR="${SCRIPTDIR}/../.."
40 26
41if [ -e ${BUILDDIR}/conf/local.conf ]; then 27if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then
42 source $METADIR/poky/oe-init-build-env ${BUILDDIR} 28 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf
43else 29 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf
44 source $METADIR/poky/oe-init-build-env ${BUILDDIR} 30 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf
45 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf 31 echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf
46 cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf 32 echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf
47 cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf
48 echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf
49 echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf
50fi 33fi
51