blob: e6874074e8b0d8212ccd1d67297e42dc2d17a66c [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
33RUN dnf install -y git gcc make uboot-tools gcc-arm-linux-gnu
34RUN 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
52RUN echo $(date +%s) && apt-get update
53RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy
54RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy build-essential git gcc-arm-none-eabi u-boot-tools
55RUN 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
89make aspeed_defconfig
90make -j 8
91
92# Build barreleye image
93make aspeed-bmc-opp-barreleye.dtb
94cat arch/arm/boot/zImage arch/arm/boot/dts/aspeed-bmc-opp-barreleye.dtb > barreleye-zimage
95./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 aspeed-zimage uImage.barreleye
96
97# build palmetto image
98make aspeed-bmc-opp-palmetto.dtb
99cat arch/arm/boot/zImage arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dtb > palmetto-zimage
100./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 aspeed-zimage uImage.palmetto
101
102EOF_SCRIPT
103
104chmod a+x ${WORKSPACE}/build.sh
105
106# Run the docker container, execute the build script we just built
107docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
108 -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-aspeed/${distro} ${WORKSPACE}/build.sh
109
110# Timestamp for build
111echo "Build completed, $(date)"
112