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