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#   param2: <optional, the distro to build a docker image against>
9#            default is ubuntu:artful
10
11set -uo pipefail
12
13DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
14DISTRO=${2:-"ubuntu:artful"}
15
16# Determine our architecture, ppc64le or the other one
17if [ $(uname -m) == "ppc64le" ]; then
18    DOCKER_BASE="ppc64le/"
19else
20    DOCKER_BASE=""
21fi
22
23################################# docker img # #################################
24# Create docker image that can run QEMU and Robot Tests
25Dockerfile=$(cat << EOF
26FROM ${DOCKER_BASE}${DISTRO}
27
28ENV DEBIAN_FRONTEND noninteractive
29
30RUN apt-get update && apt-get install -yy \
31    debianutils \
32    gawk \
33    git \
34    python \
35    python-dev \
36    python-setuptools \
37    python3 \
38    python3-dev \
39    python3-setuptools \
40    socat \
41    texinfo \
42    wget \
43    gcc \
44    libffi-dev \
45    libssl-dev \
46    xterm \
47    mwm \
48    ssh \
49    vim \
50    iputils-ping \
51    sudo \
52    cpio \
53    unzip \
54    diffstat \
55    expect \
56    curl \
57    build-essential \
58    libpixman-1-0 \
59    libglib2.0-0 \
60    sshpass \
61    libasound2 \
62    libfdt1 \
63    libpcre3 \
64    openssl \
65    libxml2-dev \
66    libxslt-dev \
67    python3-pip
68
69RUN easy_install \
70    tox \
71    pip \
72    requests
73
74RUN pip install \
75    json2yaml \
76    robotframework \
77    robotframework-requests \
78    robotframework-sshlibrary \
79    robotframework-scplibrary \
80    pysnmp \
81    redfish
82
83RUN pip3 install \
84    beautifulsoup4 --upgrade \
85    lxml \
86    jsonschema \
87    redfishtool
88
89RUN wget https://sourceforge.net/projects/ipmitool/files/ipmitool/1.8.18/ipmitool-1.8.18.tar.bz2
90RUN tar xvfj ipmitool-*.tar.bz2
91RUN ./ipmitool-1.8.18/configure
92RUN make
93RUN make install
94
95RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
96RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} \
97                    ${USER}
98USER ${USER}
99ENV HOME ${HOME}
100RUN /bin/bash
101EOF
102)
103
104################################# docker img # #################################
105
106# Build above image
107docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"
108