# ansible tasks for installing libbytesize dependencies,
# see install-test-dependencies.yml for usage

---
##### Fedora
- name: Install basic build tools (Fedora)
  package:
    state: present
    name:
      - gcc
      - make
      - libtool
      - autoconf
      - automake
  when: ansible_distribution == 'Fedora'

- name: Install dnf-plugins-core for dnf builddep (Fedora)
  package: name=dnf-plugins-core state=present
  when: ansible_distribution == 'Fedora'

- name: Install build dependencies (Fedora)
  command: "dnf -y builddep libbytesize --nogpgcheck"
  when: ansible_distribution == 'Fedora'

- name: Install test dependencies (Fedora)
  package:
    state: present
    name:
      - glibc-all-langpacks
      - python3-polib
      - python3-pocketlint
      - python3-pylint
      - python3-pycodestyle
  when: ansible_distribution == 'Fedora'

##### CentOS
- name: Install basic build tools (CentOS)
  package:
    state: present
    name:
      - gcc
      - make
      - libtool
      - autoconf
      - automake
  when: ansible_distribution == 'CentOS'

- name: Install dnf-plugins-core for dnf builddep (CentOS)
  package: name=dnf-plugins-core state=present
  when: ansible_distribution == 'CentOS'

- name: Install build dependencies (CentOS)
  command: "dnf -y builddep libbytesize --nogpgcheck"
  when: ansible_distribution == 'CentOS'

- name: Install test dependencies (CentOS)
  package:
    state: present
    name:
      - glibc-all-langpacks
      - python3-pip
  when: ansible_distribution == 'CentOS'

- name: Install pylint, polib, pycodestyle and pocketlint using pip (CentOS)
  pip:
    name: ['pylint', 'pycodestyle', 'polib', 'pocketlint']
    executable: pip3
  when: ansible_distribution == 'CentOS'

##### Debian/Ubuntu
- name: Install basic build tools (Debian/Ubuntu)
  package:
    state: present
    name:
      - gcc
      - make
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Add source repositories (Debian/Ubuntu)
  shell: "grep '^deb ' /etc/apt/sources.list | perl -pe 's/deb /deb-src /' >> /etc/apt/sources.list"
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Update apt cache (Debian/Ubuntu)
  apt:
    update_cache: yes
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Install build dependencies (Debian/Ubuntu)
  apt:
    name: libbytesize
    state: build-dep
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Install test dependencies (Debian/Ubuntu)
  package:
    state: present
    name:
      - locales-all
      - python3-polib
      - python3-pip
      - pycodestyle
      - pylint
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Install pocketlint using pip (Debian/Ubuntu)
  pip:
    name: ['pocketlint']
    executable: pip3
    extra_args: --break-system-packages
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
