83 lines
2.0 KiB
YAML
83 lines
2.0 KiB
YAML
- name: Check if paru is already installed
|
|
ansible.builtin.command:
|
|
argv:
|
|
- pacman
|
|
- -Qq
|
|
- paru
|
|
register: is_paru_installed
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Stop the role if paru is already installed
|
|
when: is_paru_installed.rc == 0
|
|
ansible.builtin.meta: end_role
|
|
|
|
- name: Create temporary dir for build
|
|
ansible.builtin.tempfile:
|
|
state: directory
|
|
suffix: paru
|
|
register: paru_tmp
|
|
|
|
- name: Download the AUR snapshot
|
|
ansible.builtin.get_url:
|
|
url: "https://aur.archlinux.org/cgit/aur.git/snapshot/paru.tar.gz"
|
|
dest: "{{ paru_tmp.path }}/paru.tar.gz"
|
|
|
|
- name: Extract the snapshot
|
|
ansible.builtin.unarchive:
|
|
src: "{{ paru_tmp.path }}/paru.tar.gz"
|
|
dest: "{{ paru_tmp.path }}"
|
|
remote_src: true
|
|
|
|
- name: Read the package metadata
|
|
ansible.builtin.slurp:
|
|
src: "{{ paru_tmp.path }}/paru/.SRCINFO"
|
|
register: paru_srcinfo
|
|
|
|
- name: Extract build and runtime dependencies
|
|
ansible.builtin.set_fact:
|
|
paru_build_deps: >-
|
|
{{ (paru_srcinfo.content | b64decode)
|
|
| regex_findall('(?m)^\s*(?:make|check)?depends(?:_\w+)?\s*=\s*([^\s<>=]+)')
|
|
| unique }}
|
|
|
|
- name: Ensure build prerequisites are present
|
|
become: true
|
|
ansible.builtin.pacman:
|
|
name: "{{ ['base-devel', 'fakeroot'] + paru_build_deps }}"
|
|
state: present
|
|
|
|
- name: Build the package (no install)
|
|
ansible.builtin.command:
|
|
argv:
|
|
- makepkg
|
|
- --noconfirm
|
|
chdir: "{{ paru_tmp.path }}/paru"
|
|
environment:
|
|
PKGDEST: "{{ paru_tmp.path }}/paru"
|
|
|
|
- name: Locate built package(s)
|
|
ansible.builtin.find:
|
|
paths: "{{ paru_tmp.path }}/paru"
|
|
patterns: "*.pkg.tar.zst"
|
|
excludes: "*-debug-*"
|
|
file_type: file
|
|
register: built_pkgs
|
|
|
|
# Install with root, but OUTSIDE makepkg
|
|
- name: Install built package(s)
|
|
become: true
|
|
ansible.builtin.command:
|
|
argv:
|
|
- pacman
|
|
- -U
|
|
- --noconfirm
|
|
- "{{ item.path }}"
|
|
creates: /usr/bin/paru
|
|
loop: "{{ built_pkgs.files }}"
|
|
|
|
- name: Remove temporary directory
|
|
ansible.builtin.file:
|
|
path: "{{ paru_tmp.path }}"
|
|
state: absent
|