blob: 5eef10456e864d2d94c4fc326be79d2fead05841 [file] [log] [blame]
Chris Smartb23265d2016-01-11 16:48:57 +11001#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4#
5
6# Trace bash processing
7#set -x
8
9# Default variables
10WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
11http_proxy=${http_proxy:-}
12
13# Timestamp for job
14echo "Build started, $(date)"
15
16# Configure docker build
17if [[ -n "${http_proxy}" ]]; then
18PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
19fi
20
21Dockerfile=$(cat << EOF
22FROM ubuntu:15.10
23
24${PROXY}
25
26#RUN echo $(date +%s) && apt-get update
27RUN apt-get update
28RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy
29RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy bc build-essential cpio git python unzip wget
30RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
31RUN locale-gen en_AU.utf8
32
33USER ${USER}
34ENV HOME ${HOME}
35RUN /bin/bash
36EOF
37)
38
39# Build the docker container
40docker build -t initramfs-build/ubuntu - <<< "${Dockerfile}"
41if [[ "$?" -ne 0 ]]; then
42 echo "Failed to build docker container."
43 exit 1
44fi
45
46# Create the docker run script
47export PROXY_HOST=${http_proxy/#http*:\/\/}
48export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
49export PROXY_PORT=${http_proxy/#http*:\/\/*:}
50
51mkdir -p ${WORKSPACE}
52
53cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
54#!/bin/bash
55
56set -x
57
58cd ${WORKSPACE}
59
60# Go into the linux directory (the script will put us in a build subdir)
61cd buildroot
62
63cat > configs/powerpc64_openpower_defconfig << EOF_BUILDROOT
64BR2_powerpc64le=y
65BR2_TARGET_ROOTFS_CPIO=y
66BR2_TARGET_ROOTFS_CPIO_XZ=y
67EOF_BUILDROOT
68
69# Build buildroot
70export BR2_DL_DIR=${HOME}/buildroot_downloads
71make powerpc64_openpower_defconfig || exit 1
72make || exit 1
73
74EOF_SCRIPT
75
76chmod a+x ${WORKSPACE}/build.sh
77
78# Run the docker container, execute the build script we just built
79docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
80 -w "${HOME}" -v "${HOME}":"${HOME}" -t initramfs-build/ubuntu ${WORKSPACE}/build.sh
81
82# Timestamp for build
83echo "Build completed, $(date)"
84