blob: 26d4bcff1891c36a77ba83d7038f8fae9dcf4f21 [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
Chris Smart110f0b02016-03-09 14:50:11 +110026# update datestamp below to force a cache refresh
27RUN echo 201603091439 && apt-get update
Chris Smartb23265d2016-01-11 16:48:57 +110028RUN 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
Chris Smart01d1b382016-01-14 12:05:33 +110067BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
Chris Smartb23265d2016-01-11 16:48:57 +110068EOF_BUILDROOT
69
70# Build buildroot
71export BR2_DL_DIR=${HOME}/buildroot_downloads
72make powerpc64_openpower_defconfig || exit 1
73make || exit 1
74
75EOF_SCRIPT
76
77chmod a+x ${WORKSPACE}/build.sh
78
79# Run the docker container, execute the build script we just built
80docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
81 -w "${HOME}" -v "${HOME}":"${HOME}" -t initramfs-build/ubuntu ${WORKSPACE}/build.sh
82
83# Timestamp for build
84echo "Build completed, $(date)"
85