summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bonnans <laurent.bonnans@here.com>2020-04-02 17:06:16 +0200
committerPatrick Vacek <patrickvacek@gmail.com>2020-04-29 12:35:56 +0200
commit0344e1db1262084bea7cd1289254e198d6de95a0 (patch)
tree0c33914788bf1e853ec53f2627f2ca3dd970d893
parent4b81ab1e4af714af61e5311c5868deb6558831a6 (diff)
downloadmeta-updater-0344e1db1262084bea7cd1289254e198d6de95a0.tar.gz
Fix envsetup when run in zsh
Now also works with zsh < 5.5 Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
-rwxr-xr-xscripts/envsetup.sh32
1 files changed, 22 insertions, 10 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
index a7ee877..c12f193 100755
--- a/scripts/envsetup.sh
+++ b/scripts/envsetup.sh
@@ -6,15 +6,23 @@ BUILDDIR="build"
6DISTRO="poky-sota-systemd" 6DISTRO="poky-sota-systemd"
7BASE_CONF="local.conf.base.append" 7BASE_CONF="local.conf.base.append"
8 8
9if [ -n "$ZSH_VERSION" ]; then
10 # be more compatible with bash
11 setopt shwordsplit
12fi
13
9# A definition of a dictionary with a list of configuration files that must be appended 14# 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. 15# to resulting conf/local.conf file for each particular distribution.
11declare -A supported_distros=( 16declare -A supported_distros
12 ["poky-sota-systemd"]="local.conf.systemd.append" 17supported_distros[poky-sota-systemd]="local.conf.systemd.append"
13 ["poky-sota"]="local.conf.base.append" 18supported_distros[poky-sota]="local.conf.base.append"
14 ["poky"]="local.conf.systemd.append local.conf.nonostree.append" 19supported_distros[poky]="local.conf.systemd.append local.conf.nonostree.append"
15) 20
21usage () {
22 echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota | poky >]"
23}
16 24
17[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota | poky >]"; return 1; } 25[[ "$#" -lt 1 ]] && { usage; return 1; }
18[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; } 26[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; }
19[[ "$#" -eq 3 ]] && { DISTRO="$3"; } 27[[ "$#" -eq 3 ]] && { DISTRO="$3"; }
20 28
@@ -35,23 +43,27 @@ fi
35METADIR=${METADIR:-${SOURCEDIR}/../..} 43METADIR=${METADIR:-${SOURCEDIR}/../..}
36 44
37if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then 45if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then
38 declare -a DISTRO_CONFIGS=${supported_distros[$DISTRO]} 46 if [ -z "${supported_distros[$DISTRO]}" ]; then
39 [[ -n ${DISTRO_CONFIGS[@]} ]] && { echo "Using (${DISTRO_CONFIGS[*]}) for the specified distro '$DISTRO'"; } || { echo "The specified distro $DISTRO is not supported"; return 1; } 47 echo "The specified distro $DISTRO is not supported"
48 usage
49 return 1
50 fi
40 51
41 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 52 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
42 53
43 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf 54 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf
44 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf 55 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf
45 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf 56 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf
57
46 sed -e "s/##MACHINE##/$MACHINE/g" \ 58 sed -e "s/##MACHINE##/$MACHINE/g" \
47 -e "s/##DISTRO##/$DISTRO/g" \ 59 -e "s/##DISTRO##/$DISTRO/g" \
48 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf 60 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf
49 61
50 for config in ${DISTRO_CONFIGS[@]}; do 62 for config in ${supported_distros[$DISTRO]}; do
51 if [[ "$BASE_CONF" != "$config" ]]; then 63 if [[ "$BASE_CONF" != "$config" ]]; then
52 cat "${METADIR}/meta-updater/conf/$config" >> conf/local.conf 64 cat "${METADIR}/meta-updater/conf/$config" >> conf/local.conf
53 fi 65 fi
54 done 66 done
55else 67else
56 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 68 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
57fi \ No newline at end of file 69fi