blob: 1a2ee1c1291997d95b4af940b7d92adb5305b5ae [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
Alanny Lopeze08e8702018-02-24 18:07:13 -060038# Default: "qemu"
Andrew Geissler215e43c2019-04-23 10:57:48 -050039# no_tar Set to true if you do not want the debug tar built
40# Default: "false"
Michael Shepos33aeca42019-06-13 02:36:17 -050041# nice_priority Set nice priotity for bitbake command.
42# Nice:
43# Run with an adjusted niceness, which affects process
44# scheduling. Nice values range from -20 (most favorable
45# to the process) to 19 (least favorable to the process).
46# Default: "", nice is not used if nice_priority is not set
Alanny Lopez723fea62017-09-12 11:22:17 -050047#
Alanny Lopeze08e8702018-02-24 18:07:13 -060048# Deployment Variables:
Alanny Lopez1246b032018-02-24 23:34:55 -060049# obmc_dir Path of the OpenBMC repo directory used as a reference
Alanny Lopeze08e8702018-02-24 18:07:13 -060050# for the build inside the container.
51# Default: "${WORKSPACE}/openbmc"
Michael Shepos10afbb22019-02-06 13:33:07 -060052# xtrct_small_copy_dir
53# Directory within build_dir that should be copied to
54# xtrct_path. The directory and all parents up to, but not
55# including, build_dir will be copied. For example, if
56# build_dir is set to "/tmp/openbmc" and this is set to
57# "build/tmp", the directory at xtrct_path will have the
58# following directory structure:
59# xtrct_path
60# | - build
61# | - tmp
62# ...
63# Can also be set to the empty string to copy the entire
64# contents of build_dir to xtrct_path.
65# Default: "deploy/images".
Alanny Lopezb0a12dd2017-04-24 16:21:47 -050066#
67###############################################################################
Joel Stanley4b8b2392016-02-12 15:44:57 +103068# Trace bash processing. Set -e so when a step fails, we fail the build
Joel Stanley38c9d142016-02-16 12:31:55 +103069set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +110070
Alanny Lopez46967702018-02-25 00:29:14 -060071# Script Variables:
72build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
73http_proxy=${http_proxy:-}
74WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
Andrew Geisslerdc1e7022018-03-26 07:54:48 -070075num_cpu=${num_cpu:-$(nproc)}
Alanny Lopez46967702018-02-25 00:29:14 -060076
77# Docker Image Build Variables:
78build_dir=${build_dir:-/tmp/openbmc}
Chris Smart02651712015-11-11 11:09:00 +110079distro=${distro:-ubuntu}
Alanny Lopez1246b032018-02-24 23:34:55 -060080img_tag=${img_tag:-latest}
Alanny Lopez46967702018-02-25 00:29:14 -060081target=${target:-qemu}
Andrew Geissler215e43c2019-04-23 10:57:48 -050082no_tar=${no_tar:-false}
Michael Shepos33aeca42019-06-13 02:36:17 -050083nice_priority=${nice_priority:-}
Alanny Lopez46967702018-02-25 00:29:14 -060084
85# Deployment variables
Alanny Lopez46967702018-02-25 00:29:14 -060086obmc_dir=${obmc_dir:-${WORKSPACE}/openbmc}
Michael Shepos3939e952019-01-16 16:00:35 -060087ssc_dir=${HOME}
Michael Shepos10afbb22019-02-06 13:33:07 -060088xtrct_small_copy_dir=${xtrct_small_copy_dir:-deploy/images}
Michael Shepos3939e952019-01-16 16:00:35 -060089xtrct_path="${obmc_dir}/build/tmp"
90xtrct_copy_timeout="300"
Alanny Lopez46967702018-02-25 00:29:14 -060091
Chris Smartc3522542016-02-16 11:59:36 +110092PROXY=""
Chris Smart02651712015-11-11 11:09:00 +110093
Alanny Lopezccc650e2017-04-24 15:14:20 -050094# Determine the architecture
95ARCH=$(uname -m)
96
97# Determine the prefix of the Dockerfile's base image
98case ${ARCH} in
99 "ppc64le")
100 DOCKER_BASE="ppc64le/"
101 ;;
102 "x86_64")
103 DOCKER_BASE=""
104 ;;
105 *)
106 echo "Unsupported system architecture(${ARCH}) found for docker image"
107 exit 1
108esac
Andrew Geissler11abbbe2016-08-14 19:39:47 -0500109
Chris Smart02651712015-11-11 11:09:00 +1100110# Timestamp for job
111echo "Build started, $(date)"
112
Alanny Lopez1246b032018-02-24 23:34:55 -0600113# If the obmc_dir directory doesn't exist clone it in
114if [ ! -d ${obmc_dir} ]; then
115 echo "Clone in openbmc master to ${obmc_dir}"
116 git clone https://github.com/openbmc/openbmc ${obmc_dir}
Andrew Geisslerc3c35202016-08-16 08:47:50 -0500117fi
118
Alanny Lopez1246b032018-02-24 23:34:55 -0600119# Make and chown the xtrct_path directory to avoid permission errors
120if [ ! -d ${xtrct_path} ]; then
121 mkdir -p ${xtrct_path}
Alanny Lopez723fea62017-09-12 11:22:17 -0500122fi
Alanny Lopez1246b032018-02-24 23:34:55 -0600123chown ${UID}:${GROUPS} ${xtrct_path}
Alanny Lopez723fea62017-09-12 11:22:17 -0500124
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500125# Work out what build target we should be running and set BitBake command
Michael Shepos2de03e92018-11-07 15:54:56 -0600126MACHINE=""
Chris Smart02651712015-11-11 11:09:00 +1100127case ${target} in
Chris Smart02651712015-11-11 11:09:00 +1100128 palmetto)
Brad Bishop7161a172018-10-05 16:48:06 -0400129 LAYER_DIR="meta-ibm/meta-palmetto"
Brad Bishop91a200b2019-08-22 14:24:33 -0400130 MACHINE="palmetto"
131 DISTRO="openbmc-openpower"
Chris Smart02651712015-11-11 11:09:00 +1100132 ;;
Adriana Kobylak4ec7db02019-05-07 12:44:30 -0500133 swift)
134 LAYER_DIR="meta-ibm/meta-witherspoon"
135 MACHINE="swift"
Brad Bishop91a200b2019-08-22 14:24:33 -0400136 DISTRO="openbmc-witherspoon"
Adriana Kobylak4ec7db02019-05-07 12:44:30 -0500137 ;;
Andrew Geisslerdd9e1962019-08-15 08:27:28 -0500138 mihawk)
139 LAYER_DIR="meta-ibm/meta-witherspoon"
140 MACHINE="mihawk"
Brad Bishop91a200b2019-08-22 14:24:33 -0400141 DISTRO="openbmc-witherspoon"
Andrew Geisslerdd9e1962019-08-15 08:27:28 -0500142 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930143 witherspoon)
Brad Bishop7161a172018-10-05 16:48:06 -0400144 LAYER_DIR="meta-ibm/meta-witherspoon"
Brad Bishop91a200b2019-08-22 14:24:33 -0400145 MACHINE="witherspoon"
146 DISTRO="openbmc-witherspoon"
Joel Stanley0e077202016-06-28 16:42:45 +0930147 ;;
Adriana Kobylakfcba1c32019-05-10 11:33:37 -0500148 witherspoon-128)
149 LAYER_DIR="meta-ibm/meta-witherspoon"
150 MACHINE="witherspoon-128"
Brad Bishop91a200b2019-08-22 14:24:33 -0400151 DISTRO="openbmc-witherspoon"
Adriana Kobylakfcba1c32019-05-10 11:33:37 -0500152 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930153 evb-ast2500)
Brad Bishop7161a172018-10-05 16:48:06 -0400154 LAYER_DIR="meta-evb/meta-evb-aspeed/meta-evb-ast2500"
Brad Bishop91a200b2019-08-22 14:24:33 -0400155 MACHINE="evb-ast2500"
156 DISTRO="openbmc-phosphor"
Joel Stanley0e077202016-06-28 16:42:45 +0930157 ;;
Ed Tanous6dc40d92018-07-30 11:13:36 -0700158 s2600wf)
Brad Bishop7161a172018-10-05 16:48:06 -0400159 LAYER_DIR="meta-intel/meta-s2600wf"
Brad Bishop91a200b2019-08-22 14:24:33 -0400160 MACHINE="s2600wf"
161 DISTRO="openbmc-phosphor"
Ed Tanous6dc40d92018-07-30 11:13:36 -0700162 ;;
Joel Stanley915381f2016-11-01 16:58:59 +1030163 zaius)
Brad Bishop7161a172018-10-05 16:48:06 -0400164 LAYER_DIR="meta-ingrasys/meta-zaius"
Brad Bishop91a200b2019-08-22 14:24:33 -0400165 MACHINE="zaius"
166 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030167 ;;
168 romulus)
Brad Bishop7161a172018-10-05 16:48:06 -0400169 LAYER_DIR="meta-ibm/meta-romulus"
Brad Bishop91a200b2019-08-22 14:24:33 -0400170 MACHINE="romulus"
171 DISTRO="openbmc-openpower"
Joel Stanley915381f2016-11-01 16:58:59 +1030172 ;;
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800173 tiogapass)
174 LAYER_DIR="meta-facebook/meta-tiogapass"
Brad Bishop91a200b2019-08-22 14:24:33 -0400175 MACHINE="tiogapass"
176 DISTRO="openbmc-phosphor"
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800177 ;;
Andrew Geissler9eef7282019-05-10 13:28:09 -0500178 gsj)
179 LAYER_DIR="meta-quanta/meta-gsj"
Brad Bishop91a200b2019-08-22 14:24:33 -0400180 MACHINE="gsj"
181 DISTRO="openbmc-phosphor"
Andrew Geissler9eef7282019-05-10 13:28:09 -0500182 ;;
Chris Smart02651712015-11-11 11:09:00 +1100183 *)
184 exit 1
185 ;;
186esac
187
Brad Bishop7161a172018-10-05 16:48:06 -0400188BITBAKE_CMD="TEMPLATECONF=${LAYER_DIR}/conf source oe-init-build-env"
189
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500190# Configure Docker build
Chris Smart02651712015-11-11 11:09:00 +1100191if [[ "${distro}" == fedora ]];then
192
193 if [[ -n "${http_proxy}" ]]; then
194 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
195 fi
196
197 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600198 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100199
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500200 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100201
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500202 # Set the locale
203 RUN locale-gen en_US.UTF-8
204 ENV LANG en_US.UTF-8
205 ENV LANGUAGE en_US:en
206 ENV LC_ALL en_US.UTF-8
Saqib Khan75635122017-03-23 10:57:34 -0500207
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500208 RUN dnf --refresh install -y \
209 bzip2 \
210 chrpath \
211 cpio \
212 diffstat \
213 findutils \
214 gcc \
215 gcc-c++ \
216 git \
217 make \
218 patch \
219 perl-bignum \
220 perl-Data-Dumper \
221 perl-Thread-Queue \
222 python-devel \
223 python3-devel \
224 SDL-devel \
225 socat \
226 subversion \
227 tar \
228 texinfo \
229 wget \
Saqib Khan5158a322017-10-23 11:31:24 -0500230 which \
231 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100232
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500233 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
234 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smart02651712015-11-11 11:09:00 +1100235
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500236 USER ${USER}
237 ENV HOME ${HOME}
238 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100239EOF
240)
241
Alanny Lopezccc650e2017-04-24 15:14:20 -0500242elif [[ "${distro}" == ubuntu ]]; then
243
Chris Smart02651712015-11-11 11:09:00 +1100244 if [[ -n "${http_proxy}" ]]; then
245 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
246 fi
247
248 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600249 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100250
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500251 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100252
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500253 ENV DEBIAN_FRONTEND noninteractive
Saqib Khan75635122017-03-23 10:57:34 -0500254
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500255 RUN apt-get update && apt-get install -yy \
256 build-essential \
257 chrpath \
258 debianutils \
259 diffstat \
260 gawk \
261 git \
262 libdata-dumper-simple-perl \
263 libsdl1.2-dev \
264 libthread-queue-any-perl \
Alanny Lopez27af3a02017-05-26 10:49:06 -0500265 locales \
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500266 python \
267 python3 \
268 socat \
269 subversion \
270 texinfo \
271 cpio \
Saqib Khan5158a322017-10-23 11:31:24 -0500272 wget \
273 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100274
Alanny Lopez27af3a02017-05-26 10:49:06 -0500275 # Set the locale
276 RUN locale-gen en_US.UTF-8
277 ENV LANG en_US.UTF-8
278 ENV LANGUAGE en_US:en
279 ENV LC_ALL en_US.UTF-8
280
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500281 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
282 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smartd30c5902016-03-01 15:00:54 +1100283
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500284 USER ${USER}
285 ENV HOME ${HOME}
286 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100287EOF
288)
289fi
290
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500291# Create the Docker run script
Chris Smart02651712015-11-11 11:09:00 +1100292export PROXY_HOST=${http_proxy/#http*:\/\/}
293export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
294export PROXY_PORT=${http_proxy/#http*:\/\/*:}
295
Chris Smart01d2b962015-11-11 18:05:30 +1100296mkdir -p ${WORKSPACE}
Chris Smart02651712015-11-11 11:09:00 +1100297
Andrew Geissler215e43c2019-04-23 10:57:48 -0500298# Determine command for bitbake image build
299bitbake_image="obmc-phosphor-image"
300if [ $no_tar = "false" ]; then
301 bitbake_image="${bitbake_image} obmc-phosphor-debug-tarball"
302fi
303
Chris Smart01d2b962015-11-11 18:05:30 +1100304cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
Chris Smart02651712015-11-11 11:09:00 +1100305#!/bin/bash
306
Joel Stanley38c9d142016-02-16 12:31:55 +1030307set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +1100308
Alanny Lopez723fea62017-09-12 11:22:17 -0500309# Go into the OpenBMC directory, the build will handle changing directories
Alanny Lopez1246b032018-02-24 23:34:55 -0600310cd ${obmc_dir}
Chris Smart02651712015-11-11 11:09:00 +1100311
312# Set up proxies
313export ftp_proxy=${http_proxy}
314export http_proxy=${http_proxy}
315export https_proxy=${http_proxy}
316
Chris Smart01d2b962015-11-11 18:05:30 +1100317mkdir -p ${WORKSPACE}/bin
Chris Smart02651712015-11-11 11:09:00 +1100318
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500319# Configure proxies for BitBake
Chris Smart02651712015-11-11 11:09:00 +1100320if [[ -n "${http_proxy}" ]]; then
321
Chris Smartd30c5902016-03-01 15:00:54 +1100322 cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500323 #!/bin/bash
324 # \$1 = hostname, \$2 = port
325 PROXY=${PROXY_HOST}
326 PROXY_PORT=${PROXY_PORT}
327 exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100328EOF_GIT
329
Chris Smart01d2b962015-11-11 18:05:30 +1100330 chmod a+x ${WORKSPACE}/bin/git-proxy
331 export PATH=${WORKSPACE}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
Chris Smart02651712015-11-11 11:09:00 +1100332 git config core.gitProxy git-proxy
333
334 mkdir -p ~/.subversion
335
336 cat > ~/.subversion/servers << EOF_SVN
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500337 [global]
338 http-proxy-host = ${PROXY_HOST}
339 http-proxy-port = ${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100340EOF_SVN
341fi
342
343# Source our build env
344${BITBAKE_CMD}
345
Santosh Puranikf70e12b2019-09-04 15:29:24 +0530346if [[ -z "${MACHINE}" || -z "${DISTRO}" ]]; then
Brad Bishop91a200b2019-08-22 14:24:33 -0400347 echo "MACHINE or DISTRO is not configured for ${target}"
348 exit 1
Michael Shepos2de03e92018-11-07 15:54:56 -0600349fi
350
Brad Bishop91a200b2019-08-22 14:24:33 -0400351export MACHINE="${MACHINE}"
352export DISTRO="${DISTRO}"
353
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500354# Custom BitBake config settings
Chris Smart02651712015-11-11 11:09:00 +1100355cat >> conf/local.conf << EOF_CONF
Chris Smartc650c202015-11-25 15:58:53 +1100356BB_NUMBER_THREADS = "$(nproc)"
357PARALLEL_MAKE = "-j$(nproc)"
Chris Smart02651712015-11-11 11:09:00 +1100358INHERIT += "rm_work"
359BB_GENERATE_MIRROR_TARBALLS = "1"
Alanny Lopez1246b032018-02-24 23:34:55 -0600360DL_DIR="${ssc_dir}/bitbake_downloads"
361SSTATE_DIR="${ssc_dir}/bitbake_sharedstatecache"
Chris Smart02651712015-11-11 11:09:00 +1100362USER_CLASSES += "buildstats"
Andrew Geissler931ec672016-08-11 13:10:05 -0500363INHERIT_remove = "uninative"
Alanny Lopez1246b032018-02-24 23:34:55 -0600364TMPDIR="${build_dir}"
Chris Smart02651712015-11-11 11:09:00 +1100365EOF_CONF
366
367# Kick off a build
Michael Shepos33aeca42019-06-13 02:36:17 -0500368if [[ -n "${nice_priority}" ]]; then
369 nice -${nice_priority} bitbake ${BITBAKE_OPTS} ${bitbake_image}
370else
371 bitbake ${BITBAKE_OPTS} ${bitbake_image}
372fi
Chris Smart02651712015-11-11 11:09:00 +1100373
Alanny Lopez1246b032018-02-24 23:34:55 -0600374# Copy internal build directory into xtrct_path directory
Charles Paul Hoferb249c2c2018-09-12 12:15:13 -0500375if [[ ${xtrct_small_copy_dir} ]]; then
376 mkdir -p ${xtrct_path}/${xtrct_small_copy_dir}
377 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/${xtrct_small_copy_dir}/* ${xtrct_path}/${xtrct_small_copy_dir}
378else
379 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path}
380fi
Charles Paul Hoferbe8700e2018-09-05 09:28:08 -0500381
382if [[ 0 -ne $? ]]; then
383 echo "Received a non-zero exit code from timeout"
384 exit 1
385fi
386
Chris Smart02651712015-11-11 11:09:00 +1100387EOF_SCRIPT
388
389chmod a+x ${WORKSPACE}/build.sh
390
Alanny Lopez51186882017-08-01 16:14:41 -0500391# Give the Docker image a name based on the distro,tag,arch,and target
Alanny Lopez1246b032018-02-24 23:34:55 -0600392img_name=${img_name:-openbmc/${distro}:${img_tag}-${target}-${ARCH}}
Alanny Lopez51186882017-08-01 16:14:41 -0500393
394# Build the Docker image
Alanny Lopez1246b032018-02-24 23:34:55 -0600395docker build -t ${img_name} - <<< "${Dockerfile}"
Alanny Lopez51186882017-08-01 16:14:41 -0500396
Michael Shepos3939e952019-01-16 16:00:35 -0600397# If obmc_dir or ssc_dir are ${HOME} or a subdirectory they will not be mounted
398mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" "
399mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" "
400if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then
401mount_obmc_dir=""
Alanny Lopez3fbaa512017-04-24 15:46:52 -0500402fi
Michael Shepos3939e952019-01-16 16:00:35 -0600403if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then
404mount_ssc_dir=""
405fi
406
407# Run the Docker container, execute the build.sh script
408docker run \
409--cap-add=sys_admin \
Michael Shepos33aeca42019-06-13 02:36:17 -0500410--cap-add=sys_nice \
Michael Shepos3939e952019-01-16 16:00:35 -0600411--net=host \
412--rm=true \
413-e WORKSPACE=${WORKSPACE} \
414-w "${HOME}" \
415-v "${HOME}":"${HOME}" \
416${mount_obmc_dir} \
417${mount_ssc_dir} \
418--cpus="$num_cpu" \
419-t ${img_name} \
420${WORKSPACE}/build.sh
Chris Smart02651712015-11-11 11:09:00 +1100421
Alanny Lopezd32d3322017-07-18 15:21:39 -0500422# To maintain function of resources that used an older path, add a link
Alanny Lopez1246b032018-02-24 23:34:55 -0600423ln -sf ${xtrct_path}/deploy ${WORKSPACE}/deploy
Alanny Lopezd32d3322017-07-18 15:21:39 -0500424
Chris Smart02651712015-11-11 11:09:00 +1100425# Timestamp for build
Alanny Lopez0e8ad992017-06-19 15:45:23 -0500426echo "Build completed, $(date)"