summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcajun-rat <p@beta16.co.uk>2017-06-27 11:37:08 +0200
committerGitHub <noreply@github.com>2017-06-27 11:37:08 +0200
commit5d38a4f19b642a5793b79d0d8fb3a72ea84d18f8 (patch)
tree29976fc11edfa2c5c6680760e482034bfffa833d
parent45c155a67d3532ad32342fc512e8bf6341ab9e5d (diff)
parent0f40a9d48aeffeebccd01124f8e8c43b2e29883c (diff)
downloadmeta-updater-5d38a4f19b642a5793b79d0d8fb3a72ea84d18f8.tar.gz
Merge pull request #83 from advancedtelematic/bugfix/PRO-3330/build-script
Fix bash script path
-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