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