Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | # |
| 3 | # Build the required docker image to run QEMU and Robot test cases |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame^] | 4 | |
| 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. |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 9 | # |
| 10 | # Parameters: |
| 11 | # parm1: <optional, the name of the docker image to generate> |
| 12 | # default is openbmc/ubuntu-robot-qemu |
Andrew Geissler | 8b8333b | 2018-05-29 13:51:58 -0500 | [diff] [blame] | 13 | # param2: <optional, the distro to build a docker image against> |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 14 | # default is ubuntu:bionic |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 15 | |
| 16 | set -uo pipefail |
| 17 | |
Lei YU | d374874 | 2020-05-12 19:34:26 +0800 | [diff] [blame] | 18 | http_proxy=${http_proxy:-} |
| 19 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 20 | DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"} |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 21 | DISTRO=${2:-"ubuntu:bionic"} |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame^] | 22 | UBUNTU_MIRROR=${UBUNTU_MIRROR:-""} |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 23 | |
| 24 | # Determine our architecture, ppc64le or the other one |
| 25 | if [ $(uname -m) == "ppc64le" ]; then |
| 26 | DOCKER_BASE="ppc64le/" |
| 27 | else |
| 28 | DOCKER_BASE="" |
| 29 | fi |
| 30 | |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame^] | 31 | MIRROR="" |
| 32 | if [[ -n "${UBUNTU_MIRROR}" ]]; then |
| 33 | MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \ |
| 34 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 35 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 36 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 37 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list" |
| 38 | fi |
| 39 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 40 | ################################# docker img # ################################# |
| 41 | # Create docker image that can run QEMU and Robot Tests |
| 42 | Dockerfile=$(cat << EOF |
Andrew Geissler | 8b8333b | 2018-05-29 13:51:58 -0500 | [diff] [blame] | 43 | FROM ${DOCKER_BASE}${DISTRO} |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 44 | |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame^] | 45 | ${MIRROR} |
| 46 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 47 | ENV DEBIAN_FRONTEND noninteractive |
| 48 | |
| 49 | RUN apt-get update && apt-get install -yy \ |
| 50 | debianutils \ |
| 51 | gawk \ |
| 52 | git \ |
| 53 | python \ |
| 54 | python-dev \ |
| 55 | python-setuptools \ |
Saqib Khan | 362ca85 | 2017-03-21 10:48:46 -0500 | [diff] [blame] | 56 | python3 \ |
| 57 | python3-dev \ |
| 58 | python3-setuptools \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 59 | socat \ |
| 60 | texinfo \ |
| 61 | wget \ |
| 62 | gcc \ |
| 63 | libffi-dev \ |
| 64 | libssl-dev \ |
| 65 | xterm \ |
| 66 | mwm \ |
| 67 | ssh \ |
| 68 | vim \ |
| 69 | iputils-ping \ |
| 70 | sudo \ |
| 71 | cpio \ |
| 72 | unzip \ |
| 73 | diffstat \ |
| 74 | expect \ |
Rahul Maheshwari | 6b9bb1e | 2017-03-13 06:56:12 -0500 | [diff] [blame] | 75 | curl \ |
Andrew Geissler | 7a88f29 | 2018-01-04 15:16:02 -0600 | [diff] [blame] | 76 | build-essential \ |
| 77 | libpixman-1-0 \ |
Michael Walsh | f1e8376 | 2018-03-28 15:51:43 -0500 | [diff] [blame] | 78 | libglib2.0-0 \ |
Andrew Jeffery | 6ba6814 | 2018-04-05 13:30:52 +0930 | [diff] [blame] | 79 | sshpass \ |
| 80 | libasound2 \ |
| 81 | libfdt1 \ |
Rahul Maheshwari | 7285ddb | 2018-09-20 00:01:40 -0500 | [diff] [blame] | 82 | libpcre3 \ |
George Keishing | b76c0b6 | 2019-02-25 13:16:52 -0600 | [diff] [blame] | 83 | openssl \ |
| 84 | libxml2-dev \ |
George Keishing | 26dd8e1 | 2019-02-26 12:31:11 -0600 | [diff] [blame] | 85 | libxslt-dev \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 86 | python3-pip \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 87 | ipmitool \ |
| 88 | xvfb |
| 89 | |
| 90 | RUN apt-get update -qqy \ |
| 91 | && apt-get -qqy --no-install-recommends install firefox \ |
| 92 | && wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/72.0/linux-x86_64/en-US/firefox-72.0.tar.bz2 \ |
| 93 | && apt-get -y purge firefox \ |
| 94 | && tar -C /opt -xjf /tmp/firefox.tar.bz2 \ |
| 95 | && mv /opt/firefox /opt/firefox-72.0 \ |
| 96 | && ln -fs /opt/firefox-72.0/firefox /usr/bin/firefox |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 97 | |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 98 | RUN pip3 install \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 99 | tox \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 100 | requests \ |
Michael Shepos | a4d6d3d | 2019-08-15 17:11:56 -0500 | [diff] [blame] | 101 | retrying \ |
Matthew Barth | 04881eb | 2019-09-30 13:28:18 -0500 | [diff] [blame] | 102 | websocket-client \ |
Alanny Lopez | 8594e43 | 2017-05-17 15:42:59 -0500 | [diff] [blame] | 103 | json2yaml \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 104 | robotframework \ |
| 105 | robotframework-requests \ |
| 106 | robotframework-sshlibrary \ |
Sunil M | 55d0d75 | 2018-03-22 07:04:17 -0500 | [diff] [blame] | 107 | robotframework-scplibrary \ |
George Keishing | 0e5dd8a | 2018-12-02 23:17:59 -0600 | [diff] [blame] | 108 | pysnmp \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 109 | redfish \ |
George Keishing | 26dd8e1 | 2019-02-26 12:31:11 -0600 | [diff] [blame] | 110 | beautifulsoup4 --upgrade \ |
George Keishing | 882254f | 2019-03-05 13:55:29 -0600 | [diff] [blame] | 111 | lxml \ |
George Keishing | 428553d | 2019-04-02 10:04:11 -0500 | [diff] [blame] | 112 | jsonschema \ |
George Keishing | ae29c89 | 2019-10-04 10:49:03 -0500 | [diff] [blame] | 113 | redfishtool \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 114 | redfish_utilities \ |
| 115 | robotframework-httplibrary \ |
| 116 | robotframework-seleniumlibrary \ |
| 117 | robotframework-xvfb \ |
| 118 | robotframework-angularjs \ |
| 119 | scp \ |
| 120 | selenium==3.141.0 \ |
| 121 | urllib3 \ |
| 122 | xvfbwrapper |
| 123 | |
| 124 | RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz \ |
| 125 | && tar xvzf geckodriver-*.tar.gz \ |
| 126 | && mv geckodriver /usr/local/bin \ |
| 127 | && chmod a+x /usr/local/bin/geckodriver |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 128 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 129 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 130 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} \ |
| 131 | ${USER} |
| 132 | USER ${USER} |
| 133 | ENV HOME ${HOME} |
| 134 | RUN /bin/bash |
| 135 | EOF |
| 136 | ) |
| 137 | |
| 138 | ################################# docker img # ################################# |
| 139 | |
Lei YU | d374874 | 2020-05-12 19:34:26 +0800 | [diff] [blame] | 140 | PROXY_ARGS="" |
| 141 | if [[ -n "${http_proxy}" ]]; then |
| 142 | PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}" |
| 143 | fi |
| 144 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 145 | # Build above image |
Lei YU | d374874 | 2020-05-12 19:34:26 +0800 | [diff] [blame] | 146 | docker build ${PROXY_ARGS} -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}" |