Fixed Paru installation role

This commit is contained in:
2026-07-27 06:32:05 +02:00
parent 376202caf2
commit ace626ba0f
+35 -14
View File
@@ -1,21 +1,17 @@
- name: Check if paru is already installed - name: Check if paru is already installed
ansible.builtin.pacman: ansible.builtin.command:
name: paru argv:
state: present - pacman
check_mode: true - -Qq
- paru
register: is_paru_installed register: is_paru_installed
changed_when: false
failed_when: false
- name: Stop the role if paru is already installed - name: Stop the role if paru is already installed
when: not is_paru_installed.changed when: is_paru_installed.rc == 0
ansible.builtin.meta: end_role ansible.builtin.meta: end_role
- name: Ensure build prerequisites are present
become: true
ansible.builtin.pacman:
name:
- base-devel
- fakeroot
- name: Create temporary dir for build - name: Create temporary dir for build
ansible.builtin.tempfile: ansible.builtin.tempfile:
state: directory state: directory
@@ -33,9 +29,29 @@
dest: "{{ paru_tmp.path }}" dest: "{{ paru_tmp.path }}"
remote_src: true 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) - name: Build the package (no install)
ansible.builtin.command: ansible.builtin.command:
cmd: makepkg --syncdeps --noconfirm argv:
- makepkg
- --noconfirm
chdir: "{{ paru_tmp.path }}/paru" chdir: "{{ paru_tmp.path }}/paru"
environment: environment:
PKGDEST: "{{ paru_tmp.path }}/paru" PKGDEST: "{{ paru_tmp.path }}/paru"
@@ -44,6 +60,7 @@
ansible.builtin.find: ansible.builtin.find:
paths: "{{ paru_tmp.path }}/paru" paths: "{{ paru_tmp.path }}/paru"
patterns: "*.pkg.tar.zst" patterns: "*.pkg.tar.zst"
excludes: "*-debug-*"
file_type: file file_type: file
register: built_pkgs register: built_pkgs
@@ -51,7 +68,11 @@
- name: Install built package(s) - name: Install built package(s)
become: true become: true
ansible.builtin.command: ansible.builtin.command:
cmd: "pacman -U --noconfirm {{ item.path }}" argv:
- pacman
- -U
- --noconfirm
- "{{ item.path }}"
creates: /usr/bin/paru creates: /usr/bin/paru
loop: "{{ built_pkgs.files }}" loop: "{{ built_pkgs.files }}"