blob: 65abf39fe2a322695c23951c9cd7524c6a612d83 [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 Smart4593d4f2016-03-09 15:50:59 +110026ENV DEBIAN_FRONTEND noninteractive
Chris Smartfc730ff2016-03-09 20:17:19 +110027RUN apt-get update && apt-get install -yy \
Chris Smart4593d4f2016-03-09 15:50:59 +110028 bc \
29 build-essential \
30 cpio \
31 git \
32 python \
33 unzip \
34 wget
35
36RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
37RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
38
Chris Smartb23265d2016-01-11 16:48:57 +110039RUN locale-gen en_AU.utf8
40
41USER ${USER}
42ENV HOME ${HOME}
43RUN /bin/bash
44EOF
45)
46
47# Build the docker container
48docker build -t initramfs-build/ubuntu - <<< "${Dockerfile}"
49if [[ "$?" -ne 0 ]]; then
50 echo "Failed to build docker container."
51 exit 1
52fi
53
54# Create the docker run script
55export PROXY_HOST=${http_proxy/#http*:\/\/}
56export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
57export PROXY_PORT=${http_proxy/#http*:\/\/*:}
58
59mkdir -p ${WORKSPACE}
60
61cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
62#!/bin/bash
63
64set -x
65
66cd ${WORKSPACE}
67
68# Go into the linux directory (the script will put us in a build subdir)
69cd buildroot
70
71cat > configs/powerpc64_openpower_defconfig << EOF_BUILDROOT
72BR2_powerpc64le=y
73BR2_TARGET_ROOTFS_CPIO=y
74BR2_TARGET_ROOTFS_CPIO_XZ=y
Chris Smart01d1b382016-01-14 12:05:33 +110075BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
Chris Smartf540dac2016-03-16 12:58:15 +110076BR2_GLIBC_VERSION_2_22=y
Chris Smartb23265d2016-01-11 16:48:57 +110077EOF_BUILDROOT
78
79# Build buildroot
80export BR2_DL_DIR=${HOME}/buildroot_downloads
81make powerpc64_openpower_defconfig || exit 1
82make || exit 1
83
84EOF_SCRIPT
85
86chmod a+x ${WORKSPACE}/build.sh
87
88# Run the docker container, execute the build script we just built
89docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
90 -w "${HOME}" -v "${HOME}":"${HOME}" -t initramfs-build/ubuntu ${WORKSPACE}/build.sh
91
92# Timestamp for build
93echo "Build completed, $(date)"
94