blob: 632d71e7af320e999d55f4e644400fe056ee707c [file] [log] [blame]
Alanny Lopez56fc36a2017-07-27 13:55:44 -05001#!/bin/bash
Alanny Lopezb0a12dd2017-04-24 16:21:47 -05002###############################################################################
Chris Smart02651712015-11-11 11:09:00 +11003#
Michael Shepos3939e952019-01-16 16:00:35 -06004# This build script is for running the OpenBMC builds as Docker containers.
Alanny Lopez3fbaa512017-04-24 15:46:52 -05005#
Alanny Lopezb0a12dd2017-04-24 16:21:47 -05006###############################################################################
7#
Alanny Lopeze08e8702018-02-24 18:07:13 -06008# Script Variables:
9# build_scripts_dir The path of the openbmc-build-scripts directory.
10# Default: The directory containing this script
11# http_proxy The HTTP address of the proxy server to connect to.
12# Default: "", proxy is not setup if this is not set
13# WORKSPACE Path of the workspace directory where some intermediate
14# files and the images will be saved to.
15# Default: "~/{RandomNumber}"
Andrew Geisslerdc1e7022018-03-26 07:54:48 -070016# num_cpu Number of cpu's to give bitbake, default is total amount
17# in system
Alanny Lopezb0a12dd2017-04-24 16:21:47 -050018#
Alanny Lopeze08e8702018-02-24 18:07:13 -060019# Docker Image Build Variables:
Alanny Lopez1246b032018-02-24 23:34:55 -060020# BITBAKE_OPTS Set to "-c populate_sdk" or whatever other BitBake options
Alanny Lopeze08e8702018-02-24 18:07:13 -060021# you'd like to pass into the build.
22# Default: "", no options set
Alanny Lopez1246b032018-02-24 23:34:55 -060023# build_dir Path where the actual BitBake build occurs inside the
Alanny Lopeze08e8702018-02-24 18:07:13 -060024# container, path cannot be located on network storage.
25# Default: "/tmp/openbmc"
26# distro The distro used as the base image for the build image:
27# fedora|ubuntu
28# Default: "ubuntu"
Alanny Lopez1246b032018-02-24 23:34:55 -060029# img_name The name given to the target build's docker image.
Alanny Lopeze08e8702018-02-24 18:07:13 -060030# Default: "openbmc/${distro}:${imgtag}-${target}-${ARCH}"
Alanny Lopez1246b032018-02-24 23:34:55 -060031# img_tag The base docker image distro tag:
Alanny Lopeze08e8702018-02-24 18:07:13 -060032# ubuntu: latest|16.04|14.04|trusty|xenial
33# fedora: 23|24|25
34# Default: "latest"
35# target The target we aim to build:
Andrew Geisslerdd820722018-02-20 13:42:58 -060036# evb-ast2500|palmetto|qemu|qemux86-64
Andrew Geisslerdd9e1962019-08-15 08:27:28 -050037# romulus|s2600wf|witherspoon|zaius|tiogapass|gsj|mihawk
Andrew Geissler2eb45d32019-09-18 21:56:44 -050038# witherspoon-tacoma|
Alanny Lopeze08e8702018-02-24 18:07:13 -060039# Default: "qemu"
Andrew Geissler215e43c2019-04-23 10:57:48 -050040# no_tar Set to true if you do not want the debug tar built
41# Default: "false"
Michael Shepos33aeca42019-06-13 02:36:17 -050042# nice_priority Set nice priotity for bitbake command.
43# Nice:
44# Run with an adjusted niceness, which affects process
45# scheduling. Nice values range from -20 (most favorable
46# to the process) to 19 (least favorable to the process).
47# Default: "", nice is not used if nice_priority is not set
Alanny Lopez723fea62017-09-12 11:22:17 -050048#
Alanny Lopeze08e8702018-02-24 18:07:13 -060049# Deployment Variables:
Alanny Lopez1246b032018-02-24 23:34:55 -060050# obmc_dir Path of the OpenBMC repo directory used as a reference
Alanny Lopeze08e8702018-02-24 18:07:13 -060051# for the build inside the container.
52# Default: "${WORKSPACE}/openbmc"
Michael Shepos10afbb22019-02-06 13:33:07 -060053# xtrct_small_copy_dir
54# Directory within build_dir that should be copied to
55# xtrct_path. The directory and all parents up to, but not
56# including, build_dir will be copied. For example, if
57# build_dir is set to "/tmp/openbmc" and this is set to
58# "build/tmp", the directory at xtrct_path will have the
59# following directory structure:
60# xtrct_path
61# | - build
62# | - tmp
63# ...
64# Can also be set to the empty string to copy the entire
65# contents of build_dir to xtrct_path.
66# Default: "deploy/images".
Alanny Lopezb0a12dd2017-04-24 16:21:47 -050067#
68###############################################################################
Joel Stanley4b8b2392016-02-12 15:44:57 +103069# Trace bash processing. Set -e so when a step fails, we fail the build
Joel Stanley38c9d142016-02-16 12:31:55 +103070set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +110071
Alanny Lopez46967702018-02-25 00:29:14 -060072# Script Variables:
73build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
74http_proxy=${http_proxy:-}
75WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
Andrew Geisslerdc1e7022018-03-26 07:54:48 -070076num_cpu=${num_cpu:-$(nproc)}
Alanny Lopez46967702018-02-25 00:29:14 -060077
78# Docker Image Build Variables:
79build_dir=${build_dir:-/tmp/openbmc}
Chris Smart02651712015-11-11 11:09:00 +110080distro=${distro:-ubuntu}
Alanny Lopez1246b032018-02-24 23:34:55 -060081img_tag=${img_tag:-latest}
Alanny Lopez46967702018-02-25 00:29:14 -060082target=${target:-qemu}
Andrew Geissler215e43c2019-04-23 10:57:48 -050083no_tar=${no_tar:-false}
Michael Shepos33aeca42019-06-13 02:36:17 -050084nice_priority=${nice_priority:-}
Alanny Lopez46967702018-02-25 00:29:14 -060085
86# Deployment variables
Alanny Lopez46967702018-02-25 00:29:14 -060087obmc_dir=${obmc_dir:-${WORKSPACE}/openbmc}
Michael Shepos3939e952019-01-16 16:00:35 -060088ssc_dir=${HOME}
Michael Shepos10afbb22019-02-06 13:33:07 -060089xtrct_small_copy_dir=${xtrct_small_copy_dir:-deploy/images}
Michael Shepos3939e952019-01-16 16:00:35 -060090xtrct_path="${obmc_dir}/build/tmp"
91xtrct_copy_timeout="300"
Alanny Lopez46967702018-02-25 00:29:14 -060092
Andrew Geissler2eb45d32019-09-18 21:56:44 -050093bitbake_target="obmc-phosphor-image"
Chris Smartc3522542016-02-16 11:59:36 +110094PROXY=""
Chris Smart02651712015-11-11 11:09:00 +110095
Alanny Lopezccc650e2017-04-24 15:14:20 -050096# Determine the architecture
97ARCH=$(uname -m)
98
99# Determine the prefix of the Dockerfile's base image
100case ${ARCH} in
101 "ppc64le")
102 DOCKER_BASE="ppc64le/"
103 ;;
104 "x86_64")
105 DOCKER_BASE=""
106 ;;
107 *)
108 echo "Unsupported system architecture(${ARCH}) found for docker image"
109 exit 1
110esac
Andrew Geissler11abbbe2016-08-14 19:39:47 -0500111
Chris Smart02651712015-11-11 11:09:00 +1100112# Timestamp for job
113echo "Build started, $(date)"
114
Alanny Lopez1246b032018-02-24 23:34:55 -0600115# If the obmc_dir directory doesn't exist clone it in
116if [ ! -d ${obmc_dir} ]; then
117 echo "Clone in openbmc master to ${obmc_dir}"
118 git clone https://github.com/openbmc/openbmc ${obmc_dir}
Andrew Geisslerc3c35202016-08-16 08:47:50 -0500119fi
120
Alanny Lopez1246b032018-02-24 23:34:55 -0600121# Make and chown the xtrct_path directory to avoid permission errors
122if [ ! -d ${xtrct_path} ]; then
123 mkdir -p ${xtrct_path}
Alanny Lopez723fea62017-09-12 11:22:17 -0500124fi
Alanny Lopez1246b032018-02-24 23:34:55 -0600125chown ${UID}:${GROUPS} ${xtrct_path}
Alanny Lopez723fea62017-09-12 11:22:17 -0500126
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500127# Work out what build target we should be running and set BitBake command
Michael Shepos2de03e92018-11-07 15:54:56 -0600128MACHINE=""
Chris Smart02651712015-11-11 11:09:00 +1100129case ${target} in
Chris Smart02651712015-11-11 11:09:00 +1100130 palmetto)
Brad Bishop7161a172018-10-05 16:48:06 -0400131 LAYER_DIR="meta-ibm/meta-palmetto"
Brad Bishop91a200b2019-08-22 14:24:33 -0400132 MACHINE="palmetto"
133 DISTRO="openbmc-openpower"
Chris Smart02651712015-11-11 11:09:00 +1100134 ;;
Adriana Kobylak4ec7db02019-05-07 12:44:30 -0500135 swift)
136 LAYER_DIR="meta-ibm/meta-witherspoon"
137 MACHINE="swift"
Brad Bishop91a200b2019-08-22 14:24:33 -0400138 DISTRO="openbmc-witherspoon"
Adriana Kobylak4ec7db02019-05-07 12:44:30 -0500139 ;;
Andrew Geisslerdd9e1962019-08-15 08:27:28 -0500140 mihawk)
141 LAYER_DIR="meta-ibm/meta-witherspoon"
142 MACHINE="mihawk"
Brad Bishop91a200b2019-08-22 14:24:33 -0400143 DISTRO="openbmc-witherspoon"
Andrew Geisslerdd9e1962019-08-15 08:27:28 -0500144 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930145 witherspoon)
Brad Bishop7161a172018-10-05 16:48:06 -0400146 LAYER_DIR="meta-ibm/meta-witherspoon"
Brad Bishop91a200b2019-08-22 14:24:33 -0400147 MACHINE="witherspoon"
148 DISTRO="openbmc-witherspoon"
Joel Stanley0e077202016-06-28 16:42:45 +0930149 ;;
Adriana Kobylakfcba1c32019-05-10 11:33:37 -0500150 witherspoon-128)
151 LAYER_DIR="meta-ibm/meta-witherspoon"
152 MACHINE="witherspoon-128"
Brad Bishop91a200b2019-08-22 14:24:33 -0400153 DISTRO="openbmc-witherspoon"
Adriana Kobylakfcba1c32019-05-10 11:33:37 -0500154 ;;
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500155 witherspoon-tacoma)
156 LAYER_DIR="meta-ibm/meta-witherspoon"
157 MACHINE="witherspoon-tacoma"
158 DISTRO="openbmc-openpower"
159 bitbake_target="aspeed-image-norootfs"
160 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930161 evb-ast2500)
Brad Bishop7161a172018-10-05 16:48:06 -0400162 LAYER_DIR="meta-evb/meta-evb-aspeed/meta-evb-ast2500"
Brad Bishop91a200b2019-08-22 14:24:33 -0400163 MACHINE="evb-ast2500"
164 DISTRO="openbmc-phosphor"
Joel Stanley0e077202016-06-28 16:42:45 +0930165 ;;
Ed Tanous6dc40d92018-07-30 11:13:36 -0700166 s2600wf)
Brad Bishop7161a172018-10-05 16:48:06 -0400167 LAYER_DIR="meta-intel/meta-s2600wf"
Brad Bishop91a200b2019-08-22 14:24:33 -0400168 MACHINE="s2600wf"
169 DISTRO="openbmc-phosphor"
Ed Tanous6dc40d92018-07-30 11:13:36 -0700170 ;;
Joel Stanley915381f2016-11-01 16:58:59 +1030171 zaius)
Brad Bishop7161a172018-10-05 16:48:06 -0400172 LAYER_DIR="meta-ingrasys/meta-zaius"
Brad Bishop91a200b2019-08-22 14:24:33 -0400173 MACHINE="zaius"
174 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030175 ;;
176 romulus)
Brad Bishop7161a172018-10-05 16:48:06 -0400177 LAYER_DIR="meta-ibm/meta-romulus"
Brad Bishop91a200b2019-08-22 14:24:33 -0400178 MACHINE="romulus"
179 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030180 ;;
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800181 tiogapass)
182 LAYER_DIR="meta-facebook/meta-tiogapass"
Brad Bishop91a200b2019-08-22 14:24:33 -0400183 MACHINE="tiogapass"
184 DISTRO="openbmc-phosphor"
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800185 ;;
Andrew Geissler9eef7282019-05-10 13:28:09 -0500186 gsj)
187 LAYER_DIR="meta-quanta/meta-gsj"
Brad Bishop91a200b2019-08-22 14:24:33 -0400188 MACHINE="gsj"
189 DISTRO="openbmc-phosphor"
Andrew Geissler9eef7282019-05-10 13:28:09 -0500190 ;;
Chris Smart02651712015-11-11 11:09:00 +1100191 *)
192 exit 1
193 ;;
194esac
195
Brad Bishop7161a172018-10-05 16:48:06 -0400196BITBAKE_CMD="TEMPLATECONF=${LAYER_DIR}/conf source oe-init-build-env"
197
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500198# Configure Docker build
Chris Smart02651712015-11-11 11:09:00 +1100199if [[ "${distro}" == fedora ]];then
200
201 if [[ -n "${http_proxy}" ]]; then
202 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
203 fi
204
205 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600206 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100207
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500208 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100209
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500210 # Set the locale
211 RUN locale-gen en_US.UTF-8
212 ENV LANG en_US.UTF-8
213 ENV LANGUAGE en_US:en
214 ENV LC_ALL en_US.UTF-8
Saqib Khan75635122017-03-23 10:57:34 -0500215
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500216 RUN dnf --refresh install -y \
217 bzip2 \
218 chrpath \
219 cpio \
220 diffstat \
221 findutils \
222 gcc \
223 gcc-c++ \
224 git \
225 make \
226 patch \
227 perl-bignum \
228 perl-Data-Dumper \
229 perl-Thread-Queue \
230 python-devel \
231 python3-devel \
232 SDL-devel \
233 socat \
234 subversion \
235 tar \
236 texinfo \
237 wget \
Saqib Khan5158a322017-10-23 11:31:24 -0500238 which \
239 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100240
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500241 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
242 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smart02651712015-11-11 11:09:00 +1100243
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500244 USER ${USER}
245 ENV HOME ${HOME}
246 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100247EOF
248)
249
Alanny Lopezccc650e2017-04-24 15:14:20 -0500250elif [[ "${distro}" == ubuntu ]]; then
251
Chris Smart02651712015-11-11 11:09:00 +1100252 if [[ -n "${http_proxy}" ]]; then
253 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
254 fi
255
256 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600257 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100258
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500259 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100260
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500261 ENV DEBIAN_FRONTEND noninteractive
Saqib Khan75635122017-03-23 10:57:34 -0500262
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500263 RUN apt-get update && apt-get install -yy \
264 build-essential \
265 chrpath \
266 debianutils \
267 diffstat \
268 gawk \
269 git \
270 libdata-dumper-simple-perl \
271 libsdl1.2-dev \
272 libthread-queue-any-perl \
Alanny Lopez27af3a02017-05-26 10:49:06 -0500273 locales \
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500274 python \
275 python3 \
276 socat \
277 subversion \
278 texinfo \
279 cpio \
Saqib Khan5158a322017-10-23 11:31:24 -0500280 wget \
281 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100282
Alanny Lopez27af3a02017-05-26 10:49:06 -0500283 # Set the locale
284 RUN locale-gen en_US.UTF-8
285 ENV LANG en_US.UTF-8
286 ENV LANGUAGE en_US:en
287 ENV LC_ALL en_US.UTF-8
288
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500289 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
290 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smartd30c5902016-03-01 15:00:54 +1100291
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500292 USER ${USER}
293 ENV HOME ${HOME}
294 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100295EOF
296)
297fi
298
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500299# Create the Docker run script
Chris Smart02651712015-11-11 11:09:00 +1100300export PROXY_HOST=${http_proxy/#http*:\/\/}
301export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
302export PROXY_PORT=${http_proxy/#http*:\/\/*:}
303
Chris Smart01d2b962015-11-11 18:05:30 +1100304mkdir -p ${WORKSPACE}
Chris Smart02651712015-11-11 11:09:00 +1100305
Andrew Geissler215e43c2019-04-23 10:57:48 -0500306# Determine command for bitbake image build
Andrew Geissler215e43c2019-04-23 10:57:48 -0500307if [ $no_tar = "false" ]; then
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500308 bitbake_target="${bitbake_target} obmc-phosphor-debug-tarball"
Andrew Geissler215e43c2019-04-23 10:57:48 -0500309fi
310
Chris Smart01d2b962015-11-11 18:05:30 +1100311cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
Chris Smart02651712015-11-11 11:09:00 +1100312#!/bin/bash
313
Joel Stanley38c9d142016-02-16 12:31:55 +1030314set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +1100315
Alanny Lopez723fea62017-09-12 11:22:17 -0500316# Go into the OpenBMC directory, the build will handle changing directories
Alanny Lopez1246b032018-02-24 23:34:55 -0600317cd ${obmc_dir}
Chris Smart02651712015-11-11 11:09:00 +1100318
319# Set up proxies
320export ftp_proxy=${http_proxy}
321export http_proxy=${http_proxy}
322export https_proxy=${http_proxy}
323
Chris Smart01d2b962015-11-11 18:05:30 +1100324mkdir -p ${WORKSPACE}/bin
Chris Smart02651712015-11-11 11:09:00 +1100325
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500326# Configure proxies for BitBake
Chris Smart02651712015-11-11 11:09:00 +1100327if [[ -n "${http_proxy}" ]]; then
328
Chris Smartd30c5902016-03-01 15:00:54 +1100329 cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500330 #!/bin/bash
331 # \$1 = hostname, \$2 = port
332 PROXY=${PROXY_HOST}
333 PROXY_PORT=${PROXY_PORT}
334 exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100335EOF_GIT
336
Chris Smart01d2b962015-11-11 18:05:30 +1100337 chmod a+x ${WORKSPACE}/bin/git-proxy
338 export PATH=${WORKSPACE}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
Chris Smart02651712015-11-11 11:09:00 +1100339 git config core.gitProxy git-proxy
340
341 mkdir -p ~/.subversion
342
343 cat > ~/.subversion/servers << EOF_SVN
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500344 [global]
345 http-proxy-host = ${PROXY_HOST}
346 http-proxy-port = ${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100347EOF_SVN
348fi
349
350# Source our build env
351${BITBAKE_CMD}
352
Santosh Puranikf70e12b2019-09-04 15:29:24 +0530353if [[ -z "${MACHINE}" || -z "${DISTRO}" ]]; then
Brad Bishop91a200b2019-08-22 14:24:33 -0400354 echo "MACHINE or DISTRO is not configured for ${target}"
355 exit 1
Michael Shepos2de03e92018-11-07 15:54:56 -0600356fi
357
Brad Bishop91a200b2019-08-22 14:24:33 -0400358export MACHINE="${MACHINE}"
359export DISTRO="${DISTRO}"
360
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500361# Custom BitBake config settings
Chris Smart02651712015-11-11 11:09:00 +1100362cat >> conf/local.conf << EOF_CONF
Chris Smartc650c202015-11-25 15:58:53 +1100363BB_NUMBER_THREADS = "$(nproc)"
364PARALLEL_MAKE = "-j$(nproc)"
Chris Smart02651712015-11-11 11:09:00 +1100365INHERIT += "rm_work"
366BB_GENERATE_MIRROR_TARBALLS = "1"
Alanny Lopez1246b032018-02-24 23:34:55 -0600367DL_DIR="${ssc_dir}/bitbake_downloads"
368SSTATE_DIR="${ssc_dir}/bitbake_sharedstatecache"
Chris Smart02651712015-11-11 11:09:00 +1100369USER_CLASSES += "buildstats"
Andrew Geissler931ec672016-08-11 13:10:05 -0500370INHERIT_remove = "uninative"
Alanny Lopez1246b032018-02-24 23:34:55 -0600371TMPDIR="${build_dir}"
Chris Smart02651712015-11-11 11:09:00 +1100372EOF_CONF
373
374# Kick off a build
Michael Shepos33aeca42019-06-13 02:36:17 -0500375if [[ -n "${nice_priority}" ]]; then
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500376 nice -${nice_priority} bitbake ${BITBAKE_OPTS} ${bitbake_target}
Michael Shepos33aeca42019-06-13 02:36:17 -0500377else
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500378 bitbake ${BITBAKE_OPTS} ${bitbake_target}
Michael Shepos33aeca42019-06-13 02:36:17 -0500379fi
Chris Smart02651712015-11-11 11:09:00 +1100380
Alanny Lopez1246b032018-02-24 23:34:55 -0600381# Copy internal build directory into xtrct_path directory
Charles Paul Hoferb249c2c2018-09-12 12:15:13 -0500382if [[ ${xtrct_small_copy_dir} ]]; then
383 mkdir -p ${xtrct_path}/${xtrct_small_copy_dir}
384 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/${xtrct_small_copy_dir}/* ${xtrct_path}/${xtrct_small_copy_dir}
385else
386 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path}
387fi
Charles Paul Hoferbe8700e2018-09-05 09:28:08 -0500388
389if [[ 0 -ne $? ]]; then
390 echo "Received a non-zero exit code from timeout"
391 exit 1
392fi
393
Chris Smart02651712015-11-11 11:09:00 +1100394EOF_SCRIPT
395
396chmod a+x ${WORKSPACE}/build.sh
397
Alanny Lopez51186882017-08-01 16:14:41 -0500398# Give the Docker image a name based on the distro,tag,arch,and target
Alanny Lopez1246b032018-02-24 23:34:55 -0600399img_name=${img_name:-openbmc/${distro}:${img_tag}-${target}-${ARCH}}
Alanny Lopez51186882017-08-01 16:14:41 -0500400
401# Build the Docker image
Alanny Lopez1246b032018-02-24 23:34:55 -0600402docker build -t ${img_name} - <<< "${Dockerfile}"
Alanny Lopez51186882017-08-01 16:14:41 -0500403
Michael Shepos3939e952019-01-16 16:00:35 -0600404# If obmc_dir or ssc_dir are ${HOME} or a subdirectory they will not be mounted
405mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" "
406mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" "
407if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then
408mount_obmc_dir=""
Alanny Lopez3fbaa512017-04-24 15:46:52 -0500409fi
Michael Shepos3939e952019-01-16 16:00:35 -0600410if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then
411mount_ssc_dir=""
412fi
413
414# Run the Docker container, execute the build.sh script
415docker run \
416--cap-add=sys_admin \
Michael Shepos33aeca42019-06-13 02:36:17 -0500417--cap-add=sys_nice \
Michael Shepos3939e952019-01-16 16:00:35 -0600418--net=host \
419--rm=true \
420-e WORKSPACE=${WORKSPACE} \
421-w "${HOME}" \
422-v "${HOME}":"${HOME}" \
423${mount_obmc_dir} \
424${mount_ssc_dir} \
425--cpus="$num_cpu" \
426-t ${img_name} \
427${WORKSPACE}/build.sh
Chris Smart02651712015-11-11 11:09:00 +1100428
Alanny Lopezd32d3322017-07-18 15:21:39 -0500429# To maintain function of resources that used an older path, add a link
Alanny Lopez1246b032018-02-24 23:34:55 -0600430ln -sf ${xtrct_path}/deploy ${WORKSPACE}/deploy
Alanny Lopezd32d3322017-07-18 15:21:39 -0500431
Chris Smart02651712015-11-11 11:09:00 +1100432# Timestamp for build
Alanny Lopez0e8ad992017-06-19 15:45:23 -0500433echo "Build completed, $(date)"