blob: b0cc4a3908bf527e9a6bffbef65167345da091d4 [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 Barth0e90f3c2017-01-16 13:43:05 -060052 python-yaml \
Matthew Barth6cc35d82017-01-18 13:36:31 -060053 python-mako \
Matthew Barthb4aea672016-11-10 14:59:52 -060054 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050055 python3 \
56 python3-dev\
57 python3-yaml \
58 python3-mako \
59 python3-setuptools \
Matthew Barthb4aea672016-11-10 14:59:52 -060060 pkg-config \
61 autoconf \
62 libsystemd-dev \
Matthew Barth92f93872017-02-08 11:19:27 -060063 libssl-dev \
Matthew Barth550bc0d2017-04-10 13:25:50 -050064 libevdev-dev \
Matthew Barthb4aea672016-11-10 14:59:52 -060065 sudo \
66 wget \
Leonel Gonzalez13ca3802017-03-07 14:08:44 -060067 git \
Saqib Khan5158a322017-10-23 11:31:24 -050068 dbus \
Andrew Geissler158b0a12018-01-10 10:46:48 -080069 iputils-ping \
70 clang-format-5.0
Matthew Barthb4aea672016-11-10 14:59:52 -060071
Matthew Bartha2366d92017-01-31 09:46:20 -060072RUN easy_install pip
73RUN pip install inflection
Adriana Kobylak3b02d3f2018-01-10 16:33:26 -060074RUN pip install pycodestyle
Matthew Bartha2366d92017-01-31 09:46:20 -060075
Matthew Barthb4aea672016-11-10 14:59:52 -060076RUN wget http://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2016.09.16.tar.xz
77RUN tar -xJf autoconf-archive-2016.09.16.tar.xz
78RUN cd autoconf-archive-2016.09.16 && ./configure --prefix=/usr && make && make install
79
Brad Bishopfb2adeb2017-05-30 18:25:14 -040080RUN wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
81RUN tar -xzf release-1.8.0.tar.gz
82RUN cd googletest-release-1.8.0 && cmake -DBUILD_SHARED_LIBS=ON . && make && \
83cp -a googletest/include/gtest /usr/include && \
84cp -a googlemock/include/gmock /usr/include && \
85cp -a googlemock/gtest/libgtest.so /usr/lib/ && \
86cp -a googlemock/gtest/libgtest_main.so /usr/lib/ && \
87cp -a googlemock/libgmock.so /usr/lib/ && \
88cp -a googlemock/libgmock_main.so /usr/lib/
Matthew Barthb4aea672016-11-10 14:59:52 -060089
Deepak Kodihallide7767c2017-06-21 02:19:14 -050090RUN wget https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz
91RUN tar -xzf v1.2.2.tar.gz
92RUN cp -a cereal-1.2.2/include/cereal/ /usr/include/
93
David Cobbleyedb53d12018-01-04 09:14:34 -080094RUN wget https://github.com/nlohmann/json/releases/download/v3.0.1/json.hpp
Andrew Geisslerd62aa342018-01-05 11:00:00 -060095RUN mkdir /usr/include/nlohmann/
David Cobbleyedb53d12018-01-04 09:14:34 -080096RUN cp -a json.hpp /usr/include/nlohmann/
David Cobbleye99c07a2017-12-22 11:39:01 -080097
Matthew Barthb4aea672016-11-10 14:59:52 -060098RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
99RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
100
Matthew Barthccb7f852016-11-23 17:43:02 -0600101RUN echo '${AUTOM4TE}' > ${AUTOM4TE_CFG}
102
Matthew Barthb4aea672016-11-10 14:59:52 -0600103RUN /bin/bash
104EOF
105)
106fi
107################################# docker img # #################################
108
109# Build above image
110docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"