Alanny Lopez | 56fc36a | 2017-07-27 13:55:44 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 2 | ############################################################################### |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 3 | # |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 4 | # This build script is for running the OpenBMC builds as containers with the |
| 5 | # option of launching the containers with Docker or Kubernetes. |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 6 | # |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 7 | ############################################################################### |
| 8 | # |
| 9 | # Variables used for Jenkins build job matrix: |
| 10 | # target = barreleye|palmetto|witherspoon|firestone|garrison|evb-ast2500 |
| 11 | # zaius|romulus|qemu |
| 12 | # distro = fedora|ubuntu |
| 13 | # imgtag = Varies by distro. latest|16.04|14.04|trusty|xenial; 23|24|25 |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 14 | # obmcext = Path of the OpenBMC repo directory used in creating a copy |
| 15 | # inside the container that is not mounted to external storage |
| 16 | # default directory location "${WORKSPACE}/openbmc" |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 17 | # builddir = Path of the OpenBMC directory where the build occurs inside |
| 18 | # the container, cannot be placed on external storage default |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 19 | # directory location "/tmp/openbmc" |
| 20 | # sscdir = Path of the BitBake shared-state cache directoy, will default |
| 21 | # to directory "/home/${USER}", used to speed up builds. |
| 22 | # WORKSPACE = Path of the workspace directory where some intermediate files |
| 23 | # and the images will be saved to. |
| 24 | # |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 25 | # extraction = Path where the ombcdir contents will be copied out to when |
| 26 | # the build completes. Defaults to ${obmcext}/build/tmp. |
| 27 | # |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 28 | # Optional Variables: |
| 29 | # launch = job|pod |
| 30 | # Can be left blank to launch via Docker if not using |
| 31 | # Kubernetes to launch the container. |
| 32 | # Job lets you keep a copy of job and container logs on the |
| 33 | # api, can be useful if not using Jenkins as you can run the |
| 34 | # job again via the api without needing this script. |
| 35 | # Pod launches a container which runs to completion without |
| 36 | # saving anything to the api when it completes. |
| 37 | # imgname = Defaults to a relatively long but descriptive name, can be |
| 38 | # changed or passed to give a specific name to created image. |
| 39 | # http_proxy = The HTTP address for the proxy server you wish to connect to. |
| 40 | # BITBAKE_OPTS = Set to "-c populate_sdk" or whatever other bitbake options |
| 41 | # you'd like to pass into the build. |
| 42 | # |
| 43 | ############################################################################### |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 44 | |
Joel Stanley | 4b8b239 | 2016-02-12 15:44:57 +1030 | [diff] [blame] | 45 | # Trace bash processing. Set -e so when a step fails, we fail the build |
Joel Stanley | 38c9d14 | 2016-02-16 12:31:55 +1030 | [diff] [blame] | 46 | set -xeo pipefail |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 47 | |
| 48 | # Default variables |
| 49 | target=${target:-qemu} |
| 50 | distro=${distro:-ubuntu} |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 51 | imgtag=${imgtag:-latest} |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 52 | builddir=${builddir:-/tmp/openbmc} |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 53 | sscdir=${sscdir:-${HOME}} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 54 | WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 55 | obmcext=${obmcext:-${WORKSPACE}/openbmc} |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 56 | extraction=${extraction:-${obmcext}/build/tmp} |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 57 | launch=${launch:-} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 58 | http_proxy=${http_proxy:-} |
Chris Smart | c352254 | 2016-02-16 11:59:36 +1100 | [diff] [blame] | 59 | PROXY="" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 60 | |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 61 | # Determine the architecture |
| 62 | ARCH=$(uname -m) |
| 63 | |
| 64 | # Determine the prefix of the Dockerfile's base image |
| 65 | case ${ARCH} in |
| 66 | "ppc64le") |
| 67 | DOCKER_BASE="ppc64le/" |
| 68 | ;; |
| 69 | "x86_64") |
| 70 | DOCKER_BASE="" |
| 71 | ;; |
| 72 | *) |
| 73 | echo "Unsupported system architecture(${ARCH}) found for docker image" |
| 74 | exit 1 |
| 75 | esac |
Andrew Geissler | 11abbbe | 2016-08-14 19:39:47 -0500 | [diff] [blame] | 76 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 77 | # Timestamp for job |
| 78 | echo "Build started, $(date)" |
| 79 | |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 80 | # If the obmcext directory doesn't exist clone it in |
| 81 | if [ ! -d ${obmcext} ]; then |
| 82 | echo "Clone in openbmc master to ${obmcext}" |
| 83 | git clone https://github.com/openbmc/openbmc ${obmcext} |
Andrew Geissler | c3c3520 | 2016-08-16 08:47:50 -0500 | [diff] [blame] | 84 | fi |
| 85 | |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 86 | # Make and chown the extraction directory to avoid permission errors |
| 87 | if [ ! -d ${extraction} ]; then |
| 88 | mkdir -p ${extraction} |
| 89 | fi |
| 90 | chown ${UID}:${GROUPS} ${extraction} |
| 91 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 92 | # Work out what build target we should be running and set BitBake command |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 93 | case ${target} in |
| 94 | barreleye) |
| 95 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-rackspace/meta-barreleye/conf source oe-init-build-env" |
| 96 | ;; |
| 97 | palmetto) |
| 98 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf source oe-init-build-env" |
| 99 | ;; |
Joel Stanley | 0e07720 | 2016-06-28 16:42:45 +0930 | [diff] [blame] | 100 | witherspoon) |
| 101 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/conf source oe-init-build-env" |
| 102 | ;; |
| 103 | firestone) |
| 104 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-firestone/conf source oe-init-build-env" |
| 105 | ;; |
| 106 | garrison) |
| 107 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-garrison/conf source oe-init-build-env" |
| 108 | ;; |
| 109 | evb-ast2500) |
| 110 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-evb/meta-evb-aspeed/meta-evb-ast2500/conf source oe-init-build-env" |
| 111 | ;; |
Joel Stanley | 915381f | 2016-11-01 16:58:59 +1030 | [diff] [blame] | 112 | zaius) |
| 113 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/conf source oe-init-build-env" |
| 114 | ;; |
| 115 | romulus) |
| 116 | BITBAKE_CMD="TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-romulus/conf source oe-init-build-env" |
| 117 | ;; |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 118 | qemu) |
| 119 | BITBAKE_CMD="source openbmc-env" |
| 120 | ;; |
| 121 | *) |
| 122 | exit 1 |
| 123 | ;; |
| 124 | esac |
| 125 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 126 | # Configure Docker build |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 127 | if [[ "${distro}" == fedora ]];then |
| 128 | |
| 129 | if [[ -n "${http_proxy}" ]]; then |
| 130 | PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf" |
| 131 | fi |
| 132 | |
| 133 | Dockerfile=$(cat << EOF |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 134 | FROM ${DOCKER_BASE}${distro}:${imgtag} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 135 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 136 | ${PROXY} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 137 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 138 | # Set the locale |
| 139 | RUN locale-gen en_US.UTF-8 |
| 140 | ENV LANG en_US.UTF-8 |
| 141 | ENV LANGUAGE en_US:en |
| 142 | ENV LC_ALL en_US.UTF-8 |
Saqib Khan | 7563512 | 2017-03-23 10:57:34 -0500 | [diff] [blame] | 143 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 144 | RUN dnf --refresh install -y \ |
| 145 | bzip2 \ |
| 146 | chrpath \ |
| 147 | cpio \ |
| 148 | diffstat \ |
| 149 | findutils \ |
| 150 | gcc \ |
| 151 | gcc-c++ \ |
| 152 | git \ |
| 153 | make \ |
| 154 | patch \ |
| 155 | perl-bignum \ |
| 156 | perl-Data-Dumper \ |
| 157 | perl-Thread-Queue \ |
| 158 | python-devel \ |
| 159 | python3-devel \ |
| 160 | SDL-devel \ |
| 161 | socat \ |
| 162 | subversion \ |
| 163 | tar \ |
| 164 | texinfo \ |
| 165 | wget \ |
| 166 | which |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 167 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 168 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 169 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 170 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 171 | USER ${USER} |
| 172 | ENV HOME ${HOME} |
| 173 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 174 | EOF |
| 175 | ) |
| 176 | |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 177 | elif [[ "${distro}" == ubuntu ]]; then |
| 178 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 179 | if [[ -n "${http_proxy}" ]]; then |
| 180 | PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" |
| 181 | fi |
| 182 | |
| 183 | Dockerfile=$(cat << EOF |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 184 | FROM ${DOCKER_BASE}${distro}:${imgtag} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 185 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 186 | ${PROXY} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 187 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 188 | ENV DEBIAN_FRONTEND noninteractive |
Saqib Khan | 7563512 | 2017-03-23 10:57:34 -0500 | [diff] [blame] | 189 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 190 | RUN apt-get update && apt-get install -yy \ |
| 191 | build-essential \ |
| 192 | chrpath \ |
| 193 | debianutils \ |
| 194 | diffstat \ |
| 195 | gawk \ |
| 196 | git \ |
| 197 | libdata-dumper-simple-perl \ |
| 198 | libsdl1.2-dev \ |
| 199 | libthread-queue-any-perl \ |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 200 | locales \ |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 201 | python \ |
| 202 | python3 \ |
| 203 | socat \ |
| 204 | subversion \ |
| 205 | texinfo \ |
| 206 | cpio \ |
| 207 | wget |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 208 | |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 209 | # Set the locale |
| 210 | RUN locale-gen en_US.UTF-8 |
| 211 | ENV LANG en_US.UTF-8 |
| 212 | ENV LANGUAGE en_US:en |
| 213 | ENV LC_ALL en_US.UTF-8 |
| 214 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 215 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 216 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
Chris Smart | d30c590 | 2016-03-01 15:00:54 +1100 | [diff] [blame] | 217 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 218 | USER ${USER} |
| 219 | ENV HOME ${HOME} |
| 220 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 221 | EOF |
| 222 | ) |
| 223 | fi |
| 224 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 225 | # Create the Docker run script |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 226 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 227 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 228 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 229 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 230 | mkdir -p ${WORKSPACE} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 231 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 232 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 233 | #!/bin/bash |
| 234 | |
Joel Stanley | 38c9d14 | 2016-02-16 12:31:55 +1030 | [diff] [blame] | 235 | set -xeo pipefail |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 236 | |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 237 | # Go into the OpenBMC directory, the build will handle changing directories |
| 238 | cd ${obmcext} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 239 | |
| 240 | # Set up proxies |
| 241 | export ftp_proxy=${http_proxy} |
| 242 | export http_proxy=${http_proxy} |
| 243 | export https_proxy=${http_proxy} |
| 244 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 245 | mkdir -p ${WORKSPACE}/bin |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 246 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 247 | # Configure proxies for BitBake |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 248 | if [[ -n "${http_proxy}" ]]; then |
| 249 | |
Chris Smart | d30c590 | 2016-03-01 15:00:54 +1100 | [diff] [blame] | 250 | cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 251 | #!/bin/bash |
| 252 | # \$1 = hostname, \$2 = port |
| 253 | PROXY=${PROXY_HOST} |
| 254 | PROXY_PORT=${PROXY_PORT} |
| 255 | exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 256 | EOF_GIT |
| 257 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 258 | chmod a+x ${WORKSPACE}/bin/git-proxy |
| 259 | export PATH=${WORKSPACE}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 260 | git config core.gitProxy git-proxy |
| 261 | |
| 262 | mkdir -p ~/.subversion |
| 263 | |
| 264 | cat > ~/.subversion/servers << EOF_SVN |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 265 | [global] |
| 266 | http-proxy-host = ${PROXY_HOST} |
| 267 | http-proxy-port = ${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 268 | EOF_SVN |
| 269 | fi |
| 270 | |
| 271 | # Source our build env |
| 272 | ${BITBAKE_CMD} |
| 273 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 274 | # Custom BitBake config settings |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 275 | cat >> conf/local.conf << EOF_CONF |
Chris Smart | c650c20 | 2015-11-25 15:58:53 +1100 | [diff] [blame] | 276 | BB_NUMBER_THREADS = "$(nproc)" |
| 277 | PARALLEL_MAKE = "-j$(nproc)" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 278 | INHERIT += "rm_work" |
| 279 | BB_GENERATE_MIRROR_TARBALLS = "1" |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 280 | DL_DIR="${sscdir}/bitbake_downloads" |
| 281 | SSTATE_DIR="${sscdir}/bitbake_sharedstatecache" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 282 | USER_CLASSES += "buildstats" |
Andrew Geissler | 931ec67 | 2016-08-11 13:10:05 -0500 | [diff] [blame] | 283 | INHERIT_remove = "uninative" |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 284 | TMPDIR="${builddir}" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 285 | EOF_CONF |
| 286 | |
| 287 | # Kick off a build |
Andrew Geissler | 496a6b0 | 2016-10-03 10:04:49 -0500 | [diff] [blame] | 288 | bitbake ${BITBAKE_OPTS} obmc-phosphor-image |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 289 | |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 290 | # Copy build directory of internal obmcdir into workspace directory |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 291 | cp -r ${builddir}/* ${extraction} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 292 | EOF_SCRIPT |
| 293 | |
| 294 | chmod a+x ${WORKSPACE}/build.sh |
| 295 | |
Alanny Lopez | 5118688 | 2017-08-01 16:14:41 -0500 | [diff] [blame] | 296 | # Give the Docker image a name based on the distro,tag,arch,and target |
| 297 | imgname=${imgname:-openbmc/${distro}:${imgtag}-${target}-${ARCH}} |
| 298 | |
| 299 | # Build the Docker image |
| 300 | docker build -t ${imgname} - <<< "${Dockerfile}" |
| 301 | |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 302 | # Determine if the build container will be launched with Docker or Kubernetes |
| 303 | if [[ "${launch}" == "" ]]; then |
| 304 | |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 305 | # If obmcext or sscdir are ${HOME} or a subdirectory they will not be mounted |
| 306 | mountobmcext="-v ""${obmcext}"":""${obmcext}"" " |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 307 | mountsscdir="-v ""${sscdir}"":""${sscdir}"" " |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 308 | if [[ "${obmcext}" = "${HOME}/"* || "${obmcext}" = "${HOME}" ]];then |
| 309 | mountobmcext="" |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 310 | fi |
| 311 | if [[ "${sscdir}" = "${HOME}/"* || "${sscdir}" = "${HOME}" ]];then |
| 312 | mountsscdir="" |
| 313 | fi |
| 314 | |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 315 | # Run the Docker container, execute the build.sh script |
| 316 | docker run \ |
| 317 | --cap-add=sys_admin \ |
| 318 | --net=host \ |
| 319 | --rm=true \ |
| 320 | -e WORKSPACE=${WORKSPACE} \ |
| 321 | -w "${HOME}" \ |
| 322 | -v "${HOME}":"${HOME}" \ |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 323 | ${mountobmcext} \ |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 324 | ${mountsscdir} \ |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 325 | -t ${imgname} \ |
| 326 | ${WORKSPACE}/build.sh |
| 327 | |
| 328 | elif [[ "${launch}" == "job" || "${launch}" == "pod" ]]; then |
| 329 | |
| 330 | # Source and run the helper script to launch the pod or job |
Alanny Lopez | 0e8ad99 | 2017-06-19 15:45:23 -0500 | [diff] [blame] | 331 | . ./kubernetes/kubernetes-launch.sh OpenBMC-build true true |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 332 | |
| 333 | else |
| 334 | echo "Launch Parameter is invalid" |
| 335 | fi |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 336 | |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 337 | # To maintain function of resources that used an older path, add a link |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 338 | ln -sf ${extraction}/deploy ${WORKSPACE}/deploy |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 339 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 340 | # Timestamp for build |
Alanny Lopez | 0e8ad99 | 2017-06-19 15:45:23 -0500 | [diff] [blame] | 341 | echo "Build completed, $(date)" |