Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | set -eo pipefail |
| 5 | |
| 6 | function 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 | |
| 13 | env |
| 14 | |
| 15 | if [ -d output-images ]; then |
| 16 | echo 'output-images already exists!'; |
| 17 | exit 1; |
| 18 | fi |
| 19 | |
| 20 | for distro in ubuntu1404 fedora23; |
| 21 | do |
| 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 |
| 40 | RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
| 41 | ${PROXY} |
| 42 | USER ${USER} |
| 43 | ENV HOME ${HOME} |
| 44 | EOF |
| 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 |
| 54 | done; |
| 55 | |