1#!/bin/bash -xe
2#
3# Build the required docker image to run QEMU and Robot test cases
4#
5#  Parameters:
6#   parm1:  <optional, the name of the docker image to generate>
7#            default is openbmc/ubuntu-robot-qemu
8
9set -uo pipefail
10
11DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
12
13# Determine our architecture, ppc64le or the other one
14if [ $(uname -m) == "ppc64le" ]; then
15    DOCKER_BASE="ppc64le/"
16else
17    DOCKER_BASE=""
18fi
19
20################################# docker img # #################################
21# Create docker image that can run QEMU and Robot Tests
22Dockerfile=$(cat << EOF
23FROM ${DOCKER_BASE}ubuntu:latest
24
25ENV DEBIAN_FRONTEND noninteractive
26
27RUN apt-get update && apt-get install -yy \
28    debianutils \
29    gawk \
30    git \
31    python \
32    python-dev \
33    python-setuptools \
34    socat \
35    texinfo \
36    wget \
37    gcc \
38    libffi-dev \
39    libssl-dev \
40    xterm \
41    mwm \
42    ssh \
43    vim \
44    iputils-ping \
45    sudo \
46    cpio \
47    unzip \
48    diffstat \
49    expect \
50    curl
51
52RUN easy_install \
53    tox \
54    pip \
55    requests
56
57RUN pip install \
58    robotframework \
59    robotframework-requests \
60    robotframework-sshlibrary \
61    robotframework-scplibrary
62
63RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
64RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} \
65                    ${USER}
66USER ${USER}
67ENV HOME ${HOME}
68RUN /bin/bash
69EOF
70)
71
72################################# docker img # #################################
73
74# Build above image
75docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"
76