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