From 2250f520fed3960a62043c606398c96f8d7bedbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 2 Dec 2021 16:55:55 +0100 Subject: [PATCH] Make ghautomatrop work with Junest --- config/automatrop/.gitignore | 2 +- .../roles/desktop_environment/tasks/main.yml | 1 + config/automatrop/roles/facts/tasks/main.yml | 10 +++- .../roles/software/handlers/main.yml | 6 ++ .../automatrop/roles/software/tasks/main.yml | 60 ++++++++++++++----- .../templates/snippets/pm_data_management.j2 | 2 +- .../snippets/pm_terminal_essentials.j2 | 2 + config/automatrop/roles/vim/tasks/main.yml | 3 - config/automatrop/self_name | 1 + 9 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 config/automatrop/self_name diff --git a/config/automatrop/.gitignore b/config/automatrop/.gitignore index 801d1f7..206c8c2 100644 --- a/config/automatrop/.gitignore +++ b/config/automatrop/.gitignore @@ -1 +1 @@ -self_hostname +self_name diff --git a/config/automatrop/roles/desktop_environment/tasks/main.yml b/config/automatrop/roles/desktop_environment/tasks/main.yml index 54cf0b6..781be24 100644 --- a/config/automatrop/roles/desktop_environment/tasks/main.yml +++ b/config/automatrop/roles/desktop_environment/tasks/main.yml @@ -167,6 +167,7 @@ loop: - pulseaudio - mpd + when: has_systemd # TODO bar (might change bar in the future, so...) # TODO highlight (there IS a template but the colors look different from vim and mostly the same from when there's no config) diff --git a/config/automatrop/roles/facts/tasks/main.yml b/config/automatrop/roles/facts/tasks/main.yml index 4f06a62..fd07ad9 100644 --- a/config/automatrop/roles/facts/tasks/main.yml +++ b/config/automatrop/roles/facts/tasks/main.yml @@ -4,9 +4,17 @@ arch: "{{ ansible_lsb.id == 'Arch' }}" manjaro: "{{ ansible_lsb.id == 'Manjaro' or ansible_lsb.id == 'Manjaro-ARM' }}" termux: "{{ ansible_distribution == 'OtherLinux' and ansible_python.executable == '/data/data/com.termux/files/usr/bin/python' }}" - debian_based: "{{ ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' }}" debian: "{{ ansible_distribution == 'Debian' }}" ubuntu: "{{ ansible_distribution == 'Ubuntu' }}" + junest: "{{ ansible_distribution == 'Archlinux' and ansible_is_chroot }}" # TODO Check if /etc/junest exists + tags: + - always + +- name: Set composed facts + set_fact: + debian_based: "{{ debian or ubuntu }}" + can_chown: "{{ not junest }}" + has_systemd: "{{ not junest }}" tags: - always # TODO Make this a real Ansible fact maybe? diff --git a/config/automatrop/roles/software/handlers/main.yml b/config/automatrop/roles/software/handlers/main.yml index 66f7ee5..2f759f8 100644 --- a/config/automatrop/roles/software/handlers/main.yml +++ b/config/automatrop/roles/software/handlers/main.yml @@ -15,3 +15,9 @@ listen: "software changed" when: root_access when: arch_based + +- name: update pacman cache + pacman: + update_cache: yes + become: yes + when: arch_based diff --git a/config/automatrop/roles/software/tasks/main.yml b/config/automatrop/roles/software/tasks/main.yml index 9a9907c..9ef01ef 100644 --- a/config/automatrop/roles/software/tasks/main.yml +++ b/config/automatrop/roles/software/tasks/main.yml @@ -59,6 +59,30 @@ # Arch configuration +# TODO Patch sudo-fake so it allows using -u so `become` works + +- name: Enable multilib repo + lineinfile: + path: /etc/pacman.conf + regexp: '^#?\s*\[multilib\]$' + line: '[multilib]' + become: yes + when: arch_based and ansible_architecture == "x86_64" + notify: udpate pacman cache + +- name: Configure multilib repo + lineinfile: + path: /etc/pacman.conf + regexp: '^#?\s*Include\s*=\s*/etc/pacman.d/mirrorlist' + line: 'Include = /etc/pacman.d/mirrorlist' + insertafter: '^\[multilib\]$' + become: yes + when: arch_based and ansible_architecture == "x86_64" + notify: udpate pacman cache + +- name: Update cache if needed + meta: flush_handlers + - name: Install ccache pacman: name: ccache @@ -90,7 +114,6 @@ replace: "CFLAGS=\\1\\2" become: yes when: arch_based - tags: g - name: Change -march to native from makepkg CFLAGS replace: @@ -99,7 +122,6 @@ replace: "CFLAGS=\\1-march=native\\2\\3" become: yes when: arch_based - tags: g - name: Set makepkg MAKEFLAGS replace: @@ -140,24 +162,30 @@ # Install alternative package managers +- name: List packages from base-devel + command: pacman -Sqg base-devel + register: base_devel_packages + changed_when: no + check_mode: no + - name: Install dependencies for AUR helpers pacman: - name: - - fakeroot - - base-devel + name: "{{ (base_devel_packages.stdout | split('\n') | reject('eq', 'sudo')) + ['fakeroot'] }}" become: yes - when: arch_based and root_access + when: arch_based +# Do not install sudo because maybe sudo-fake is installed (otherwise it conflicts) +# It should already be installed already anyway - name: Install AUR package manager (Arch) aur: name: yay-bin - when: arch and root_access + when: arch - name: Install AUR package manager (Manjaro) pacman: name: yay become: yes - when: manjaro and root_access + when: manjaro # Not sure if regular Manjaro has yay in its community packages, # but Manjaro-ARM sure does @@ -172,13 +200,6 @@ packages: "{{ query('template', 'package_manager.j2')[0].split('\n')[:-1]|sort|unique }}" tags: softwarelist -- name: Check if list of packages changed - copy: - content: "{% for package in packages %}{{ package }}\n{% endfor %}" - dest: "{{ ansible_user_dir }}/.cache/automatrop/package_manager" - notify: "software changed" - tags: softwarelist - - name: Install packages (Arch-based) aur: name: "{{ packages }}" @@ -189,7 +210,14 @@ use: yay notify: "software changed" tags: softwarelist - when: arch_based and root_access + when: arch_based + +- name: Check if list of packages changed + copy: + content: "{% for package in packages %}{{ package }}\n{% endfor %}" + dest: "{{ ansible_user_dir }}/.cache/automatrop/package_manager" + notify: "software changed" + tags: softwarelist # translate-shell # $ curl -L git.io/trans > ~/.local/bin/trans diff --git a/config/automatrop/roles/software/templates/snippets/pm_data_management.j2 b/config/automatrop/roles/software/templates/snippets/pm_data_management.j2 index 75763f7..d6c2768 100644 --- a/config/automatrop/roles/software/templates/snippets/pm_data_management.j2 +++ b/config/automatrop/roles/software/templates/snippets/pm_data_management.j2 @@ -5,7 +5,7 @@ rsync borg syncthing {% if arch_based %} -{% if ansible_architecture == 'x86_64' %} +{% if ansible_architecture == 'x86_64' and can_chown %} freefilesync-bin {# Not worth the compilation if you can't have the binaries #} {% endif %} diff --git a/config/automatrop/roles/software/templates/snippets/pm_terminal_essentials.j2 b/config/automatrop/roles/software/templates/snippets/pm_terminal_essentials.j2 index 9350e26..69a99cd 100644 --- a/config/automatrop/roles/software/templates/snippets/pm_terminal_essentials.j2 +++ b/config/automatrop/roles/software/templates/snippets/pm_terminal_essentials.j2 @@ -1,7 +1,9 @@ moreutils man visidata +{% if can_chown or not arch_based %} insect +{% endif %} translate-shell gnupg {# Editor #} diff --git a/config/automatrop/roles/vim/tasks/main.yml b/config/automatrop/roles/vim/tasks/main.yml index 0b13399..fb63c5f 100644 --- a/config/automatrop/roles/vim/tasks/main.yml +++ b/config/automatrop/roles/vim/tasks/main.yml @@ -3,7 +3,6 @@ vim_variants: - vim - nvim - tags: g # TODO vim-minimal for bsh # TODO Select those in a clever way @@ -25,7 +24,6 @@ src: loader.j2 dest: "{{ ansible_user_dir }}/.config/vim/loader.vim" mode: "u=rw,g=r,o=r" - tags: g - name: Install theme template: @@ -54,4 +52,3 @@ loop: "{{ vim_variants }}" loop_control: loop_var: variant - tags: g diff --git a/config/automatrop/self_name b/config/automatrop/self_name new file mode 100644 index 0000000..90e6c19 --- /dev/null +++ b/config/automatrop/self_name @@ -0,0 +1 @@ +gho.geoffrey.frogeye.fr