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 | # |
Michael Shepos | 3939e95 | 2019-01-16 16:00:35 -0600 | [diff] [blame] | 4 | # This build script is for running the OpenBMC builds as Docker containers. |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 5 | # |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 6 | ############################################################################### |
| 7 | # |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 8 | # 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 Geissler | dc1e702 | 2018-03-26 07:54:48 -0700 | [diff] [blame] | 16 | # num_cpu Number of cpu's to give bitbake, default is total amount |
| 17 | # in system |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 18 | # |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 19 | # Docker Image Build Variables: |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 20 | # BITBAKE_OPTS Set to "-c populate_sdk" or whatever other BitBake options |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 21 | # you'd like to pass into the build. |
| 22 | # Default: "", no options set |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 23 | # build_dir Path where the actual BitBake build occurs inside the |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 24 | # 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 Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 29 | # img_name The name given to the target build's docker image. |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 30 | # Default: "openbmc/${distro}:${imgtag}-${target}-${ARCH}" |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 31 | # img_tag The base docker image distro tag: |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 32 | # 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 Geissler | dd82072 | 2018-02-20 13:42:58 -0600 | [diff] [blame] | 36 | # evb-ast2500|palmetto|qemu|qemux86-64 |
Vijay Khemka | 4c5b12e | 2019-01-23 14:50:09 -0800 | [diff] [blame] | 37 | # romulus|s2600wf|witherspoon|zaius|tiogapass |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 38 | # Default: "qemu" |
Andrew Geissler | 215e43c | 2019-04-23 10:57:48 -0500 | [diff] [blame] | 39 | # no_tar Set to true if you do not want the debug tar built |
| 40 | # Default: "false" |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 41 | # |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 42 | # Deployment Variables: |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 43 | # obmc_dir Path of the OpenBMC repo directory used as a reference |
Alanny Lopez | e08e870 | 2018-02-24 18:07:13 -0600 | [diff] [blame] | 44 | # for the build inside the container. |
| 45 | # Default: "${WORKSPACE}/openbmc" |
Michael Shepos | 10afbb2 | 2019-02-06 13:33:07 -0600 | [diff] [blame] | 46 | # xtrct_small_copy_dir |
| 47 | # Directory within build_dir that should be copied to |
| 48 | # xtrct_path. The directory and all parents up to, but not |
| 49 | # including, build_dir will be copied. For example, if |
| 50 | # build_dir is set to "/tmp/openbmc" and this is set to |
| 51 | # "build/tmp", the directory at xtrct_path will have the |
| 52 | # following directory structure: |
| 53 | # xtrct_path |
| 54 | # | - build |
| 55 | # | - tmp |
| 56 | # ... |
| 57 | # Can also be set to the empty string to copy the entire |
| 58 | # contents of build_dir to xtrct_path. |
| 59 | # Default: "deploy/images". |
Alanny Lopez | b0a12dd | 2017-04-24 16:21:47 -0500 | [diff] [blame] | 60 | # |
| 61 | ############################################################################### |
Joel Stanley | 4b8b239 | 2016-02-12 15:44:57 +1030 | [diff] [blame] | 62 | # 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] | 63 | set -xeo pipefail |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 64 | |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 65 | # Script Variables: |
| 66 | build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"} |
| 67 | http_proxy=${http_proxy:-} |
| 68 | WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} |
Andrew Geissler | dc1e702 | 2018-03-26 07:54:48 -0700 | [diff] [blame] | 69 | num_cpu=${num_cpu:-$(nproc)} |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 70 | |
| 71 | # Docker Image Build Variables: |
| 72 | build_dir=${build_dir:-/tmp/openbmc} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 73 | distro=${distro:-ubuntu} |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 74 | img_tag=${img_tag:-latest} |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 75 | target=${target:-qemu} |
Andrew Geissler | 215e43c | 2019-04-23 10:57:48 -0500 | [diff] [blame] | 76 | no_tar=${no_tar:-false} |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 77 | |
| 78 | # Deployment variables |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 79 | obmc_dir=${obmc_dir:-${WORKSPACE}/openbmc} |
Michael Shepos | 3939e95 | 2019-01-16 16:00:35 -0600 | [diff] [blame] | 80 | ssc_dir=${HOME} |
Michael Shepos | 10afbb2 | 2019-02-06 13:33:07 -0600 | [diff] [blame] | 81 | xtrct_small_copy_dir=${xtrct_small_copy_dir:-deploy/images} |
Michael Shepos | 3939e95 | 2019-01-16 16:00:35 -0600 | [diff] [blame] | 82 | xtrct_path="${obmc_dir}/build/tmp" |
| 83 | xtrct_copy_timeout="300" |
Alanny Lopez | 4696770 | 2018-02-25 00:29:14 -0600 | [diff] [blame] | 84 | |
Chris Smart | c352254 | 2016-02-16 11:59:36 +1100 | [diff] [blame] | 85 | PROXY="" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 86 | |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 87 | # Determine the architecture |
| 88 | ARCH=$(uname -m) |
| 89 | |
| 90 | # Determine the prefix of the Dockerfile's base image |
| 91 | case ${ARCH} in |
| 92 | "ppc64le") |
| 93 | DOCKER_BASE="ppc64le/" |
| 94 | ;; |
| 95 | "x86_64") |
| 96 | DOCKER_BASE="" |
| 97 | ;; |
| 98 | *) |
| 99 | echo "Unsupported system architecture(${ARCH}) found for docker image" |
| 100 | exit 1 |
| 101 | esac |
Andrew Geissler | 11abbbe | 2016-08-14 19:39:47 -0500 | [diff] [blame] | 102 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 103 | # Timestamp for job |
| 104 | echo "Build started, $(date)" |
| 105 | |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 106 | # If the obmc_dir directory doesn't exist clone it in |
| 107 | if [ ! -d ${obmc_dir} ]; then |
| 108 | echo "Clone in openbmc master to ${obmc_dir}" |
| 109 | git clone https://github.com/openbmc/openbmc ${obmc_dir} |
Andrew Geissler | c3c3520 | 2016-08-16 08:47:50 -0500 | [diff] [blame] | 110 | fi |
| 111 | |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 112 | # Make and chown the xtrct_path directory to avoid permission errors |
| 113 | if [ ! -d ${xtrct_path} ]; then |
| 114 | mkdir -p ${xtrct_path} |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 115 | fi |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 116 | chown ${UID}:${GROUPS} ${xtrct_path} |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 117 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 118 | # Work out what build target we should be running and set BitBake command |
Michael Shepos | 2de03e9 | 2018-11-07 15:54:56 -0600 | [diff] [blame] | 119 | MACHINE="" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 120 | case ${target} in |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 121 | palmetto) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 122 | LAYER_DIR="meta-ibm/meta-palmetto" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 123 | ;; |
Adriana Kobylak | 4ec7db0 | 2019-05-07 12:44:30 -0500 | [diff] [blame] | 124 | swift) |
| 125 | LAYER_DIR="meta-ibm/meta-witherspoon" |
| 126 | MACHINE="swift" |
| 127 | ;; |
Joel Stanley | 0e07720 | 2016-06-28 16:42:45 +0930 | [diff] [blame] | 128 | witherspoon) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 129 | LAYER_DIR="meta-ibm/meta-witherspoon" |
Joel Stanley | 0e07720 | 2016-06-28 16:42:45 +0930 | [diff] [blame] | 130 | ;; |
Adriana Kobylak | fcba1c3 | 2019-05-10 11:33:37 -0500 | [diff] [blame] | 131 | witherspoon-128) |
| 132 | LAYER_DIR="meta-ibm/meta-witherspoon" |
| 133 | MACHINE="witherspoon-128" |
| 134 | ;; |
Joel Stanley | 0e07720 | 2016-06-28 16:42:45 +0930 | [diff] [blame] | 135 | evb-ast2500) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 136 | LAYER_DIR="meta-evb/meta-evb-aspeed/meta-evb-ast2500" |
Joel Stanley | 0e07720 | 2016-06-28 16:42:45 +0930 | [diff] [blame] | 137 | ;; |
Ed Tanous | 6dc40d9 | 2018-07-30 11:13:36 -0700 | [diff] [blame] | 138 | s2600wf) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 139 | LAYER_DIR="meta-intel/meta-s2600wf" |
Ed Tanous | 6dc40d9 | 2018-07-30 11:13:36 -0700 | [diff] [blame] | 140 | ;; |
Joel Stanley | 915381f | 2016-11-01 16:58:59 +1030 | [diff] [blame] | 141 | zaius) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 142 | LAYER_DIR="meta-ingrasys/meta-zaius" |
Joel Stanley | 915381f | 2016-11-01 16:58:59 +1030 | [diff] [blame] | 143 | ;; |
| 144 | romulus) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 145 | LAYER_DIR="meta-ibm/meta-romulus" |
Joel Stanley | 915381f | 2016-11-01 16:58:59 +1030 | [diff] [blame] | 146 | ;; |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 147 | qemu) |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 148 | LAYER_DIR="meta-phosphor" |
Michael Shepos | 2de03e9 | 2018-11-07 15:54:56 -0600 | [diff] [blame] | 149 | # MACHINE defaults to `qemuarm` in this layer, no change necessary |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 150 | ;; |
Andrew Geissler | dd82072 | 2018-02-20 13:42:58 -0600 | [diff] [blame] | 151 | qemux86-64) |
Michael Shepos | 2de03e9 | 2018-11-07 15:54:56 -0600 | [diff] [blame] | 152 | LAYER_DIR="meta-phosphor" |
| 153 | # MACHINE defaults to `qemuarm` in this layer, change to `qemux86-64` |
| 154 | MACHINE="qemux86-64" |
Andrew Geissler | dd82072 | 2018-02-20 13:42:58 -0600 | [diff] [blame] | 155 | ;; |
Vijay Khemka | 4c5b12e | 2019-01-23 14:50:09 -0800 | [diff] [blame] | 156 | tiogapass) |
| 157 | LAYER_DIR="meta-facebook/meta-tiogapass" |
| 158 | ;; |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 159 | *) |
| 160 | exit 1 |
| 161 | ;; |
| 162 | esac |
| 163 | |
Brad Bishop | 7161a17 | 2018-10-05 16:48:06 -0400 | [diff] [blame] | 164 | BITBAKE_CMD="TEMPLATECONF=${LAYER_DIR}/conf source oe-init-build-env" |
| 165 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 166 | # Configure Docker build |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 167 | if [[ "${distro}" == fedora ]];then |
| 168 | |
| 169 | if [[ -n "${http_proxy}" ]]; then |
| 170 | PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf" |
| 171 | fi |
| 172 | |
| 173 | Dockerfile=$(cat << EOF |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 174 | FROM ${DOCKER_BASE}${distro}:${img_tag} |
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 | # Set the locale |
| 179 | RUN locale-gen en_US.UTF-8 |
| 180 | ENV LANG en_US.UTF-8 |
| 181 | ENV LANGUAGE en_US:en |
| 182 | ENV LC_ALL en_US.UTF-8 |
Saqib Khan | 7563512 | 2017-03-23 10:57:34 -0500 | [diff] [blame] | 183 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 184 | RUN dnf --refresh install -y \ |
| 185 | bzip2 \ |
| 186 | chrpath \ |
| 187 | cpio \ |
| 188 | diffstat \ |
| 189 | findutils \ |
| 190 | gcc \ |
| 191 | gcc-c++ \ |
| 192 | git \ |
| 193 | make \ |
| 194 | patch \ |
| 195 | perl-bignum \ |
| 196 | perl-Data-Dumper \ |
| 197 | perl-Thread-Queue \ |
| 198 | python-devel \ |
| 199 | python3-devel \ |
| 200 | SDL-devel \ |
| 201 | socat \ |
| 202 | subversion \ |
| 203 | tar \ |
| 204 | texinfo \ |
| 205 | wget \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 206 | which \ |
| 207 | iputils-ping |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 208 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 209 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 210 | 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] | 211 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 212 | USER ${USER} |
| 213 | ENV HOME ${HOME} |
| 214 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 215 | EOF |
| 216 | ) |
| 217 | |
Alanny Lopez | ccc650e | 2017-04-24 15:14:20 -0500 | [diff] [blame] | 218 | elif [[ "${distro}" == ubuntu ]]; then |
| 219 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 220 | if [[ -n "${http_proxy}" ]]; then |
| 221 | PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" |
| 222 | fi |
| 223 | |
| 224 | Dockerfile=$(cat << EOF |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 225 | FROM ${DOCKER_BASE}${distro}:${img_tag} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 226 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 227 | ${PROXY} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 228 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 229 | ENV DEBIAN_FRONTEND noninteractive |
Saqib Khan | 7563512 | 2017-03-23 10:57:34 -0500 | [diff] [blame] | 230 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 231 | RUN apt-get update && apt-get install -yy \ |
| 232 | build-essential \ |
| 233 | chrpath \ |
| 234 | debianutils \ |
| 235 | diffstat \ |
| 236 | gawk \ |
| 237 | git \ |
| 238 | libdata-dumper-simple-perl \ |
| 239 | libsdl1.2-dev \ |
| 240 | libthread-queue-any-perl \ |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 241 | locales \ |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 242 | python \ |
| 243 | python3 \ |
| 244 | socat \ |
| 245 | subversion \ |
| 246 | texinfo \ |
| 247 | cpio \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 248 | wget \ |
| 249 | iputils-ping |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 250 | |
Alanny Lopez | 27af3a0 | 2017-05-26 10:49:06 -0500 | [diff] [blame] | 251 | # Set the locale |
| 252 | RUN locale-gen en_US.UTF-8 |
| 253 | ENV LANG en_US.UTF-8 |
| 254 | ENV LANGUAGE en_US:en |
| 255 | ENV LC_ALL en_US.UTF-8 |
| 256 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 257 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 258 | 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] | 259 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 260 | USER ${USER} |
| 261 | ENV HOME ${HOME} |
| 262 | RUN /bin/bash |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 263 | EOF |
| 264 | ) |
| 265 | fi |
| 266 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 267 | # Create the Docker run script |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 268 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 269 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 270 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 271 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 272 | mkdir -p ${WORKSPACE} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 273 | |
Andrew Geissler | 215e43c | 2019-04-23 10:57:48 -0500 | [diff] [blame] | 274 | # Determine command for bitbake image build |
| 275 | bitbake_image="obmc-phosphor-image" |
| 276 | if [ $no_tar = "false" ]; then |
| 277 | bitbake_image="${bitbake_image} obmc-phosphor-debug-tarball" |
| 278 | fi |
| 279 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 280 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 281 | #!/bin/bash |
| 282 | |
Joel Stanley | 38c9d14 | 2016-02-16 12:31:55 +1030 | [diff] [blame] | 283 | set -xeo pipefail |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 284 | |
Alanny Lopez | 723fea6 | 2017-09-12 11:22:17 -0500 | [diff] [blame] | 285 | # Go into the OpenBMC directory, the build will handle changing directories |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 286 | cd ${obmc_dir} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 287 | |
| 288 | # Set up proxies |
| 289 | export ftp_proxy=${http_proxy} |
| 290 | export http_proxy=${http_proxy} |
| 291 | export https_proxy=${http_proxy} |
| 292 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 293 | mkdir -p ${WORKSPACE}/bin |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 294 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 295 | # Configure proxies for BitBake |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 296 | if [[ -n "${http_proxy}" ]]; then |
| 297 | |
Chris Smart | d30c590 | 2016-03-01 15:00:54 +1100 | [diff] [blame] | 298 | cat > ${WORKSPACE}/bin/git-proxy << \EOF_GIT |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 299 | #!/bin/bash |
| 300 | # \$1 = hostname, \$2 = port |
| 301 | PROXY=${PROXY_HOST} |
| 302 | PROXY_PORT=${PROXY_PORT} |
| 303 | exec socat STDIO PROXY:\${PROXY}:\${1}:\${2},proxyport=\${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 304 | EOF_GIT |
| 305 | |
Chris Smart | 01d2b96 | 2015-11-11 18:05:30 +1100 | [diff] [blame] | 306 | chmod a+x ${WORKSPACE}/bin/git-proxy |
| 307 | 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] | 308 | git config core.gitProxy git-proxy |
| 309 | |
| 310 | mkdir -p ~/.subversion |
| 311 | |
| 312 | cat > ~/.subversion/servers << EOF_SVN |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 313 | [global] |
| 314 | http-proxy-host = ${PROXY_HOST} |
| 315 | http-proxy-port = ${PROXY_PORT} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 316 | EOF_SVN |
| 317 | fi |
| 318 | |
| 319 | # Source our build env |
| 320 | ${BITBAKE_CMD} |
| 321 | |
Adriana Kobylak | 62a1b10 | 2019-05-07 12:14:45 -0500 | [diff] [blame] | 322 | # Export MACHINE name when given for build target |
Michael Shepos | 2de03e9 | 2018-11-07 15:54:56 -0600 | [diff] [blame] | 323 | if [[ -n "${MACHINE}" ]]; then |
Adriana Kobylak | 62a1b10 | 2019-05-07 12:14:45 -0500 | [diff] [blame] | 324 | export MACHINE="${MACHINE}"; export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE MACHINE" |
Michael Shepos | 2de03e9 | 2018-11-07 15:54:56 -0600 | [diff] [blame] | 325 | fi |
| 326 | |
Alanny Lopez | eaa2eae | 2017-04-24 14:55:07 -0500 | [diff] [blame] | 327 | # Custom BitBake config settings |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 328 | cat >> conf/local.conf << EOF_CONF |
Chris Smart | c650c20 | 2015-11-25 15:58:53 +1100 | [diff] [blame] | 329 | BB_NUMBER_THREADS = "$(nproc)" |
| 330 | PARALLEL_MAKE = "-j$(nproc)" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 331 | INHERIT += "rm_work" |
| 332 | BB_GENERATE_MIRROR_TARBALLS = "1" |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 333 | DL_DIR="${ssc_dir}/bitbake_downloads" |
| 334 | SSTATE_DIR="${ssc_dir}/bitbake_sharedstatecache" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 335 | USER_CLASSES += "buildstats" |
Andrew Geissler | 931ec67 | 2016-08-11 13:10:05 -0500 | [diff] [blame] | 336 | INHERIT_remove = "uninative" |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 337 | TMPDIR="${build_dir}" |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 338 | EOF_CONF |
| 339 | |
| 340 | # Kick off a build |
Andrew Geissler | 215e43c | 2019-04-23 10:57:48 -0500 | [diff] [blame] | 341 | bitbake ${BITBAKE_OPTS} ${bitbake_image} |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 342 | |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 343 | # Copy internal build directory into xtrct_path directory |
Charles Paul Hofer | b249c2c | 2018-09-12 12:15:13 -0500 | [diff] [blame] | 344 | if [[ ${xtrct_small_copy_dir} ]]; then |
| 345 | mkdir -p ${xtrct_path}/${xtrct_small_copy_dir} |
| 346 | timeout ${xtrct_copy_timeout} cp -r ${build_dir}/${xtrct_small_copy_dir}/* ${xtrct_path}/${xtrct_small_copy_dir} |
| 347 | else |
| 348 | timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path} |
| 349 | fi |
Charles Paul Hofer | be8700e | 2018-09-05 09:28:08 -0500 | [diff] [blame] | 350 | |
| 351 | if [[ 0 -ne $? ]]; then |
| 352 | echo "Received a non-zero exit code from timeout" |
| 353 | exit 1 |
| 354 | fi |
| 355 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 356 | EOF_SCRIPT |
| 357 | |
| 358 | chmod a+x ${WORKSPACE}/build.sh |
| 359 | |
Alanny Lopez | 5118688 | 2017-08-01 16:14:41 -0500 | [diff] [blame] | 360 | # Give the Docker image a name based on the distro,tag,arch,and target |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 361 | img_name=${img_name:-openbmc/${distro}:${img_tag}-${target}-${ARCH}} |
Alanny Lopez | 5118688 | 2017-08-01 16:14:41 -0500 | [diff] [blame] | 362 | |
| 363 | # Build the Docker image |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 364 | docker build -t ${img_name} - <<< "${Dockerfile}" |
Alanny Lopez | 5118688 | 2017-08-01 16:14:41 -0500 | [diff] [blame] | 365 | |
Michael Shepos | 3939e95 | 2019-01-16 16:00:35 -0600 | [diff] [blame] | 366 | # If obmc_dir or ssc_dir are ${HOME} or a subdirectory they will not be mounted |
| 367 | mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" " |
| 368 | mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" " |
| 369 | if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then |
| 370 | mount_obmc_dir="" |
Alanny Lopez | 3fbaa51 | 2017-04-24 15:46:52 -0500 | [diff] [blame] | 371 | fi |
Michael Shepos | 3939e95 | 2019-01-16 16:00:35 -0600 | [diff] [blame] | 372 | if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then |
| 373 | mount_ssc_dir="" |
| 374 | fi |
| 375 | |
| 376 | # Run the Docker container, execute the build.sh script |
| 377 | docker run \ |
| 378 | --cap-add=sys_admin \ |
| 379 | --net=host \ |
| 380 | --rm=true \ |
| 381 | -e WORKSPACE=${WORKSPACE} \ |
| 382 | -w "${HOME}" \ |
| 383 | -v "${HOME}":"${HOME}" \ |
| 384 | ${mount_obmc_dir} \ |
| 385 | ${mount_ssc_dir} \ |
| 386 | --cpus="$num_cpu" \ |
| 387 | -t ${img_name} \ |
| 388 | ${WORKSPACE}/build.sh |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 389 | |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 390 | # To maintain function of resources that used an older path, add a link |
Alanny Lopez | 1246b03 | 2018-02-24 23:34:55 -0600 | [diff] [blame] | 391 | ln -sf ${xtrct_path}/deploy ${WORKSPACE}/deploy |
Alanny Lopez | d32d332 | 2017-07-18 15:21:39 -0500 | [diff] [blame] | 392 | |
Chris Smart | 0265171 | 2015-11-11 11:09:00 +1100 | [diff] [blame] | 393 | # Timestamp for build |
Alanny Lopez | 0e8ad99 | 2017-06-19 15:45:23 -0500 | [diff] [blame] | 394 | echo "Build completed, $(date)" |