blob: eb1df4c117eb6cb4f0a2d7af9c40beb56e3ad80d [file] [log] [blame]
Joel Stanley0d3597f2015-11-18 14:09:54 +10301#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4#
5# It expects a variable as part of Jenkins build job matrix:
6# distro = fedora|ubuntu
7# WORKSPACE =
8
9# Trace bash processing
10set -x
11
12# Default variables
13distro=${distro:-ubuntu}
14WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
15http_proxy=${http_proxy:-}
16
17# Timestamp for job
18echo "Build started, $(date)"
19
20# Configure docker build
21if [[ "${distro}" == fedora ]];then
22
23 if [[ -n "${http_proxy}" ]]; then
24 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
25 fi
26
27 Dockerfile=$(cat << EOF
28FROM fedora:latest
29
30${PROXY}
31
32RUN dnf --refresh upgrade -y
Chris Smart72ed8022015-11-18 17:06:47 +110033RUN dnf install -y bc findutils git gcc gcc-arm-linux-gnu hostname make uboot-tools xz
Joel Stanley0d3597f2015-11-18 14:09:54 +103034RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
35
36USER ${USER}
37ENV HOME ${HOME}
38RUN /bin/bash
39EOF
40)
41
42elif [[ "${distro}" == ubuntu ]]; then
43 if [[ -n "${http_proxy}" ]]; then
44 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
45 fi
46
47 Dockerfile=$(cat << EOF
48FROM ubuntu:latest
49
50${PROXY}
51
Chris Smart72ed8022015-11-18 17:06:47 +110052RUN apt-get update
Joel Stanley0d3597f2015-11-18 14:09:54 +103053RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy
Chris Smart72ed8022015-11-18 17:06:47 +110054RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy bc build-essential git gcc-arm-none-eabi u-boot-tools
Joel Stanley0d3597f2015-11-18 14:09:54 +103055RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
56
57USER ${USER}
58ENV HOME ${HOME}
59RUN /bin/bash
60EOF
61)
62fi
63
64# Build the docker container
65docker build -t linux-aspeed/${distro} - <<< "${Dockerfile}"
66if [[ "$?" -ne 0 ]]; then
67 echo "Failed to build docker container."
68 exit 1
69fi
70
71# Create the docker run script
72export PROXY_HOST=${http_proxy/#http*:\/\/}
73export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
74export PROXY_PORT=${http_proxy/#http*:\/\/*:}
75
76mkdir -p ${WORKSPACE}
77
78cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
79#!/bin/bash
80
81set -x
82
83cd ${WORKSPACE}
84
85# Go into the linux-aspeed directory (the script will put us in a build subdir)
86cd linux-aspeed
87
88# Configure a build
Chris Smart72ed8022015-11-18 17:06:47 +110089if [ "${distro}" == "fedora" ]; then
90 CROSS_COMPILER="arm-linux-gnu-"
91else
92 CROSS_COMPILER="arm-none-eabi-"
93fi
94
Joel Stanley50ab01d2015-11-19 09:53:25 +103095# Record the version in the logs
96$\{CROSS_COMPILER} --version
97
Chris Smart72ed8022015-11-18 17:06:47 +110098ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make aspeed_defconfig
99ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make -j$(($(nproc) / 4))
Joel Stanley0d3597f2015-11-18 14:09:54 +1030100
101# Build barreleye image
Chris Smart72ed8022015-11-18 17:06:47 +1100102ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make aspeed-bmc-opp-barreleye.dtb
Joel Stanley0d3597f2015-11-18 14:09:54 +1030103cat arch/arm/boot/zImage arch/arm/boot/dts/aspeed-bmc-opp-barreleye.dtb > barreleye-zimage
Chris Smart72ed8022015-11-18 17:06:47 +1100104./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x40008000 -e 0x40008000 -d-e 0x40008000 -n obmc-beye-\$(date +%Y%m%d%H%M) -d barreleye-zimage uImage.barreleye
Joel Stanley0d3597f2015-11-18 14:09:54 +1030105
106# build palmetto image
Chris Smart72ed8022015-11-18 17:06:47 +1100107ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make aspeed-bmc-opp-palmetto.dtb
Joel Stanley0d3597f2015-11-18 14:09:54 +1030108cat arch/arm/boot/zImage arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dtb > palmetto-zimage
Chris Smart72ed8022015-11-18 17:06:47 +1100109./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x40008000 -e 0x40008000 -d-e 0x40008000 -n obmc-palm-\$(date +%Y%m%d%H%M) -d palmetto-zimage uImage.palmetto
Joel Stanley0d3597f2015-11-18 14:09:54 +1030110
111EOF_SCRIPT
112
113chmod a+x ${WORKSPACE}/build.sh
114
115# Run the docker container, execute the build script we just built
116docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
117 -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-aspeed/${distro} ${WORKSPACE}/build.sh
118
119# Timestamp for build
120echo "Build completed, $(date)"
121