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