xref: /qemu/scripts/ci/setup/build-environment.yml (revision 5ac034b1)
1# Copyright (c) 2021 Red Hat, Inc.
2#
3# Author:
4#  Cleber Rosa <crosa@redhat.com>
5#
6# This work is licensed under the terms of the GNU GPL, version 2 or
7# later.  See the COPYING file in the top-level directory.
8#
9# This is an ansible playbook file.  Run it to set up systems with the
10# environment needed to build QEMU.
11---
12- name: Installation of basic packages to build QEMU
13  hosts: all
14  tasks:
15    - name: Check for suitable ansible version
16      delegate_to: localhost
17      assert:
18        that:
19          - '((ansible_version.major == 2) and (ansible_version.minor >= 8)) or (ansible_version.major >= 3)'
20        msg: "Unsuitable ansible version, please use version 2.8.0 or later"
21
22    - name: Add armhf foreign architecture to aarch64 hosts
23      command: dpkg --add-architecture armhf
24      when:
25        - ansible_facts['distribution'] == 'Ubuntu'
26        - ansible_facts['architecture'] == 'aarch64'
27        - ansible_facts['distribution_version'] == '20.04'
28
29    - name: Update apt cache / upgrade packages via apt
30      apt:
31        update_cache: yes
32        upgrade: yes
33      when:
34        - ansible_facts['distribution'] == 'Ubuntu'
35
36    - name: Install basic packages to build QEMU on Ubuntu 20.04
37      package:
38        name:
39          - ccache
40          - gcc
41          - gettext
42          - git
43          - glusterfs-common
44          - libaio-dev
45          - libattr1-dev
46          - libbrlapi-dev
47          - libbz2-dev
48          - libcacard-dev
49          - libcapstone-dev
50          - libcap-ng-dev
51          - libcurl4-gnutls-dev
52          - libdrm-dev
53          - libepoxy-dev
54          - libfdt-dev
55          - libgbm-dev
56          - libgtk-3-dev
57          - libibverbs-dev
58          - libiscsi-dev
59          - libjemalloc-dev
60          - libjpeg-turbo8-dev
61          - liblzo2-dev
62          - libncurses5-dev
63          - libncursesw5-dev
64          - libnfs-dev
65          - libnss3-dev
66          - libnuma-dev
67          - libpixman-1-dev
68          - librados-dev
69          - librbd-dev
70          - librdmacm-dev
71          - libsasl2-dev
72          - libsdl2-dev
73          - libseccomp-dev
74          - libsnappy-dev
75          - libspice-protocol-dev
76          - libssh-dev
77          - libusb-1.0-0-dev
78          - libusbredirhost-dev
79          - libvdeplug-dev
80          - libvte-2.91-dev
81          - libzstd-dev
82          - make
83          - python3-yaml
84          - python3-sphinx
85          - python3-sphinx-rtd-theme
86          - ninja-build
87          - sparse
88          - xfslibs-dev
89        state: present
90      when:
91        - ansible_facts['distribution'] == 'Ubuntu'
92
93    - name: Install packages to build QEMU on Ubuntu 20.04 on non-s390x
94      package:
95        name:
96          - libspice-server-dev
97          - libxen-dev
98        state: present
99      when:
100        - ansible_facts['distribution'] == 'Ubuntu'
101        - ansible_facts['architecture'] == 'aarch64' or ansible_facts['architecture'] == 'x86_64'
102
103    - name: Install basic packages to build QEMU on Ubuntu 20.04
104      package:
105        name:
106        # Originally from tests/docker/dockerfiles/ubuntu2004.docker
107          - clang-10
108          - genisoimage
109          - liblttng-ust-dev
110          - libslirp-dev
111          - netcat-openbsd
112      when:
113        - ansible_facts['distribution'] == 'Ubuntu'
114        - ansible_facts['distribution_version'] == '20.04'
115
116    - name: Install armhf cross-compile packages to build QEMU on AArch64 Ubuntu 20.04
117      package:
118        name:
119          - binutils-arm-linux-gnueabihf
120          - gcc-arm-linux-gnueabihf
121          - libblkid-dev:armhf
122          - libc6-dev:armhf
123          - libffi-dev:armhf
124          - libglib2.0-dev:armhf
125          - libmount-dev:armhf
126          - libpcre2-dev:armhf
127          - libpixman-1-dev:armhf
128          - zlib1g-dev:armhf
129      when:
130        - ansible_facts['distribution'] == 'Ubuntu'
131        - ansible_facts['distribution_version'] == '20.04'
132        - ansible_facts['architecture'] == 'aarch64'
133
134    - name: Enable EPEL repo on EL8
135      dnf:
136        name:
137          - epel-release
138        state: present
139      when:
140        - ansible_facts['distribution_file_variety'] in ['RedHat', 'CentOS']
141        - ansible_facts['distribution_major_version'] == '8'
142
143    - name: Enable PowerTools repo on CentOS 8
144      ini_file:
145        path: /etc/yum.repos.d/CentOS-Stream-PowerTools.repo
146        section: powertools
147        option: enabled
148        value: "1"
149      when:
150        - ansible_facts['distribution_file_variety'] == 'CentOS'
151        - ansible_facts['distribution_major_version'] == '8'
152
153    - name: Install basic packages to build QEMU on EL8
154      dnf:
155        # This list of packages start with tests/docker/dockerfiles/centos8.docker
156        # but only include files that are common to all distro variants and present
157        # in the standard repos (no add-ons)
158        name:
159          - bzip2
160          - bzip2-devel
161          - capstone-devel
162          - dbus-daemon
163          - device-mapper-multipath-devel
164          - diffutils
165          - gcc
166          - gcc-c++
167          - genisoimage
168          - gettext
169          - git
170          - glib2-devel
171          - glusterfs-api-devel
172          - gnutls-devel
173          - libaio-devel
174          - libcap-ng-devel
175          - libcurl-devel
176          - libepoxy-devel
177          - libfdt-devel
178          - libgcrypt-devel
179          - libiscsi-devel
180          - libpmem-devel
181          - librados-devel
182          - librbd-devel
183          - libseccomp-devel
184          - libssh-devel
185          - libxkbcommon-devel
186          - lzo-devel
187          - make
188          - mesa-libEGL-devel
189          - nettle-devel
190          - ninja-build
191          - nmap-ncat
192          - numactl-devel
193          - pixman-devel
194          - python38
195          - python3-sphinx
196          - rdma-core-devel
197          - redhat-rpm-config
198          - snappy-devel
199          - spice-glib-devel
200          - systemd-devel
201          - systemtap-sdt-devel
202          - tar
203          - zlib-devel
204        state: present
205      when:
206        - ansible_facts['distribution_file_variety'] in ['RedHat', 'CentOS']
207        - ansible_facts['distribution_version'] == '8'
208
209    - name: Install packages only available on x86 and aarch64
210      dnf:
211        # Spice server not available in ppc64le
212        name:
213          - spice-server
214          - spice-server-devel
215        state: present
216      when:
217        - ansible_facts['distribution_file_variety'] in ['RedHat', 'CentOS']
218        - ansible_facts['distribution_version'] == '8'
219        - ansible_facts['architecture'] == 'aarch64' or ansible_facts['architecture'] == 'x86_64'
220
221    - name: Check whether the Python runtime version is managed by alternatives
222      stat:
223        path: /etc/alternatives/python3
224      register: python3
225
226    - name: Set default Python runtime to 3.8 on EL8
227      command: alternatives --set python3 /usr/bin/python3.8
228      when:
229        - ansible_facts['distribution_file_variety'] in ['RedHat', 'CentOS']
230        - ansible_facts['distribution_version'] == '8'
231        - python3.stat.islnk and python3.stat.lnk_target != '/usr/bin/python3.8'
232