New way to install packages!

Probably the fourth I ever created?
Will this one last? I don't know!

Doesn't have pip support for now,
but probably something requirements.txt based
will be a bit more proper
prenix
Geoffrey Frogeye 2021-06-12 17:15:21 +02:00
parent ccc330d795
commit 59aaf63d4a
Signed by: geoffrey
GPG Key ID: C72403E7F82E6AD8
5 changed files with 108 additions and 77 deletions

View File

@ -0,0 +1,16 @@
- name: Create and install meta package for Arch Linux
block:
- name: Generate meta package PKGBUILD
template:
src: PKGBUILD.j2
dest: "{{ ansible_user_dir }}/.cache/automatrop/PKGBUILD"
listen: "software changed"
- name: Install meta package
aur:
name: "automatrop-packages-{{ inventory_hostname_short }}"
local_pkgbuild: "{{ ansible_user_dir }}/.cache/automatrop"
use: makepkg
state: latest
listen: "software changed"
when: arch_based

View File

@ -1,55 +0,0 @@
- name: Install base shell packages (Pacman)
pacman:
name:
- base
- coreutils
- bash
- grep
- sed
- tar
- openssl # Used for machines script
when: arch
- name: Install base shell packages (Apt)
apt:
name:
- coreutils
- bash
- grep
- sed
- tar
- openssl
when: apt
- name: Install extended shell packages (Pacman)
pacman:
name:
- moreutils
- tmux
- bash-completion
- fzf
- highlight
- powerline-go-bin
when: arch
- name: Install extended shell packages (Debian)
pacman:
name:
- moreutils
- tmux
- bash-completion
- fzf
- highlight
- powerline-go
when: debian
- name: Install extended shell packages (Termux)
pacman:
name:
- moreutils
- tmux
- bash-completion
- fzf
# - highlight
# - powerline-go
when: termux

View File

@ -1,16 +1,24 @@
- name: Set variables
set_fact:
arch: "{{ ansible_distribution == 'Archlinux' }}"
arch_based: "{{ ansible_distribution == 'Archlinux' }}"
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: "{{ ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' }}"
debian_based: "{{ ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' }}"
debian: "{{ ansible_distribution == 'Debian' }}"
ubuntu: "{{ ansible_distribution == 'Ubuntu' }}"
tags: softwarelist
# TODO Is this used?
- name: Set secondary variables
set_fact:
pacman: "{{ arch }}"
pacman: "{{ arch_based }}"
apt: "{{ termux or debian }}"
sudo: "{{ not termux }}"
# TODO Install python if not done
# Or maybe not, it requires a lot of automation for something that can be done
# very quickly manually and is usually uneccessary
- name: Install python-apt dependency for Termux
block:
@ -67,30 +75,52 @@
# You should consider upgrading via the '/data/data/com.termux/files/usr/bin/python3 -m pip install --upgrade pip' command.
# Install alternative package managers
- name: Install AUR package manager
- name: Install dependencies for AUR helpers
pacman:
name:
- fakeroot
- base-devel
when: arch_based
become: "{{ sudo }}"
- name: Install AUR package manager (Arch)
aur:
name: yay-bin
when: arch
- name: Install python pip (Pacman)
- name: Install AUR package manager (Manjaro)
pacman:
name: python-pip
when: arch
become: "{{ sudo }}"
become_user: root
name: yay
when: manjaro
# Not sure if regular Manjaro has yay in its community packages,
# but Manjaro-ARM sure does
- name: Install python pip (Debian)
apt:
name: python3-pip
when: debian
become: "{{ sudo }}"
become_user: root
- name: Create cache folder
file:
state: directory
mode: "u=rwx,g=rx,o=rx"
path: "{{ ansible_user_dir }}/.cache/automatrop"
# Termux: pip is included with Python
- name: Generate list of packages for package manager
set_fact:
packages: "{{ query('template', 'package_manager.j2')[0].split('\n')[:-1]|sort }}"
tags: softwarelist
- name: Install packages (Arch-based)
aur:
name: "{{ packages }}"
extra_args: "--asdeps"
# Nothing is set as installed manually so it can
# be removed by dependency check.
# Current packages will be kept by the meta package
use: yay
when: arch_based
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 base packages
include_tasks:
file: base.yml
apply:
become: "{{ sudo }}"
become_user: root

View File

@ -0,0 +1,14 @@
# Maintainer: Geoffrey Frogeye
pkgname=automatrop-packages-{{ inventory_hostname_short }}
pkgver={{ ansible_date_time.iso8601_basic_short }}
pkgrel=1
pkgdesc='Metapackage for packages wanted by Geoffrey via automatrop for {{ inventory_hostname }}'
url='https://git.frogeye.fr/geoffrey/dotfiles/src/branch/master/config/automatrop'
arch=('any')
license=('GPL')
depends=(
{% for package in packages %}
'{{ package }}'
{% endfor %}
)

View File

@ -0,0 +1,26 @@
{# Base shell packages #}
coreutils
bash
grep
sed
tar
openssl
{% if debian_based %}
python3-pip
{% elsif termux %}
python
{% else %}
python-pip
{% endif %}
{# Extended shell packages #}
moreutils
tmux
bash-completion
fzf
highlight
{% if arch_based %}
powerline-go-bin
{% else %}
powerline-go
{% endif %}
zsh