-
Notifications
You must be signed in to change notification settings - Fork 277
/
openbmc-init-build-env
197 lines (178 loc) · 5.55 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
if [ -n "$BBPATH" ]; then
echo "WARNING: Environment already set up for $BBPATH"
return 1
fi
if [ -n "$DISTRO_OVERRIDE" ]; then
echo "WARNING: distro is set to ${DISTRO_OVERRIDE} based on DISTRO_OVERRIDE env variable"
fi
DISTRO_DEFAULT=lf-master
declare -a PLAT_DISTRO_OVERRIDES
# Add overrides here on a per-platform basis.
#
# NOTES:
# 1. Please keep in alphabetical order.
# 2. Please run "facebook/configerator_platforms_update.sh" and include
# all the auto-generated changes in the DIFF When platform distro is
# updated.
#
PLAT_DISTRO_OVERRIDES=(
# DON'T modify the next line! It is used as the anchor string in new-fblite.py
# master rolling-release platforms
meta-bletchley:lf-master
meta-catalina:lf-master
meta-clearcreek:lf-master
meta-elbert:lf-master
meta-fbal:lf-master
meta-fbdarwin:lf-master
meta-fbep:lf-master
meta-fbttn2:lf-master
meta-fby2-nd:lf-master
meta-fby35:lf-master
meta-fby3:lf-master
meta-fuji:lf-master
meta-grandcanyon:lf-master
meta-grandteton:lf-master
meta-greatlakes-lf:lf-master
meta-greatlakes:lf-master
meta-gtartemis:lf-master
meta-halfdome:lf-master
meta-harma:lf-master
meta-inspirationpoint:lf-master
meta-janga:lf-master
meta-javaisland:lf-master
meta-meru:lf-master
meta-minerva:lf-master
meta-minipack:lf-master
meta-morgan800cc:lf-master
meta-montblanc:lf-master
meta-qemux86:lf-master
meta-tahan:lf-master
meta-ventura:lf-master
meta-waimeacanyon:lf-master
meta-yosemite4:lf-master
# dunfell platforms (pending upgrade)
meta-cmm:lf-dunfell
meta-fbsp:lf-dunfell
meta-galaxy100:lf-dunfell
meta-wedge:lf-dunfell
meta-wedge100:lf-dunfell
meta-wedge400:lf-dunfell
meta-yamp:lf-dunfell
# Legacy platforms pending kernel upgrade
meta-fbtp:rocko
meta-fbttn:rocko
meta-fby2:rocko
meta-fby2-gpv2:rocko
meta-lightning:rocko
meta-yosemite:rocko
# Below Network OpenBMC platforms are not widely deployed (prototype
# hardware, etc), but we will keep the entries until all the units are
# retired.
meta-churchillmono:lf-kirkstone
meta-cloudripper:lf-dunfell
meta-netlakemtp:lf-dunfell
meta-minilaketb:rocko
meta-sandia:lf-kirkstone
)
platform="$1"
if [ -z "$DISTRO_OVERRIDE" ]; then
_distro="${DISTRO_DEFAULT}"
else
_distro="${DISTRO_OVERRIDE}"
fi
if [ -n "${BASH_SOURCE[0]}" ]; 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/templates/default"
elif [ -d "$(pwd)/meta-$1" ]; then
TEMPLATECONF="$(pwd)/meta-$1/conf/templates/default"
else
machines=$(find . -maxdepth 6 \
'(' -path "./yocto/*" -o -path "./build-*" ')' -prune -o \
-path "./meta-*/machine/*.conf" '(' -type f -o -type l ')' \
-print )
for md in ${machines}; do
machine=$(basename "$md" | sed 's/\.conf//')
meta=$(dirname "$(dirname "$md")")
meta=$(echo "$meta" | sed 's/\.\///')
if [ "$machine" = "$platform" ]; then
TEMPLATECONF="$(pwd)/$meta/templates/default"
platform=$(basename "$(dirname "$meta")")
export MACHINE="${machine/-lf/}"
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 [ -z "${platform/${override_plat}/}" ]; 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)"
if [ -d "yocto/${_distro}/workaround-bin/" ]; then
PATH="$(realpath "yocto/${_distro}/workaround-bin"):$PATH"
fi
if [ -d "facebook/workaround-bin" ]; then
PATH="$(realpath facebook/workaround-bin):$PATH"
fi
# Old distros required going into the poky directory to find the poky metas,
# but lf-based distros have them in the yocto root. Some of the meta-phosphor
# recipes get confused if COREROOT is one level deeper.
case ${_distro} in
lf-*)
_poky=""
;;
*)
_poky="/poky"
;;
esac
# 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