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
28    - name: Update apt cache / upgrade packages via apt
29      apt:
30        update_cache: yes
31        upgrade: yes
32      when:
33        - ansible_facts['distribution'] == 'Ubuntu'
34
35    # the package lists are updated by "make lcitool-refresh"
36    - name: Include package lists based on OS and architecture
37      include_vars:
38        file: "ubuntu-2204-{{ ansible_facts['architecture'] }}.yaml"
39      when:
40        - ansible_facts['distribution'] == 'Ubuntu'
41        - ansible_facts['distribution_version'] == '22.04'
42        - ansible_facts['architecture'] == 'aarch64' or ansible_facts['architecture'] == 'x86_64'
43
44    - name: Install packages for QEMU on Ubuntu 22.04
45      package:
46        name: "{{ packages }}"
47      when:
48        - ansible_facts['distribution'] == 'Ubuntu'
49        - ansible_facts['distribution_version'] == '22.04'
50        - ansible_facts['architecture'] == 'aarch64' or ansible_facts['architecture'] == 'x86_64'
51
52    - name: Install armhf cross-compile packages to build QEMU on AArch64 Ubuntu 22.04
53      package:
54        name:
55          - binutils-arm-linux-gnueabihf
56          - gcc-arm-linux-gnueabihf
57          - libblkid-dev:armhf
58          - libc6-dev:armhf
59          - libffi-dev:armhf
60          - libglib2.0-dev:armhf
61          - libmount-dev:armhf
62          - libpcre2-dev:armhf
63          - libpixman-1-dev:armhf
64          - zlib1g-dev:armhf
65      when:
66        - ansible_facts['distribution'] == 'Ubuntu'
67        - ansible_facts['distribution_version'] == '22.04'
68        - ansible_facts['architecture'] == 'aarch64'
69
70