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