blob: d7e98cad9f4537c9e7dbdeb7b061d734202c5245 [file] [log] [blame]
Stewart Smith098d03e2016-03-01 13:59:42 +11001#!/bin/bash
2
3set -ex
4set -eo pipefail
5
6function run_docker
7{
8 $DOCKER_PREFIX docker run --cap-add=sys_admin --net=host --rm=true \
9 --user="${USER}" -w "${PWD}" -v "${PWD}":"${PWD}":Z \
10 -t $1 $2
11}
12
13env
14
15if [ -d output-images ]; then
16 echo 'output-images already exists!';
17 exit 1;
18fi
19
20for distro in ubuntu1404 fedora23;
21do
22 base_dockerfile=ci/Dockerfile/$distro.`arch`
23 if [ ! -f $base_dockerfile ]; then
24 echo '$distro not supported on `arch`.';
25 continue
26 fi
27 if [[ -n "$HTTP_PROXY" ]]; then
28 http_proxy=$HTTP_PROXY
29 fi
30 if [[ -n "$http_proxy" ]]; then
31 if [[ "$distro" == fedora23 ]]; then
32 PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
33 fi
34 if [[ "$distro" == ubuntu1404 ]]; then
35 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
36 fi
37 fi
38
39 Dockerfile=$(head -n1 $base_dockerfile; echo ${PROXY}; tail -n +2 $base_dockerfile; cat << EOF
40RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
41${PROXY}
42USER ${USER}
43ENV HOME ${HOME}
44EOF
45)
46 $DOCKER_PREFIX docker build -t openpower/op-build-$distro - <<< "${Dockerfile}"
47 mkdir -p output-images/$distro
48 run_docker openpower/op-build-$distro "./ci/build-all-defconfigs.sh output-images/$distro"
49 if [ $? = 0 ]; then
50 mv *-images output-$distro/
51 else
52 exit $?;
53 fi
54done;
55