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 \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 166 | which \ |
| 167 | iputils-ping |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 168 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 169 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 170 | 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] | 171 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 172 | USER ${USER} |
| 173 | ENV HOME ${HOME} |
| 174 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 175 | EOF |
| 176 | ) |
| 177 | |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 178 | elif [[ "${distro}" == ubuntu ]]; then |
| 179 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 180 | if [[ -n "${http_proxy}" ]]; then |
| 181 | PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" |
| 182 | fi |
| 183 | |
| 184 | Dockerfile=$(cat << EOF |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 185 | FROM ${DOCKER_BASE}${distro}:${imgtag} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 186 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 187 | ${PROXY} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 188 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 189 | ENV DEBIAN_FRONTEND noninteractive |
Saqib Khan | 7563512 | 2017-03-23 10:57:34 -0500 | [diff] [blame] | 190 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 191 | RUN apt-get update && apt-get install -yy \ |
| 192 | build-essential \ |
| 193 | chrpath \ |
| 194 | debianutils \ |
| 195 | diffstat \ |
| 196 | gawk \ |
| 197 | git \ |
| 198 | libdata-dumper-simple-perl \ |
| 199 | libsdl1.2-dev \ |
| 200 | libthread-queue-any-perl \ |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 201 | locales \ |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 202 | python \ |
| 203 | python3 \ |
| 204 | socat \ |
| 205 | subversion \ |
| 206 | texinfo \ |
| 207 | cpio \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 208 | wget \ |
| 209 | iputils-ping |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 210 | |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 211 | # Set the locale |
| 212 | RUN locale-gen en_US.UTF-8 |
| 213 | ENV LANG en_US.UTF-8 |
| 214 | ENV LANGUAGE en_US:en |
| 215 | ENV LC_ALL en_US.UTF-8 |
| 216 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 217 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 218 | 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] | 219 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 220 | USER ${USER} |
| 221 | ENV HOME ${HOME} |
| 222 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 223 | EOF |
| 224 | ) |
| 225 | fi |
| 226 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 227 | # Create the Docker run script |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 228 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 229 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 230 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 231 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 232 | mkdir -p ${WORKSPACE} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 233 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 234 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 235 | #!/bin/bash |
| 236 | |
Joel Stanley | 38c9d14 | 2016-02-16 12:31:55 +1030 | [diff] [blame] | 237 | set -xeo pipefail |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 238 | |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 239 | # Go into the OpenBMC directory, the build will handle changing directories |
| 240 | cd ${obmcext} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 241 | |
| 242 | # Set up proxies |
| 243 | export ftp_proxy=${http_proxy} |
| 244 | export http_proxy=${http_proxy} |
| 245 | export https_proxy=${http_proxy} |
| 246 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 247 | mkdir -p ${WORKSPACE}/bin |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 248 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 249 | # Configure proxies for BitBake |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 250 | if [[ -n "${http_proxy}" ]]; then |
| 251 | |
Chris Smart | d30c590 | 2016-03-01 15:00:54 +1100 | [diff] [blame] | 252 | cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 253 | #!/bin/bash |
| 254 | # \$1 = hostname, \$2 = port |
| 255 | PROXY=${PROXY_HOST} |
| 256 | PROXY_PORT=${PROXY_PORT} |
| 257 | exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 258 | EOF_GIT |
| 259 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 260 | chmod a+x ${WORKSPACE}/bin/git-proxy |
| 261 | 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] | 262 | git config core.gitProxy git-proxy |
| 263 | |
| 264 | mkdir -p ~/.subversion |
| 265 | |
| 266 | cat > ~/.subversion/servers << EOF_SVN |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 267 | [global] |
| 268 | http-proxy-host = ${PROXY_HOST} |
| 269 | http-proxy-port = ${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 270 | EOF_SVN |
| 271 | fi |
| 272 | |
| 273 | # Source our build env |
| 274 | ${BITBAKE_CMD} |
| 275 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 276 | # Custom BitBake config settings |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 277 | cat >> conf/local.conf << EOF_CONF |
Chris Smart | c650c20 | 2015-11-25 15:58:53 +1100 | [diff] [blame] | 278 | BB_NUMBER_THREADS = "$(nproc)" |
| 279 | PARALLEL_MAKE = "-j$(nproc)" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 280 | INHERIT += "rm_work" |
| 281 | BB_GENERATE_MIRROR_TARBALLS = "1" |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 282 | DL_DIR="${sscdir}/bitbake_downloads" |
| 283 | SSTATE_DIR="${sscdir}/bitbake_sharedstatecache" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 284 | USER_CLASSES += "buildstats" |
Andrew Geissler | 931ec67 | 2016-08-11 13:10:05 -0500 | [diff] [blame] | 285 | INHERIT_remove = "uninative" |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 286 | TMPDIR="${builddir}" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 287 | EOF_CONF |
| 288 | |
| 289 | # Kick off a build |
Andrew Geissler | 496a6b0 | 2016-10-03 10:04:49 -0500 | [diff] [blame] | 290 | bitbake ${BITBAKE_OPTS} obmc-phosphor-image |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 291 | |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 292 | # Copy build directory of internal obmcdir into workspace directory |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 293 | cp -r ${builddir}/* ${extraction} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 294 | EOF_SCRIPT |
| 295 | |
| 296 | chmod a+x ${WORKSPACE}/build.sh |
| 297 | |
Alanny Lopez | 5118688 | 2017-08-01 16:14:41 -0500 | [diff] [blame] | 298 | # Give the Docker image a name based on the distro,tag,arch,and target |
| 299 | imgname=${imgname:-openbmc/${distro}:${imgtag}-${target}-${ARCH}} |
| 300 | |
| 301 | # Build the Docker image |
| 302 | docker build -t ${imgname} - <<< "${Dockerfile}" |
| 303 | |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 304 | # Determine if the build container will be launched with Docker or Kubernetes |
| 305 | if [[ "${launch}" == "" ]]; then |
| 306 | |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 307 | # If obmcext or sscdir are ${HOME} or a subdirectory they will not be mounted |
| 308 | mountobmcext="-v ""${obmcext}"":""${obmcext}"" " |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 309 | mountsscdir="-v ""${sscdir}"":""${sscdir}"" " |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 310 | if [[ "${obmcext}" = "${HOME}/"* || "${obmcext}" = "${HOME}" ]];then |
| 311 | mountobmcext="" |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 312 | fi |
| 313 | if [[ "${sscdir}" = "${HOME}/"* || "${sscdir}" = "${HOME}" ]];then |
| 314 | mountsscdir="" |
| 315 | fi |
| 316 | |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 317 | # Run the Docker container, execute the build.sh script |
| 318 | docker run \ |
| 319 | --cap-add=sys_admin \ |
| 320 | --net=host \ |
| 321 | --rm=true \ |
| 322 | -e WORKSPACE=${WORKSPACE} \ |
| 323 | -w "${HOME}" \ |
| 324 | -v "${HOME}":"${HOME}" \ |
Alanny Lopez | 7ec6d4d | 2017-06-09 09:43:01 -0500 | [diff] [blame] | 325 | ${mountobmcext} \ |
Alanny Lopez | 97a7950 | 2017-04-24 16:19:25 -0500 | [diff] [blame] | 326 | ${mountsscdir} \ |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 327 | -t ${imgname} \ |
| 328 | ${WORKSPACE}/build.sh |
| 329 | |
| 330 | elif [[ "${launch}" == "job" || "${launch}" == "pod" ]]; then |
| 331 | |
| 332 | # Source and run the helper script to launch the pod or job |
Alanny Lopez | 0e8ad99 | 2017-06-19 15:45:23 -0500 | [diff] [blame] | 333 | . ./kubernetes/kubernetes-launch.sh OpenBMC-build true true |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 334 | |
| 335 | else |
| 336 | echo "Launch Parameter is invalid" |
| 337 | fi |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 338 | |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 339 | # 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] | 340 | ln -sf ${extraction}/deploy ${WORKSPACE}/deploy |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 341 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 342 | # Timestamp for build |
Alanny Lopez | 0e8ad99 | 2017-06-19 15:45:23 -0500 | [diff] [blame] | 343 | echo "Build completed, $(date)" |