blob: c432946a52e0f50ef47491f0d51b02064a109050 [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 Geisslerf86b4a82019-09-27 15:21:11 -050038# witherspoon-tacoma|rainier
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 ;;
Andrew Geisslerf86b4a82019-09-27 15:21:11 -0500161 rainier)
162 LAYER_DIR="meta-ibm/meta-witherspoon"
163 MACHINE="rainier"
164 DISTRO="openbmc-openpower"
165 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930166 evb-ast2500)
Brad Bishop7161a172018-10-05 16:48:06 -0400167 LAYER_DIR="meta-evb/meta-evb-aspeed/meta-evb-ast2500"
Brad Bishop91a200b2019-08-22 14:24:33 -0400168 MACHINE="evb-ast2500"
169 DISTRO="openbmc-phosphor"
Joel Stanley0e077202016-06-28 16:42:45 +0930170 ;;
Ed Tanous6dc40d92018-07-30 11:13:36 -0700171 s2600wf)
Brad Bishop7161a172018-10-05 16:48:06 -0400172 LAYER_DIR="meta-intel/meta-s2600wf"
Brad Bishop91a200b2019-08-22 14:24:33 -0400173 MACHINE="s2600wf"
174 DISTRO="openbmc-phosphor"
Ed Tanous6dc40d92018-07-30 11:13:36 -0700175 ;;
Joel Stanley915381f2016-11-01 16:58:59 +1030176 zaius)
Brad Bishop7161a172018-10-05 16:48:06 -0400177 LAYER_DIR="meta-ingrasys/meta-zaius"
Brad Bishop91a200b2019-08-22 14:24:33 -0400178 MACHINE="zaius"
179 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030180 ;;
181 romulus)
Brad Bishop7161a172018-10-05 16:48:06 -0400182 LAYER_DIR="meta-ibm/meta-romulus"
Brad Bishop91a200b2019-08-22 14:24:33 -0400183 MACHINE="romulus"
184 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030185 ;;
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800186 tiogapass)
187 LAYER_DIR="meta-facebook/meta-tiogapass"
Brad Bishop91a200b2019-08-22 14:24:33 -0400188 MACHINE="tiogapass"
189 DISTRO="openbmc-phosphor"
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800190 ;;
Andrew Geissler9eef7282019-05-10 13:28:09 -0500191 gsj)
192 LAYER_DIR="meta-quanta/meta-gsj"
Brad Bishop91a200b2019-08-22 14:24:33 -0400193 MACHINE="gsj"
194 DISTRO="openbmc-phosphor"
Andrew Geissler9eef7282019-05-10 13:28:09 -0500195 ;;
Chris Smart02651712015-11-11 11:09:00 +1100196 *)
197 exit 1
198 ;;
199esac
200
Brad Bishop7161a172018-10-05 16:48:06 -0400201BITBAKE_CMD="TEMPLATECONF=${LAYER_DIR}/conf source oe-init-build-env"
202
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500203# Configure Docker build
Chris Smart02651712015-11-11 11:09:00 +1100204if [[ "${distro}" == fedora ]];then
205
206 if [[ -n "${http_proxy}" ]]; then
207 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
208 fi
209
210 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600211 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100212
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500213 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100214
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500215 # Set the locale
216 RUN locale-gen en_US.UTF-8
217 ENV LANG en_US.UTF-8
218 ENV LANGUAGE en_US:en
219 ENV LC_ALL en_US.UTF-8
Saqib Khan75635122017-03-23 10:57:34 -0500220
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500221 RUN dnf --refresh install -y \
222 bzip2 \
223 chrpath \
224 cpio \
225 diffstat \
226 findutils \
227 gcc \
228 gcc-c++ \
229 git \
230 make \
231 patch \
232 perl-bignum \
233 perl-Data-Dumper \
234 perl-Thread-Queue \
235 python-devel \
236 python3-devel \
237 SDL-devel \
238 socat \
239 subversion \
240 tar \
241 texinfo \
242 wget \
Saqib Khan5158a322017-10-23 11:31:24 -0500243 which \
244 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100245
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500246 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
247 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smart02651712015-11-11 11:09:00 +1100248
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500249 USER ${USER}
250 ENV HOME ${HOME}
251 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100252EOF
253)
254
Alanny Lopezccc650e2017-04-24 15:14:20 -0500255elif [[ "${distro}" == ubuntu ]]; then
256
Chris Smart02651712015-11-11 11:09:00 +1100257 if [[ -n "${http_proxy}" ]]; then
258 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
259 fi
260
261 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600262 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100263
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500264 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100265
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500266 ENV DEBIAN_FRONTEND noninteractive
Saqib Khan75635122017-03-23 10:57:34 -0500267
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500268 RUN apt-get update && apt-get install -yy \
269 build-essential \
270 chrpath \
271 debianutils \
272 diffstat \
273 gawk \
274 git \
275 libdata-dumper-simple-perl \
276 libsdl1.2-dev \
277 libthread-queue-any-perl \
Alanny Lopez27af3a02017-05-26 10:49:06 -0500278 locales \
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500279 python \
280 python3 \
281 socat \
282 subversion \
283 texinfo \
284 cpio \
Saqib Khan5158a322017-10-23 11:31:24 -0500285 wget \
286 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100287
Alanny Lopez27af3a02017-05-26 10:49:06 -0500288 # Set the locale
289 RUN locale-gen en_US.UTF-8
290 ENV LANG en_US.UTF-8
291 ENV LANGUAGE en_US:en
292 ENV LC_ALL en_US.UTF-8
293
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500294 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
295 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smartd30c5902016-03-01 15:00:54 +1100296
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500297 USER ${USER}
298 ENV HOME ${HOME}
299 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100300EOF
301)
302fi
303
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500304# Create the Docker run script
Chris Smart02651712015-11-11 11:09:00 +1100305export PROXY_HOST=${http_proxy/#http*:\/\/}
306export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
307export PROXY_PORT=${http_proxy/#http*:\/\/*:}
308
Chris Smart01d2b962015-11-11 18:05:30 +1100309mkdir -p ${WORKSPACE}
Chris Smart02651712015-11-11 11:09:00 +1100310
Andrew Geissler215e43c2019-04-23 10:57:48 -0500311# Determine command for bitbake image build
Andrew Geissler215e43c2019-04-23 10:57:48 -0500312if [ $no_tar = "false" ]; then
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500313 bitbake_target="${bitbake_target} obmc-phosphor-debug-tarball"
Andrew Geissler215e43c2019-04-23 10:57:48 -0500314fi
315
Chris Smart01d2b962015-11-11 18:05:30 +1100316cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
Chris Smart02651712015-11-11 11:09:00 +1100317#!/bin/bash
318
Joel Stanley38c9d142016-02-16 12:31:55 +1030319set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +1100320
Alanny Lopez723fea62017-09-12 11:22:17 -0500321# Go into the OpenBMC directory, the build will handle changing directories
Alanny Lopez1246b032018-02-24 23:34:55 -0600322cd ${obmc_dir}
Chris Smart02651712015-11-11 11:09:00 +1100323
324# Set up proxies
325export ftp_proxy=${http_proxy}
326export http_proxy=${http_proxy}
327export https_proxy=${http_proxy}
328
Chris Smart01d2b962015-11-11 18:05:30 +1100329mkdir -p ${WORKSPACE}/bin
Chris Smart02651712015-11-11 11:09:00 +1100330
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500331# Configure proxies for BitBake
Chris Smart02651712015-11-11 11:09:00 +1100332if [[ -n "${http_proxy}" ]]; then
333
Chris Smartd30c5902016-03-01 15:00:54 +1100334 cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500335 #!/bin/bash
336 # \$1 = hostname, \$2 = port
337 PROXY=${PROXY_HOST}
338 PROXY_PORT=${PROXY_PORT}
339 exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100340EOF_GIT
341
Chris Smart01d2b962015-11-11 18:05:30 +1100342 chmod a+x ${WORKSPACE}/bin/git-proxy
343 export PATH=${WORKSPACE}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
Chris Smart02651712015-11-11 11:09:00 +1100344 git config core.gitProxy git-proxy
345
346 mkdir -p ~/.subversion
347
348 cat > ~/.subversion/servers << EOF_SVN
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500349 [global]
350 http-proxy-host = ${PROXY_HOST}
351 http-proxy-port = ${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100352EOF_SVN
353fi
354
355# Source our build env
356${BITBAKE_CMD}
357
Santosh Puranikf70e12b2019-09-04 15:29:24 +0530358if [[ -z "${MACHINE}" || -z "${DISTRO}" ]]; then
Brad Bishop91a200b2019-08-22 14:24:33 -0400359 echo "MACHINE or DISTRO is not configured for ${target}"
360 exit 1
Michael Shepos2de03e92018-11-07 15:54:56 -0600361fi
362
Brad Bishop91a200b2019-08-22 14:24:33 -0400363export MACHINE="${MACHINE}"
364export DISTRO="${DISTRO}"
365
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500366# Custom BitBake config settings
Chris Smart02651712015-11-11 11:09:00 +1100367cat >> conf/local.conf << EOF_CONF
Chris Smartc650c202015-11-25 15:58:53 +1100368BB_NUMBER_THREADS = "$(nproc)"
369PARALLEL_MAKE = "-j$(nproc)"
Chris Smart02651712015-11-11 11:09:00 +1100370INHERIT += "rm_work"
371BB_GENERATE_MIRROR_TARBALLS = "1"
Alanny Lopez1246b032018-02-24 23:34:55 -0600372DL_DIR="${ssc_dir}/bitbake_downloads"
373SSTATE_DIR="${ssc_dir}/bitbake_sharedstatecache"
Chris Smart02651712015-11-11 11:09:00 +1100374USER_CLASSES += "buildstats"
Andrew Geissler931ec672016-08-11 13:10:05 -0500375INHERIT_remove = "uninative"
Alanny Lopez1246b032018-02-24 23:34:55 -0600376TMPDIR="${build_dir}"
Chris Smart02651712015-11-11 11:09:00 +1100377EOF_CONF
378
379# Kick off a build
Michael Shepos33aeca42019-06-13 02:36:17 -0500380if [[ -n "${nice_priority}" ]]; then
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500381 nice -${nice_priority} bitbake ${BITBAKE_OPTS} ${bitbake_target}
Michael Shepos33aeca42019-06-13 02:36:17 -0500382else
Andrew Geissler2eb45d32019-09-18 21:56:44 -0500383 bitbake ${BITBAKE_OPTS} ${bitbake_target}
Michael Shepos33aeca42019-06-13 02:36:17 -0500384fi
Chris Smart02651712015-11-11 11:09:00 +1100385
Alanny Lopez1246b032018-02-24 23:34:55 -0600386# Copy internal build directory into xtrct_path directory
Charles Paul Hoferb249c2c2018-09-12 12:15:13 -0500387if [[ ${xtrct_small_copy_dir} ]]; then
388 mkdir -p ${xtrct_path}/${xtrct_small_copy_dir}
389 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/${xtrct_small_copy_dir}/* ${xtrct_path}/${xtrct_small_copy_dir}
390else
391 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path}
392fi
Charles Paul Hoferbe8700e2018-09-05 09:28:08 -0500393
394if [[ 0 -ne $? ]]; then
395 echo "Received a non-zero exit code from timeout"
396 exit 1
397fi
398
Chris Smart02651712015-11-11 11:09:00 +1100399EOF_SCRIPT
400
401chmod a+x ${WORKSPACE}/build.sh
402
Alanny Lopez51186882017-08-01 16:14:41 -0500403# Give the Docker image a name based on the distro,tag,arch,and target
Alanny Lopez1246b032018-02-24 23:34:55 -0600404img_name=${img_name:-openbmc/${distro}:${img_tag}-${target}-${ARCH}}
Alanny Lopez51186882017-08-01 16:14:41 -0500405
406# Build the Docker image
Alanny Lopez1246b032018-02-24 23:34:55 -0600407docker build -t ${img_name} - <<< "${Dockerfile}"
Alanny Lopez51186882017-08-01 16:14:41 -0500408
Michael Shepos3939e952019-01-16 16:00:35 -0600409# If obmc_dir or ssc_dir are ${HOME} or a subdirectory they will not be mounted
410mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" "
411mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" "
412if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then
413mount_obmc_dir=""
Alanny Lopez3fbaa512017-04-24 15:46:52 -0500414fi
Michael Shepos3939e952019-01-16 16:00:35 -0600415if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then
416mount_ssc_dir=""
417fi
418
419# Run the Docker container, execute the build.sh script
420docker run \
421--cap-add=sys_admin \
Michael Shepos33aeca42019-06-13 02:36:17 -0500422--cap-add=sys_nice \
Michael Shepos3939e952019-01-16 16:00:35 -0600423--net=host \
424--rm=true \
425-e WORKSPACE=${WORKSPACE} \
426-w "${HOME}" \
427-v "${HOME}":"${HOME}" \
428${mount_obmc_dir} \
429${mount_ssc_dir} \
430--cpus="$num_cpu" \
431-t ${img_name} \
432${WORKSPACE}/build.sh
Chris Smart02651712015-11-11 11:09:00 +1100433
Alanny Lopezd32d3322017-07-18 15:21:39 -0500434# To maintain function of resources that used an older path, add a link
Alanny Lopez1246b032018-02-24 23:34:55 -0600435ln -sf ${xtrct_path}/deploy ${WORKSPACE}/deploy
Alanny Lopezd32d3322017-07-18 15:21:39 -0500436
Chris Smart02651712015-11-11 11:09:00 +1100437# Timestamp for build
Alanny Lopez0e8ad992017-06-19 15:45:23 -0500438echo "Build completed, $(date)"