blob: 5e02f50b4d027857a4db100bba6945bd38f9ac74 [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 Geissler9eef7282019-05-10 13:28:09 -050037# romulus|s2600wf|witherspoon|zaius|tiogapass|gsj
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"
Chris Smart02651712015-11-11 11:09:00 +1100130 ;;
Adriana Kobylak4ec7db02019-05-07 12:44:30 -0500131 swift)
132 LAYER_DIR="meta-ibm/meta-witherspoon"
133 MACHINE="swift"
134 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930135 witherspoon)
Brad Bishop7161a172018-10-05 16:48:06 -0400136 LAYER_DIR="meta-ibm/meta-witherspoon"
Joel Stanley0e077202016-06-28 16:42:45 +0930137 ;;
Adriana Kobylakfcba1c32019-05-10 11:33:37 -0500138 witherspoon-128)
139 LAYER_DIR="meta-ibm/meta-witherspoon"
140 MACHINE="witherspoon-128"
141 ;;
Joel Stanley0e077202016-06-28 16:42:45 +0930142 evb-ast2500)
Brad Bishop7161a172018-10-05 16:48:06 -0400143 LAYER_DIR="meta-evb/meta-evb-aspeed/meta-evb-ast2500"
Joel Stanley0e077202016-06-28 16:42:45 +0930144 ;;
Ed Tanous6dc40d92018-07-30 11:13:36 -0700145 s2600wf)
Brad Bishop7161a172018-10-05 16:48:06 -0400146 LAYER_DIR="meta-intel/meta-s2600wf"
Ed Tanous6dc40d92018-07-30 11:13:36 -0700147 ;;
Joel Stanley915381f2016-11-01 16:58:59 +1030148 zaius)
Brad Bishop7161a172018-10-05 16:48:06 -0400149 LAYER_DIR="meta-ingrasys/meta-zaius"
Joel Stanley915381f2016-11-01 16:58:59 +1030150 ;;
151 romulus)
Brad Bishop7161a172018-10-05 16:48:06 -0400152 LAYER_DIR="meta-ibm/meta-romulus"
Joel Stanley915381f2016-11-01 16:58:59 +1030153 ;;
Chris Smart02651712015-11-11 11:09:00 +1100154 qemu)
Brad Bishop7161a172018-10-05 16:48:06 -0400155 LAYER_DIR="meta-phosphor"
Michael Shepos2de03e92018-11-07 15:54:56 -0600156 # MACHINE defaults to `qemuarm` in this layer, no change necessary
Chris Smart02651712015-11-11 11:09:00 +1100157 ;;
Andrew Geisslerdd820722018-02-20 13:42:58 -0600158 qemux86-64)
Michael Shepos2de03e92018-11-07 15:54:56 -0600159 LAYER_DIR="meta-phosphor"
160 # MACHINE defaults to `qemuarm` in this layer, change to `qemux86-64`
161 MACHINE="qemux86-64"
Andrew Geisslerdd820722018-02-20 13:42:58 -0600162 ;;
Vijay Khemka4c5b12e2019-01-23 14:50:09 -0800163 tiogapass)
164 LAYER_DIR="meta-facebook/meta-tiogapass"
165 ;;
Andrew Geissler9eef7282019-05-10 13:28:09 -0500166 gsj)
167 LAYER_DIR="meta-quanta/meta-gsj"
168 ;;
Chris Smart02651712015-11-11 11:09:00 +1100169 *)
170 exit 1
171 ;;
172esac
173
Brad Bishop7161a172018-10-05 16:48:06 -0400174BITBAKE_CMD="TEMPLATECONF=${LAYER_DIR}/conf source oe-init-build-env"
175
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500176# Configure Docker build
Chris Smart02651712015-11-11 11:09:00 +1100177if [[ "${distro}" == fedora ]];then
178
179 if [[ -n "${http_proxy}" ]]; then
180 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
181 fi
182
183 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600184 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100185
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500186 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100187
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500188 # Set the locale
189 RUN locale-gen en_US.UTF-8
190 ENV LANG en_US.UTF-8
191 ENV LANGUAGE en_US:en
192 ENV LC_ALL en_US.UTF-8
Saqib Khan75635122017-03-23 10:57:34 -0500193
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500194 RUN dnf --refresh install -y \
195 bzip2 \
196 chrpath \
197 cpio \
198 diffstat \
199 findutils \
200 gcc \
201 gcc-c++ \
202 git \
203 make \
204 patch \
205 perl-bignum \
206 perl-Data-Dumper \
207 perl-Thread-Queue \
208 python-devel \
209 python3-devel \
210 SDL-devel \
211 socat \
212 subversion \
213 tar \
214 texinfo \
215 wget \
Saqib Khan5158a322017-10-23 11:31:24 -0500216 which \
217 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100218
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500219 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
220 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smart02651712015-11-11 11:09:00 +1100221
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500222 USER ${USER}
223 ENV HOME ${HOME}
224 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100225EOF
226)
227
Alanny Lopezccc650e2017-04-24 15:14:20 -0500228elif [[ "${distro}" == ubuntu ]]; then
229
Chris Smart02651712015-11-11 11:09:00 +1100230 if [[ -n "${http_proxy}" ]]; then
231 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
232 fi
233
234 Dockerfile=$(cat << EOF
Alanny Lopez1246b032018-02-24 23:34:55 -0600235 FROM ${DOCKER_BASE}${distro}:${img_tag}
Chris Smart02651712015-11-11 11:09:00 +1100236
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500237 ${PROXY}
Chris Smart02651712015-11-11 11:09:00 +1100238
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500239 ENV DEBIAN_FRONTEND noninteractive
Saqib Khan75635122017-03-23 10:57:34 -0500240
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500241 RUN apt-get update && apt-get install -yy \
242 build-essential \
243 chrpath \
244 debianutils \
245 diffstat \
246 gawk \
247 git \
248 libdata-dumper-simple-perl \
249 libsdl1.2-dev \
250 libthread-queue-any-perl \
Alanny Lopez27af3a02017-05-26 10:49:06 -0500251 locales \
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500252 python \
253 python3 \
254 socat \
255 subversion \
256 texinfo \
257 cpio \
Saqib Khan5158a322017-10-23 11:31:24 -0500258 wget \
259 iputils-ping
Chris Smart02651712015-11-11 11:09:00 +1100260
Alanny Lopez27af3a02017-05-26 10:49:06 -0500261 # Set the locale
262 RUN locale-gen en_US.UTF-8
263 ENV LANG en_US.UTF-8
264 ENV LANGUAGE en_US:en
265 ENV LC_ALL en_US.UTF-8
266
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500267 RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
268 RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
Chris Smartd30c5902016-03-01 15:00:54 +1100269
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500270 USER ${USER}
271 ENV HOME ${HOME}
272 RUN /bin/bash
Chris Smart02651712015-11-11 11:09:00 +1100273EOF
274)
275fi
276
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500277# Create the Docker run script
Chris Smart02651712015-11-11 11:09:00 +1100278export PROXY_HOST=${http_proxy/#http*:\/\/}
279export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
280export PROXY_PORT=${http_proxy/#http*:\/\/*:}
281
Chris Smart01d2b962015-11-11 18:05:30 +1100282mkdir -p ${WORKSPACE}
Chris Smart02651712015-11-11 11:09:00 +1100283
Andrew Geissler215e43c2019-04-23 10:57:48 -0500284# Determine command for bitbake image build
285bitbake_image="obmc-phosphor-image"
286if [ $no_tar = "false" ]; then
287 bitbake_image="${bitbake_image} obmc-phosphor-debug-tarball"
288fi
289
Chris Smart01d2b962015-11-11 18:05:30 +1100290cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
Chris Smart02651712015-11-11 11:09:00 +1100291#!/bin/bash
292
Joel Stanley38c9d142016-02-16 12:31:55 +1030293set -xeo pipefail
Chris Smart02651712015-11-11 11:09:00 +1100294
Alanny Lopez723fea62017-09-12 11:22:17 -0500295# Go into the OpenBMC directory, the build will handle changing directories
Alanny Lopez1246b032018-02-24 23:34:55 -0600296cd ${obmc_dir}
Chris Smart02651712015-11-11 11:09:00 +1100297
298# Set up proxies
299export ftp_proxy=${http_proxy}
300export http_proxy=${http_proxy}
301export https_proxy=${http_proxy}
302
Chris Smart01d2b962015-11-11 18:05:30 +1100303mkdir -p ${WORKSPACE}/bin
Chris Smart02651712015-11-11 11:09:00 +1100304
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500305# Configure proxies for BitBake
Chris Smart02651712015-11-11 11:09:00 +1100306if [[ -n "${http_proxy}" ]]; then
307
Chris Smartd30c5902016-03-01 15:00:54 +1100308 cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500309 #!/bin/bash
310 # \$1 = hostname, \$2 = port
311 PROXY=${PROXY_HOST}
312 PROXY_PORT=${PROXY_PORT}
313 exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100314EOF_GIT
315
Chris Smart01d2b962015-11-11 18:05:30 +1100316 chmod a+x ${WORKSPACE}/bin/git-proxy
317 export PATH=${WORKSPACE}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}
Chris Smart02651712015-11-11 11:09:00 +1100318 git config core.gitProxy git-proxy
319
320 mkdir -p ~/.subversion
321
322 cat > ~/.subversion/servers << EOF_SVN
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500323 [global]
324 http-proxy-host = ${PROXY_HOST}
325 http-proxy-port = ${PROXY_PORT}
Chris Smart02651712015-11-11 11:09:00 +1100326EOF_SVN
327fi
328
329# Source our build env
330${BITBAKE_CMD}
331
Adriana Kobylak62a1b102019-05-07 12:14:45 -0500332# Export MACHINE name when given for build target
Michael Shepos2de03e92018-11-07 15:54:56 -0600333if [[ -n "${MACHINE}" ]]; then
Adriana Kobylak62a1b102019-05-07 12:14:45 -0500334 export MACHINE="${MACHINE}"; export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE MACHINE"
Michael Shepos2de03e92018-11-07 15:54:56 -0600335fi
336
Alanny Lopezeaa2eae2017-04-24 14:55:07 -0500337# Custom BitBake config settings
Chris Smart02651712015-11-11 11:09:00 +1100338cat >> conf/local.conf << EOF_CONF
Chris Smartc650c202015-11-25 15:58:53 +1100339BB_NUMBER_THREADS = "$(nproc)"
340PARALLEL_MAKE = "-j$(nproc)"
Chris Smart02651712015-11-11 11:09:00 +1100341INHERIT += "rm_work"
342BB_GENERATE_MIRROR_TARBALLS = "1"
Alanny Lopez1246b032018-02-24 23:34:55 -0600343DL_DIR="${ssc_dir}/bitbake_downloads"
344SSTATE_DIR="${ssc_dir}/bitbake_sharedstatecache"
Chris Smart02651712015-11-11 11:09:00 +1100345USER_CLASSES += "buildstats"
Andrew Geissler931ec672016-08-11 13:10:05 -0500346INHERIT_remove = "uninative"
Alanny Lopez1246b032018-02-24 23:34:55 -0600347TMPDIR="${build_dir}"
Chris Smart02651712015-11-11 11:09:00 +1100348EOF_CONF
349
350# Kick off a build
Michael Shepos33aeca42019-06-13 02:36:17 -0500351if [[ -n "${nice_priority}" ]]; then
352 nice -${nice_priority} bitbake ${BITBAKE_OPTS} ${bitbake_image}
353else
354 bitbake ${BITBAKE_OPTS} ${bitbake_image}
355fi
Chris Smart02651712015-11-11 11:09:00 +1100356
Alanny Lopez1246b032018-02-24 23:34:55 -0600357# Copy internal build directory into xtrct_path directory
Charles Paul Hoferb249c2c2018-09-12 12:15:13 -0500358if [[ ${xtrct_small_copy_dir} ]]; then
359 mkdir -p ${xtrct_path}/${xtrct_small_copy_dir}
360 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/${xtrct_small_copy_dir}/* ${xtrct_path}/${xtrct_small_copy_dir}
361else
362 timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path}
363fi
Charles Paul Hoferbe8700e2018-09-05 09:28:08 -0500364
365if [[ 0 -ne $? ]]; then
366 echo "Received a non-zero exit code from timeout"
367 exit 1
368fi
369
Chris Smart02651712015-11-11 11:09:00 +1100370EOF_SCRIPT
371
372chmod a+x ${WORKSPACE}/build.sh
373
Alanny Lopez51186882017-08-01 16:14:41 -0500374# Give the Docker image a name based on the distro,tag,arch,and target
Alanny Lopez1246b032018-02-24 23:34:55 -0600375img_name=${img_name:-openbmc/${distro}:${img_tag}-${target}-${ARCH}}
Alanny Lopez51186882017-08-01 16:14:41 -0500376
377# Build the Docker image
Alanny Lopez1246b032018-02-24 23:34:55 -0600378docker build -t ${img_name} - <<< "${Dockerfile}"
Alanny Lopez51186882017-08-01 16:14:41 -0500379
Michael Shepos3939e952019-01-16 16:00:35 -0600380# If obmc_dir or ssc_dir are ${HOME} or a subdirectory they will not be mounted
381mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" "
382mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" "
383if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then
384mount_obmc_dir=""
Alanny Lopez3fbaa512017-04-24 15:46:52 -0500385fi
Michael Shepos3939e952019-01-16 16:00:35 -0600386if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then
387mount_ssc_dir=""
388fi
389
390# Run the Docker container, execute the build.sh script
391docker run \
392--cap-add=sys_admin \
Michael Shepos33aeca42019-06-13 02:36:17 -0500393--cap-add=sys_nice \
Michael Shepos3939e952019-01-16 16:00:35 -0600394--net=host \
395--rm=true \
396-e WORKSPACE=${WORKSPACE} \
397-w "${HOME}" \
398-v "${HOME}":"${HOME}" \
399${mount_obmc_dir} \
400${mount_ssc_dir} \
401--cpus="$num_cpu" \
402-t ${img_name} \
403${WORKSPACE}/build.sh
Chris Smart02651712015-11-11 11:09:00 +1100404
Alanny Lopezd32d3322017-07-18 15:21:39 -0500405# To maintain function of resources that used an older path, add a link
Alanny Lopez1246b032018-02-24 23:34:55 -0600406ln -sf ${xtrct_path}/deploy ${WORKSPACE}/deploy
Alanny Lopezd32d3322017-07-18 15:21:39 -0500407
Chris Smart02651712015-11-11 11:09:00 +1100408# Timestamp for build
Alanny Lopez0e8ad992017-06-19 15:45:23 -0500409echo "Build completed, $(date)"