forked from facebook/openbmc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
openbmc-init-build-env
61 lines (54 loc) · 1.6 KB
/
openbmc-init-build-env
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
#!/bin/bash
if [ -z "$DISTRO_DEFAULT" ]; then
DISTRO_DEFAULT=krogoth
else
echo "WARNING: distro is set to ${DISTRO_DEFAULT} based on DISTRO_DEFAULT env variable"
fi
declare -a DISTRO_OVERRIDES
#DISTRO_OVERRIDES=(meta-cmm:rocko)
platform="$1"
_distro="${DISTRO_DEFAULT}"
if [ -n "$BASH_SOURCE" ]; then
THIS_SCRIPT=$BASH_SOURCE
elif [ -n "$ZSH_NAME" ]; then
THIS_SCRIPT=$0
else
THIS_SCRIPT="$(pwd)/openbmc-init-build-env"
fi
if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT $@'"
exit 1
fi
unset THIS_SCRIPT
# Make sure specific BSP is set
if [ -z "$TEMPLATECONF" ]; then
if [ -z "$1" ]; then
echo "A specific BSP must be provided:"
echo "e.g.:"
echo " . openbmc-init-build-env meta-facebook/meta-wedge"
return 1
fi
if [ -d "$(pwd)/$1" ]; then
TEMPLATECONF="$(pwd)/$1/conf"
elif [ -d "$(pwd)/meta-$1" ]; then
TEMPLATECONF="$(pwd)/meta-$1/conf"
else
echo "Neither $(pwd)/$1 nor $(pwd)/meta-$1 exists"
return 1
fi
export TEMPLATECONF
shift 1
fi
for override in ${DISTRO_OVERRIDES[*]}; do
override_plat=${override%%:*}
override_distro=${override##*:}
if [[ "${platform/${override_plat}/}" != "${platform}" ]]; then
# override happens
_distro="${override_distro}"
fi
done
unset DISTRO_DEFAULT DISTRO_OVERRIDES
unset override override_plat override_distro
echo "Init build environment for platform '${platform}' with distro ${_distro}..."
unset platform
. yocto/${_distro}/poky/oe-init-build-env $@