blob: 9be8869b4c713b95a6a5e64c4d13168b40f49a38 [file] [log] [blame]
Andrew Geissler0205e8d2016-08-10 07:46:19 -05001#!/bin/bash -xe
2#
3# Build the required docker image to run QEMU and Robot test cases
Lei YUba111ab2020-05-12 19:57:56 +08004
5# Script Variables:
6# UBUNTU_MIRROR: <optional, the URL of a mirror of Ubuntu to override the
7# default ones in /etc/apt/sources.list>
8# default is empty, and no mirror is used.
Lei YU51b6aec2020-05-13 11:32:03 +08009# PIP_MIRROR: <optional, the URL of a PIP mirror>
10# default is empty, and no mirror is used.
Andrew Geissler0205e8d2016-08-10 07:46:19 -050011#
12# Parameters:
13# parm1: <optional, the name of the docker image to generate>
14# default is openbmc/ubuntu-robot-qemu
Andrew Geissler8b8333b2018-05-29 13:51:58 -050015# param2: <optional, the distro to build a docker image against>
Andrew Geissler0205e8d2016-08-10 07:46:19 -050016
17set -uo pipefail
18
Lei YUd3748742020-05-12 19:34:26 +080019http_proxy=${http_proxy:-}
20
Andrew Geissler0205e8d2016-08-10 07:46:19 -050021DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
Nan Zhou86ae1352022-06-27 22:30:55 +000022DISTRO=${2:-"ubuntu:jammy"}
Lei YUba111ab2020-05-12 19:57:56 +080023UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Lei YU51b6aec2020-05-13 11:32:03 +080024PIP_MIRROR=${PIP_MIRROR:-""}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050025
26# Determine our architecture, ppc64le or the other one
Patrick Williams384d7412020-11-06 16:15:41 -060027if [ "$(uname -m)" == "ppc64le" ]; then
Andrew Geissler0205e8d2016-08-10 07:46:19 -050028 DOCKER_BASE="ppc64le/"
29else
30 DOCKER_BASE=""
31fi
32
Lei YUba111ab2020-05-12 19:57:56 +080033MIRROR=""
34if [[ -n "${UBUNTU_MIRROR}" ]]; then
35 MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
36 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
37 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
38 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
39 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
40fi
41
Lei YU51b6aec2020-05-13 11:32:03 +080042PIP_MIRROR_CMD=""
43if [[ -n "${PIP_MIRROR}" ]]; then
Patrick Williams384d7412020-11-06 16:15:41 -060044 PIP_HOSTNAME=$(echo "${PIP_MIRROR}" | awk -F[/:] '{print $4}')
Lei YU51b6aec2020-05-13 11:32:03 +080045 PIP_MIRROR_CMD="RUN mkdir -p \${HOME}/.pip && \
46 echo \"[global]\" > \${HOME}/.pip/pip.conf && \
47 echo \"index-url=${PIP_MIRROR}\" >> \${HOME}/.pip/pip.conf &&\
48 echo \"[install]\" >> \${HOME}/.pip/pip.conf &&\
49 echo \"trusted-host=${PIP_HOSTNAME}\" >> \${HOME}/.pip/pip.conf"
50fi
51
Andrew Geissler0205e8d2016-08-10 07:46:19 -050052################################# docker img # #################################
53# Create docker image that can run QEMU and Robot Tests
54Dockerfile=$(cat << EOF
Andrew Geissler8b8333b2018-05-29 13:51:58 -050055FROM ${DOCKER_BASE}${DISTRO}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050056
Lei YUba111ab2020-05-12 19:57:56 +080057${MIRROR}
58
Lei YU51b6aec2020-05-13 11:32:03 +080059ARG DEBIAN_FRONTEND=noninteractive
Andrew Geissler0205e8d2016-08-10 07:46:19 -050060
61RUN apt-get update && apt-get install -yy \
62 debianutils \
63 gawk \
64 git \
Nan Zhou86ae1352022-06-27 22:30:55 +000065 python2 \
66 python2-dev \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050067 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050068 python3 \
69 python3-dev \
70 python3-setuptools \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050071 socat \
72 texinfo \
73 wget \
74 gcc \
75 libffi-dev \
76 libssl-dev \
77 xterm \
78 mwm \
79 ssh \
80 vim \
81 iputils-ping \
82 sudo \
83 cpio \
84 unzip \
85 diffstat \
86 expect \
Rahul Maheshwari6b9bb1e2017-03-13 06:56:12 -050087 curl \
Andrew Geissler7a88f292018-01-04 15:16:02 -060088 build-essential \
Rahul Maheshwari3eafe342024-02-14 02:58:23 -060089 libdbus-glib-1-2 \
Andrew Geissler7a88f292018-01-04 15:16:02 -060090 libpixman-1-0 \
Michael Walshf1e83762018-03-28 15:51:43 -050091 libglib2.0-0 \
Andrew Jeffery6ba68142018-04-05 13:30:52 +093092 sshpass \
93 libasound2 \
94 libfdt1 \
Rahul Maheshwari7285ddb2018-09-20 00:01:40 -050095 libpcre3 \
Andrew Geissler851eaff2022-12-22 09:47:54 -060096 libslirp-dev \
George Keishingb76c0b62019-02-25 13:16:52 -060097 openssl \
98 libxml2-dev \
George Keishing26dd8e12019-02-26 12:31:11 -060099 libxslt-dev \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500100 python3-pip \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600101 ipmitool \
Andrew Geissler6ddfc292021-02-23 18:46:17 -0600102 xvfb \
103 rustc
Anusha Dathatri39b62802019-12-18 04:01:45 -0600104
105RUN apt-get update -qqy \
106 && apt-get -qqy --no-install-recommends install firefox \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500107 && wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/112.0.2/linux-x86_64/en-US/firefox-112.0.2.tar.bz2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600108 && apt-get -y purge firefox \
109 && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500110 && mv /opt/firefox /opt/firefox-112.0.2 \
111 && ln -fs /opt/firefox-112.0.2/firefox /usr/bin/firefox
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500112
Lei YU51b6aec2020-05-13 11:32:03 +0800113ENV HOME ${HOME}
114
115${PIP_MIRROR_CMD}
116
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500117RUN pip3 install \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500118 tox \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500119 requests \
Michael Sheposa4d6d3d2019-08-15 17:11:56 -0500120 retrying \
Matthew Barth04881eb2019-09-30 13:28:18 -0500121 websocket-client \
Alanny Lopez8594e432017-05-17 15:42:59 -0500122 json2yaml \
George Keishingeffe5082024-06-05 10:58:48 +0530123 robotframework==7.0 \
George Keishing09dcd892022-08-02 08:12:15 -0500124 robotframework-requests \
125 robotframework-jsonlibrary \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500126 robotframework-sshlibrary \
Sunil M55d0d752018-03-22 07:04:17 -0500127 robotframework-scplibrary \
George Keishing0e5dd8a2018-12-02 23:17:59 -0600128 pysnmp \
Jian Zhang8b362562022-09-22 21:21:15 +0800129 redfish>=3.1.7 \
George Keishing26dd8e12019-02-26 12:31:11 -0600130 beautifulsoup4 --upgrade \
George Keishing882254f2019-03-05 13:55:29 -0600131 lxml \
George Keishing428553d2019-04-02 10:04:11 -0500132 jsonschema \
George Keishingae29c892019-10-04 10:49:03 -0500133 redfishtool \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600134 redfish_utilities \
135 robotframework-httplibrary \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500136 robotframework-seleniumlibrary==6.0.0 \
137 robotframework-xvfb==1.2.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600138 robotframework-angularjs \
139 scp \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500140 selenium==4.8.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600141 urllib3 \
George Keishing092ec342021-08-04 01:01:51 -0500142 click \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500143 xvfbwrapper==0.2.9
Anusha Dathatri39b62802019-12-18 04:01:45 -0600144
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500145RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.32.2/geckodriver-v0.32.2-linux64.tar.gz \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600146 && tar xvzf geckodriver-*.tar.gz \
147 && mv geckodriver /usr/local/bin \
148 && chmod a+x /usr/local/bin/geckodriver
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500149
Patrick Williams384d7412020-11-06 16:15:41 -0600150RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
Nan Zhouc2796fe2022-01-28 21:28:00 +0000151RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -l -m -u ${UID} -g ${GROUPS[0]} \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500152 ${USER}
153USER ${USER}
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500154RUN /bin/bash
155EOF
156)
157
158################################# docker img # #################################
159
Lei YUd3748742020-05-12 19:34:26 +0800160PROXY_ARGS=""
161if [[ -n "${http_proxy}" ]]; then
Patrick Williams476a7e92022-12-06 09:52:53 -0600162 PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
Lei YUd3748742020-05-12 19:34:26 +0800163fi
164
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500165# Build above image
Patrick Williams384d7412020-11-06 16:15:41 -0600166# shellcheck disable=SC2086 # PROXY_ARGS is intentionally word-split.
167docker build ${PROXY_ARGS} -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}"