forked from facebook/openbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openbmc-init-build-env
139 lines (127 loc) · 3.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
if [ -n "$DISTRO_OVERRIDE" ]; then
echo "WARNING: distro is set to ${DISTRO_OVERRIDE} based on DISTRO_OVERRIDE env variable"
elif [ -z "$DISTRO_DEFAULT" ]; then
DISTRO_DEFAULT=zeus
else
echo "WARNING: default distro is set to ${DISTRO_DEFAULT} based on DISTRO_DEFAULT env variable"
fi
declare -a PLAT_DISTRO_OVERRIDES
# Add overrides here on a per-platform basis.
PLAT_DISTRO_OVERRIDES=(
# master / rolling-release platforms
# -- none --
# gatesgarth platforms (latest)
# -- none --
# dunfell platforms (pending upgrade)
# -- none --
meta-fby2-nd:lf-dunfell
# zeus platforms (pending upgrade)
meta-qemux86:zeus
meta-fbal:zeus
meta-fbep:zeus
meta-clearcreek:zeus
meta-fbsp:zeus
meta-fby3:zeus
meta-grandcanyon:zeus
meta-cmm:zeus
meta-elbert:zeus
meta-cloudripper:zeus
meta-fuji:zeus
meta-minipack:zeus
meta-wedge400:zeus
# warrior platforms (pending upgrade)
# -- none --
# Legacy platforms pending kernel upgrade
meta-fby2-gpv2:rocko
meta-fby2:rocko
meta-yosemite:rocko
meta-fbtp:rocko
meta-fbttn:rocko
meta-wedge:rocko
meta-minilaketb:rocko
meta-yamp:rocko
meta-lightning:rocko
meta-wedge100:rocko
meta-galaxy100:rocko
)
platform="$1"
if [ -z "$DISTRO_OVERRIDE" ]; then
_distro="${DISTRO_DEFAULT}"
else
_distro="${DISTRO_OVERRIDE}"
fi
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
# This script relies on bash-like word splitting, so enable it in zsh.
if [ -n "$ZSH_NAME" ]; then
setopt sh_word_split
fi
# 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
machines=$(find . -maxdepth 6 -path "*/machine/*" '(' -type f -o -type l ')' )
for md in ${machines}; do
machine=$(basename "$md" | sed 's/\.conf//')
meta=$(dirname "$(dirname "$md")")
meta=$(echo "$meta" | sed 's/\.\///')
if [ "x$machine" = "x$platform" ]; then
TEMPLATECONF="$(pwd)/$meta"
platform=$(basename "$(dirname "$meta")")
break
fi
done
if [ -z "$TEMPLATECONF" ]; then
echo "Neither $(pwd)/$1 nor $(pwd)/meta-$1 exists"
return 1
fi
fi
export TEMPLATECONF
shift 1
fi
# If user is not overriding the distro, then see
# if there are platform overrides.
if [ -z "$DISTRO_OVERRIDE" ]; then
for override in ${PLAT_DISTRO_OVERRIDES[*]}; do
override_plat=${override%%:*}
override_distro=${override##*:}
if [[ "${platform/${override_plat}/}" != "${platform}" ]]; then
# override happens
_distro="${override_distro}"
break
fi
done
fi
unset DISTRO_DEFAULT PLAT_DISTRO_OVERRIDES DISTRO_OVERRIDE
unset override override_plat override_distro
echo "Init build environment for platform '${platform}' with distro ${_distro}..."
unset platform
# Sourcing the Yocto script causes the pwd to change to the build directory.
# Keep it around so that we can source scripts out of our tree afterward.
REPO_ROOT="$(pwd)"
# shellcheck disable=SC1090
# distro can vary, so we can't use a shellcheck directive to point to next
. "yocto/${_distro}/poky/oe-init-build-env" "$@"
if [ -d "${REPO_ROOT}/facebook" ]; then
"${REPO_ROOT}/facebook/facebookify.sh" "$(pwd)"
fi