blob: 8449d2ff6856dc0b78237a0f9758a8b825bcdd25 [file] [log] [blame]
Matthew Barthb4aea672016-11-10 14:59:52 -06001#!/bin/bash -xe
2#
3# Build the required docker image to run package unit tests
4#
5# Parameters:
6# param1: <optional, the name of the docker image to generate>
7# default is openbmc/ubuntu-unit-test
8# param2: <optional, the distro to build a docker image against>
9# default is ubuntu:latest
10
11set -uo pipefail
12
13DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-unit-test"}
14DISTRO=${2:-"ubuntu:latest"}
15
Matthew Barthccb7f852016-11-23 17:43:02 -060016# Disable autom4te cache as workaround to permission issue
17AUTOM4TE_CFG="/root/.autom4te.cfg"
18AUTOM4TE="begin-language: \"Autoconf-without-aclocal-m4\"\nargs: --no-cache\n\
19end-language: \"Autoconf-without-aclocal-m4\""
20
Matthew Barthb4aea672016-11-10 14:59:52 -060021# Determine the architecture
22ARCH=$(uname -m)
23case ${ARCH} in
24 "ppc64le")
25 DOCKER_BASE="ppc64le/"
26 ;;
27 "x86_64")
28 DOCKER_BASE=""
29 ;;
30 *)
31 echo "Unsupported system architecture(${ARCH}) found for docker image"
32 exit 1
33esac
34
35################################# docker img # #################################
36# Create docker image that can run package unit tests
37if [[ "${DISTRO}" == "ubuntu"* ]]; then
38Dockerfile=$(cat << EOF
39FROM ${DOCKER_BASE}${DISTRO}
40
41ENV DEBIAN_FRONTEND noninteractive
42
43RUN apt-get update && apt-get install -yy \
44 gcc \
45 g++ \
46 libc6-dev \
47 libtool \
48 cmake \
49 python \
50 python-dev \
Matthew Barthccb7f852016-11-23 17:43:02 -060051 python-git \
Matthew Barthb4aea672016-11-10 14:59:52 -060052 python-setuptools \
53 pkg-config \
54 autoconf \
55 libsystemd-dev \
56 sudo \
57 wget \
58 git
59
60RUN wget http://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2016.09.16.tar.xz
61RUN tar -xJf autoconf-archive-2016.09.16.tar.xz
62RUN cd autoconf-archive-2016.09.16 && ./configure --prefix=/usr && make && make install
63
64RUN wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
65RUN tar -xzf release-1.7.0.tar.gz
66RUN cd googletest-release-1.7.0 && cmake -DBUILD_SHARED_LIBS=ON . && make && \
67cp -a include/gtest /usr/include && \
68cp -a libgtest_main.so libgtest.so /usr/lib/
69
70RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
71RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
72
Matthew Barthccb7f852016-11-23 17:43:02 -060073RUN echo '${AUTOM4TE}' > ${AUTOM4TE_CFG}
74
Matthew Barthb4aea672016-11-10 14:59:52 -060075RUN /bin/bash
76EOF
77)
78fi
79################################# docker img # #################################
80
81# Build above image
82docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"