fix(os-update): keep the pacman package cache empty #1579

Merged
k.renner merged 3 commits from fix/edge-pacman-cache into main 2026-11-06 12:03:23 +00:00
2 changed files with 42 additions and 0 deletions
@@ -0,0 +1,14 @@
# Managed by ansible (roles/os-update).
# Downloaded packages are not kept; older versions come from the Arch Linux
# Archive.
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Description = Removing downloaded packages from the cache...
When = PostTransaction
Exec = /usr/bin/find /var/cache/pacman/pkg -mindepth 1 -delete
+28
View File
@@ -25,6 +25,34 @@
check_mode: false
when: os_update_docker.stat.exists
# pacman keeps every downloaded package; on the edge hosts' 7 GB eMMC root
# the cache grows to gigabytes.
- name: Ensure the pacman hook directory exists (Arch)
ansible.builtin.file:
path: /etc/pacman.d/hooks
state: directory
mode: "0755"
when: ansible_facts['os_family'] == 'Archlinux'
- name: Empty the package cache after every transaction (Arch)
ansible.builtin.copy:
src: pacman-cache.hook
dest: /etc/pacman.d/hooks/pacman-cache.hook
mode: "0644"
when: ansible_facts['os_family'] == 'Archlinux'
- name: Empty the package cache (Arch)
ansible.builtin.command:
argv: [find, /var/cache/pacman/pkg, -mindepth, "1", -delete, -print]
register: os_update_pacman_cache
changed_when: os_update_pacman_cache.stdout | length > 0
when: ansible_facts['os_family'] == 'Archlinux'
- name: Re-read mounts after the cache cleanup
ansible.builtin.setup:
gather_subset: [mounts]
when: os_update_pacman_cache is changed
- name: Assert at least 1 GiB free on /
ansible.builtin.assert:
that: >-