From 003a22ca6eafbf44b1c7b646baf6244973b90bb3 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Mon, 27 May 2024 01:25:03 +0200 Subject: [PATCH] feat: install AUR packages --- ansible/arch_packages.json | 2 +- ansible/roles/aur/defaults/main.yaml | 1 + ansible/roles/aur/tasks/backend-makepkg.yaml | 35 ++++++++++++++++++++ ansible/roles/aur/tasks/main.yaml | 5 +++ ansible/vm_files | 2 +- ansible/workstation.yaml | 13 ++++---- 6 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 ansible/roles/aur/defaults/main.yaml create mode 100644 ansible/roles/aur/tasks/backend-makepkg.yaml diff --git a/ansible/arch_packages.json b/ansible/arch_packages.json index 0b4436d..5b02595 100644 --- a/ansible/arch_packages.json +++ b/ansible/arch_packages.json @@ -1 +1 @@ -["util-linux", "less", "git", "moreutils", "tmux", "openssh", "base-devel", "moreutils", "fzf", "lf", "ripgrep", "fd", "bat", "pv", "at", "jo", "jq", "fx", "yq", "xsv", "unzip", "unoconv", "pandoc", "libqalculate", "wget", "nmap", "wireguard-tools", "tcpdump", "socat", "rsync", "rclone", "lsof", "w3m", "acpi", "smartmontools", "lshw", "dmidecode", "ffmpeg", "imagemagick", "mpv", "yt-dlp", "tesseract", "tesseract-data-fra", "tesseract-data-eng", "gopass", "vim", "helix", "gcc", "make", "cmake", "libxkbcommon", "jwt-cli", "fish", "zoxide", "dash", "pavucontrol", "wev", "wtype", "wl-clipboard", "wofi", "sway", "swaylock", "swayidle", "cliphist", "firefox-developer-edition", "torbrowser-launcher", "alacritty", "thunderbird", "zathura", "krita", "inkscape", "libreoffice-still", "ttf-font-awesome", "ttf-fira-code"] +["util-linux", "less", "git", "moreutils", "tmux", "openssh", "base-devel", "moreutils", "fzf", "lf", "ripgrep", "fd", "bat", "pv", "at", "jo", "jq", "fx", "yq", "xsv", "unzip", "unoconv", "pandoc", "libqalculate", "wget", "nmap", "wireguard-tools", "tcpdump", "socat", "rsync", "rclone", "lsof", "w3m", "acpi", "smartmontools", "lshw", "dmidecode", "usbutils", "ffmpeg", "imagemagick", "mpv", "yt-dlp", "tesseract", "tesseract-data-fra", "tesseract-data-eng", "gopass", "vim", "helix", "gcc", "make", "cmake", "libxkbcommon", "jwt-cli", "fish", "zoxide", "dash", "pavucontrol", "wev", "wtype", "wl-clipboard", "wofi", "sway", "swaylock", "swayidle", "cliphist", "firefox-developer-edition", "torbrowser-launcher", "alacritty", "thunderbird", "zathura", "krita", "inkscape", "libreoffice-still", "ttf-font-awesome", "ttf-fira-code"] diff --git a/ansible/roles/aur/defaults/main.yaml b/ansible/roles/aur/defaults/main.yaml new file mode 100644 index 0000000..d16e7bc --- /dev/null +++ b/ansible/roles/aur/defaults/main.yaml @@ -0,0 +1 @@ +makepkg_aur_url: https://aur.archlinux.org/cgit/aur.git/snapshot/ diff --git a/ansible/roles/aur/tasks/backend-makepkg.yaml b/ansible/roles/aur/tasks/backend-makepkg.yaml new file mode 100644 index 0000000..4dbf41e --- /dev/null +++ b/ansible/roles/aur/tasks/backend-makepkg.yaml @@ -0,0 +1,35 @@ +# Inputs: +# package_name: name of the package to download and build (i.e. yay-bin) +# build_user: user we will sudo to when building. Must be able to use +# passwordless sudo +- name: Check if package {{ package_name }} is already installed + shell: set -o pipefail || exit 1; pacman -Qsq | + { grep '^'{{ package_name | quote }}'$' ; [ $? -lt 2 ]; } + register: _package_installed + changed_when: no + +- name: Make and install {{ package_name }} + become: yes + become_user: "aur_builder" + when: _package_installed.stdout == "" + block: + - name: Create temporary build directory + tempfile: + state: directory + register: _tempdir + + - name: Download package from the AUR + unarchive: + remote_src: yes + src: "{{ makepkg_aur_url }}{{ package_name }}.tar.gz" + dest: "{{ _tempdir.path }}" + + - name: Run makepkg + shell: cd '{{ _tempdir.path | quote }}/{{ package_name | quote }}' && makepkg -rsi --noconfirm + always: + - name: Remove temporary build directory + file: + state: absent + path: "{{ _tempdir.path }}" + + diff --git a/ansible/roles/aur/tasks/main.yaml b/ansible/roles/aur/tasks/main.yaml index e69de29..58fbc9c 100644 --- a/ansible/roles/aur/tasks/main.yaml +++ b/ansible/roles/aur/tasks/main.yaml @@ -0,0 +1,5 @@ +- name: Run the installation backend + include_tasks: backend-makepkg.yaml + loop: "{{ packages }}" + loop_control: + loop_var: package_name diff --git a/ansible/vm_files b/ansible/vm_files index 6215164..250ed9e 120000 --- a/ansible/vm_files +++ b/ansible/vm_files @@ -1 +1 @@ -/home/mbess/workspace/monakhos/sandbox_vms/vm1 \ No newline at end of file +/mnt/extramedia3/mbess/workspace/monakhos/sandbox_vms/vm1 \ No newline at end of file diff --git a/ansible/workstation.yaml b/ansible/workstation.yaml index 1a785c9..666b3ac 100644 --- a/ansible/workstation.yaml +++ b/ansible/workstation.yaml @@ -146,13 +146,12 @@ mode: 0644 validate: 'visudo -cf %s' - - name: Install yay using makepkg - kewlfft.aur.aur: - name: yay - use: makepkg - state: present - become: yes - become_user: aur_builder + - name: Install yay + import_role: + name: aur + vars: + packages: + - yay-bin # - name: Clone books sources # ansible.builtin.git: