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