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 | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 53 | python-setuptools \ |
| 54 | pkg-config \ |
| 55 | autoconf \ |
| 56 | libsystemd-dev \ |
| 57 | sudo \ |
| 58 | wget \ |
| 59 | git |
| 60 | |
| 61 | RUN wget http://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2016.09.16.tar.xz |
| 62 | RUN tar -xJf autoconf-archive-2016.09.16.tar.xz |
| 63 | RUN cd autoconf-archive-2016.09.16 && ./configure --prefix=/usr && make && make install |
| 64 | |
| 65 | RUN wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz |
| 66 | RUN tar -xzf release-1.7.0.tar.gz |
| 67 | RUN cd googletest-release-1.7.0 && cmake -DBUILD_SHARED_LIBS=ON . && make && \ |
| 68 | cp -a include/gtest /usr/include && \ |
| 69 | cp -a libgtest_main.so libgtest.so /usr/lib/ |
| 70 | |
| 71 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 72 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
| 73 | |
Matthew Barth | ccb7f85 | 2016-11-23 17:43:02 -0600 | [diff] [blame] | 74 | RUN echo '${AUTOM4TE}' > ${AUTOM4TE_CFG} |
| 75 | |
Matthew Barth | b4aea67 | 2016-11-10 14:59:52 -0600 | [diff] [blame] | 76 | RUN /bin/bash |
| 77 | EOF |
| 78 | ) |
| 79 | fi |
| 80 | ################################# docker img # ################################# |
| 81 | |
| 82 | # Build above image |
| 83 | docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}" |