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