forked from MentorEmbedded/meta-mentor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-environment
79 lines (72 loc) · 2.8 KB
/
setup-environment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
if [ -z "$ZSH_NAME" ] && [ "x$0" = "x./setup-environment" ]; then
echo >&2 "Error: This script needs to be sourced. Please run as '. ./setup-environment'"
else
if [ -n "$BASH_SOURCE" ]; then
layerdir="`dirname $BASH_SOURCE`"
elif [ -n "$ZSH_NAME" ]; then
layerdir="`dirname $0`"
else
layerdir="`pwd`"
fi
layerdir=`readlink -f "$layerdir"`
if [ -f conf/local.conf -o -f conf/bblayers.conf ]; then
# Assuming we're already in the build dir
BUILDDIR=$PWD
else
BUILDDIR=$PWD/build
fi
for i in $(seq $#); do
arg="$(eval printf "%s" "\$$i")"
case "$arg" in
-b)
BUILDDIR="$(eval printf "%s" "\$$(expr $i + 1)")"
if [ -z "$BUILDDIR" ]; then
echo >&2 "-b requires an argument"
fi
;;
esac
done
OPTIONALLAYERS="${OPTIONALLAYERS:-mentor-private}"
EXCLUDEDLAYERS="$EXCLUDEDLAYERS"
# Customer directory layers handling (e.g. <customername>-custom)
if [ -e "$layerdir/../customer.conf" ] ; then
for CUSTOMER in $(cat $layerdir/../customer.conf) ; do
if [ -d "$CUSTOMER-custom" ] ; then
if [ -e "$CUSTOMER-custom/custom.conf" ] ; then
CUSTOMERLAYERS=`cat $CUSTOMER-custom/custom.conf | sed -e '/^[ ]*#/d'`
CUSTOMERLAYERS=`echo $CUSTOMERLAYERS | sed -e 's/\n//g'`
OPTIONALLAYERS="$OPTIONALLAYERS $CUSTOMERLAYERS"
unset CUSTOMERLAYERS
fi
fi
done
unset CUSTOMER
fi
# Hotfix layers handling
if [ -e "$layerdir/../hotfixes/hotfix.conf" ] ; then
HOTFIXES=`cat $layerdir/../hotfixes/hotfix.conf | sed -e '/^[ ]*#/d'`
HOTFIXES=`echo $HOTFIXES | sed -e 's/\n//g'`
OPTIONALLAYERS="$OPTIONALLAYERS $HOTFIXES"
unset HOTFIXES
fi
# Extra layers handling
if [ -e "$layerdir/../xlayers.conf" ] ; then
EXTRALAYERS=`cat $layerdir/../xlayers.conf | sed -e '/^[ ]*#/d'`
EXTRALAYERS=`echo $EXTRALAYERS | sed -e 's/\n//g'`
OPTIONALLAYERS="$OPTIONALLAYERS $EXTRALAYERS"
unset EXTRALAYERS
fi
OPTIONALLAYERS="$OPTIONALLAYERS" EXTRAMELLAYERS="$EXTRAMELLAYERS" EXCLUDEDLAYERS="$EXCLUDEDLAYERS" $layerdir/scripts/setup-mel-builddir "$@" && \
[ -n "$BUILDDIR" ] && [ -e "$BUILDDIR" ] && \
. $BUILDDIR/setup-environment
unset EXTRAMELLAYERS
unset OPTIONALLAYERS
unset EXCLUDEDLAYERS
unset layerdir
CONFIGURED_LAYERS=`sed -n -e '/^BBLAYERS = /,/^"/{ /^BBLAYERS =/d; /^"/d; p;}' $BUILDDIR/conf/bblayers.conf | awk {'print $1'}`
for layers in $CONFIGURED_LAYERS; do
if [ -e $layers/post-setup-environment ]; then
. $layers/post-setup-environment
fi
done
fi