| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 1 | #!/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 |  | 
 | 11 | set -uo pipefail | 
 | 12 |  | 
 | 13 | DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-unit-test"} | 
 | 14 | DISTRO=${2:-"ubuntu:latest"} | 
 | 15 |  | 
| Matthew Barth | ccb7f85 | 2016-11-23 17:43:02 -0600 | [diff] [blame] | 16 | # Disable autom4te cache as workaround to permission issue | 
 | 17 | AUTOM4TE_CFG="/root/.autom4te.cfg" | 
 | 18 | AUTOM4TE="begin-language: \"Autoconf-without-aclocal-m4\"\nargs: --no-cache\n\ | 
 | 19 | end-language: \"Autoconf-without-aclocal-m4\"" | 
 | 20 |  | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 21 | # Determine the architecture | 
 | 22 | ARCH=$(uname -m) | 
 | 23 | case ${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 | 
 | 33 | esac | 
 | 34 |  | 
 | 35 | ################################# docker img # ################################# | 
 | 36 | # Create docker image that can run package unit tests | 
 | 37 | if [[ "${DISTRO}" == "ubuntu"* ]]; then | 
 | 38 | Dockerfile=$(cat << EOF | 
 | 39 | FROM ${DOCKER_BASE}${DISTRO} | 
 | 40 |  | 
 | 41 | ENV DEBIAN_FRONTEND noninteractive | 
 | 42 |  | 
 | 43 | RUN apt-get update && apt-get install -yy \ | 
 | 44 |     gcc \ | 
 | 45 |     g++ \ | 
 | 46 |     libc6-dev \ | 
 | 47 |     libtool \ | 
 | 48 |     cmake \ | 
 | 49 |     python \ | 
 | 50 |     python-dev \ | 
| Matthew Barth | ccb7f85 | 2016-11-23 17:43:02 -0600 | [diff] [blame] | 51 |     python-git \ | 
| Matthew Barth | 0e90f3c | 2017-01-16 13:43:05 -0600 | [diff] [blame] | 52 |     python-yaml \ | 
| Matthew Barth | 6cc35d8 | 2017-01-18 13:36:31 -0600 | [diff] [blame] | 53 |     python-mako \ | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 54 |     python-setuptools \ | 
| Saqib Khan | 362ca85 | 2017-03-21 10:48:46 -0500 | [diff] [blame] | 55 |     python3 \ | 
 | 56 |     python3-dev\ | 
 | 57 |     python3-yaml \ | 
 | 58 |     python3-mako \ | 
 | 59 |     python3-setuptools \ | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 60 |     pkg-config \ | 
 | 61 |     autoconf \ | 
 | 62 |     libsystemd-dev \ | 
| Matthew Barth | 92f9387 | 2017-02-08 11:19:27 -0600 | [diff] [blame] | 63 |     libssl-dev \ | 
| Matthew Barth | 550bc0d | 2017-04-10 13:25:50 -0500 | [diff] [blame] | 64 |     libevdev-dev \ | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 65 |     sudo \ | 
 | 66 |     wget \ | 
| Leonel Gonzalez | 13ca380 | 2017-03-07 14:08:44 -0600 | [diff] [blame] | 67 |     git \ | 
 | 68 |     dbus | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 69 |  | 
| Matthew Barth | a2366d9 | 2017-01-31 09:46:20 -0600 | [diff] [blame] | 70 | RUN easy_install pip | 
 | 71 | RUN pip install inflection | 
 | 72 |  | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 73 | RUN wget http://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2016.09.16.tar.xz | 
 | 74 | RUN tar -xJf autoconf-archive-2016.09.16.tar.xz | 
 | 75 | RUN cd autoconf-archive-2016.09.16 && ./configure --prefix=/usr && make && make install | 
 | 76 |  | 
| Brad Bishop | fb2adeb | 2017-05-30 18:25:14 -0400 | [diff] [blame] | 77 | RUN wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz | 
 | 78 | RUN tar -xzf release-1.8.0.tar.gz | 
 | 79 | RUN cd googletest-release-1.8.0 && cmake -DBUILD_SHARED_LIBS=ON . && make && \ | 
 | 80 | cp -a googletest/include/gtest /usr/include && \ | 
 | 81 | cp -a googlemock/include/gmock /usr/include && \ | 
 | 82 | cp -a googlemock/gtest/libgtest.so /usr/lib/ && \ | 
 | 83 | cp -a googlemock/gtest/libgtest_main.so /usr/lib/ && \ | 
 | 84 | cp -a googlemock/libgmock.so /usr/lib/ && \ | 
 | 85 | cp -a googlemock/libgmock_main.so /usr/lib/ | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 86 |  | 
 | 87 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} | 
 | 88 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} | 
 | 89 |  | 
| Matthew Barth | ccb7f85 | 2016-11-23 17:43:02 -0600 | [diff] [blame] | 90 | RUN echo '${AUTOM4TE}' > ${AUTOM4TE_CFG} | 
 | 91 |  | 
| Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 92 | RUN /bin/bash | 
 | 93 | EOF | 
 | 94 | ) | 
 | 95 | fi | 
 | 96 | ################################# docker img # ################################# | 
 | 97 |  | 
 | 98 | # Build above image | 
 | 99 | docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}" |