summaryrefslogtreecommitdiffstats
path: root/scripts/envsetup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/envsetup.sh')
-rwxr-xr-xscripts/envsetup.sh33
1 files changed, 21 insertions, 12 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
index 19a5c94..a7ee877 100755
--- a/scripts/envsetup.sh
+++ b/scripts/envsetup.sh
@@ -5,17 +5,24 @@ MACHINE="$1"
5BUILDDIR="build" 5BUILDDIR="build"
6DISTRO="poky-sota-systemd" 6DISTRO="poky-sota-systemd"
7BASE_CONF="local.conf.base.append" 7BASE_CONF="local.conf.base.append"
8declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.systemd.append" ["poky-sota"]="local.conf.base.append" )
9 8
10[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; } 9# A definition of a dictionary with a list of configuration files that must be appended
10# to resulting conf/local.conf file for each particular distribution.
11declare -A supported_distros=(
12 ["poky-sota-systemd"]="local.conf.systemd.append"
13 ["poky-sota"]="local.conf.base.append"
14 ["poky"]="local.conf.systemd.append local.conf.nonostree.append"
15)
16
17[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota | poky >]"; return 1; }
11[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; } 18[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; }
12[[ "$#" -eq 3 ]] && { DISTRO="$3"; } 19[[ "$#" -eq 3 ]] && { DISTRO="$3"; }
13 20
14# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 21# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594
15SOURCED=0 22SOURCED=0
16if [ -n "$ZSH_EVAL_CONTEXT" ]; then 23if [[ -n "$ZSH_EVAL_CONTEXT" ]]; then
17 [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); } 24 [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); }
18elif [ -n "$BASH_VERSION" ]; then 25elif [[ -n "$BASH_VERSION" ]]; then
19 [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); } 26 [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); }
20fi 27fi
21 28
@@ -26,23 +33,25 @@ if [[ $SOURCED -ne 1 ]]; then
26fi 33fi
27 34
28METADIR=${METADIR:-${SOURCEDIR}/../..} 35METADIR=${METADIR:-${SOURCEDIR}/../..}
29DISTRO_CONF=${supported_distros[$DISTRO]}
30[[ -n $DISTRO_CONF ]] && { echo "Using $DISTRO_CONF for the specified distro $DISTRO"; } || { echo "The specified distro $DISTRO is not supported"; return 1; }
31 36
32if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then 37if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then
38 declare -a DISTRO_CONFIGS=${supported_distros[$DISTRO]}
39 [[ -n ${DISTRO_CONFIGS[@]} ]] && { echo "Using (${DISTRO_CONFIGS[*]}) for the specified distro '$DISTRO'"; } || { echo "The specified distro $DISTRO is not supported"; return 1; }
40
33 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 41 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
34 42
35 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf 43 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf
36 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf 44 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf
37 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf 45 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf
38
39 sed -e "s/##MACHINE##/$MACHINE/g" \ 46 sed -e "s/##MACHINE##/$MACHINE/g" \
40 -e "s/##DISTRO##/$DISTRO/g" \ 47 -e "s/##DISTRO##/$DISTRO/g" \
41 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf 48 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf
42 49
43 if [ "$BASE_CONF" != "$DISTRO_CONF" ]; then 50 for config in ${DISTRO_CONFIGS[@]}; do
44 cat "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf 51 if [[ "$BASE_CONF" != "$config" ]]; then
45 fi 52 cat "${METADIR}/meta-updater/conf/$config" >> conf/local.conf
53 fi
54 done
46else 55else
47 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 56 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
48fi 57fi \ No newline at end of file