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