working on cleanup and fixing a few format issues
- modifying how installs are done
This commit is contained in:
@@ -19,12 +19,18 @@
|
||||
path_archive: "{{ install_prefix }}/archive"
|
||||
path_bin: "{{ install_prefix }}/bin"
|
||||
path_cargo: "{{ install_prefix }}/cargo"
|
||||
path_git: "{{ install_prefix }}/git"
|
||||
path_source: "{{ install_prefix }}/source"
|
||||
path_go: "{{ install_prefix }}/go"
|
||||
path_pipx: "{{ install_prefix }}/pipx"
|
||||
store_path: "{{ ansible_facts['user_dir'] }}/.cache/ansible_role_package"
|
||||
path_lib: "{{ install_prefix }}/lib"
|
||||
|
||||
- name: Set install_become_group from install_become_user
|
||||
block:
|
||||
- name: Get install_become_user userinfo
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
key: "{{ install_become_user }}"
|
||||
|
||||
- name: Set Linux specific facts
|
||||
when:
|
||||
|
||||
@@ -4,48 +4,29 @@
|
||||
block:
|
||||
- name: Fetch git repo
|
||||
vars:
|
||||
git:
|
||||
path: "{{ d_cache.path }}/{{ cargo_build.name }}"
|
||||
repo: "{{ cargo_build.repo }}"
|
||||
depth: "{{ cargo_build.depth | default(1) }}"
|
||||
force: "{{ cargo_build.force_git | default(true) }}"
|
||||
recursive: "{{ cargo_build.recursive | default(true) }}"
|
||||
version: "{{ cargo_build.version | default(omit) }}"
|
||||
ansible.builtin.include_tasks:
|
||||
file: helpers/git.yml
|
||||
path: "{{ path_source }}/{{ cargo_build.source_dir }}"
|
||||
repo: "{{ cargo_build.repo }}"
|
||||
depth: "{{ cargo_build.depth | default(1) }}"
|
||||
force: "{{ cargo_build.force_git | default(true) }}"
|
||||
recursive: "{{ cargo_build.recursive | default(true) }}"
|
||||
version: "{{ cargo_build.version | default(omit) }}"
|
||||
ansible.builtin.include_tasks: helpers/git.yml
|
||||
|
||||
- name: Build cargo release
|
||||
ansible.builtin.command:
|
||||
chdir: "{{ d_cache.path }}/{{ cargo_build.name }}"
|
||||
chdir: "{{ path_source }}/{{ cargo_build.source_dir }}"
|
||||
argv: "{{ [cargo, build] + cargo_build.build_flags }}"
|
||||
|
||||
- name: Clean existing install
|
||||
vars:
|
||||
files: "{{ cargo_build.files }}"
|
||||
ansible.builtin.include_tasks: helpers/clean.yml
|
||||
|
||||
- name: Install cargo release
|
||||
block:
|
||||
- name: Create missing directories
|
||||
become: "{{ install_become }}"
|
||||
become_user: "{{ install_become_user }}"
|
||||
loop: "{{ cargo_build.files }}"
|
||||
loop_control:
|
||||
loop_var: file
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
path: "{{ install_prefix }}/{{ file.to | dirname }}"
|
||||
mode: '0755'
|
||||
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
|
||||
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
|
||||
|
||||
- name: Install release files
|
||||
become: "{{ install_become }}"
|
||||
become_user: "{{ install_become_user }}"
|
||||
loop: "{{ cargo_build.files }}"
|
||||
loop_control:
|
||||
loop_var: file
|
||||
ansible.builtin.copy:
|
||||
backup: false
|
||||
remote_src: true
|
||||
src: "{{ d_cache.path }}/{{ cargo_build.name }}/{{ file.from }}"
|
||||
dest: "{{ install_prefix }}/{{ file.to }}"
|
||||
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
|
||||
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
|
||||
mode: "{{ file.mode | default('0644') }}"
|
||||
force: "{{ file.force | default(true) }}"
|
||||
vars:
|
||||
source_dir: "{{ cargo_build.source_dir }}"
|
||||
ansible.builtin.include_tasks: helpers/install.yml
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
---
|
||||
- name: Remove file list
|
||||
become: true
|
||||
loop: "{{ file_list }}"
|
||||
become: "{{ install_become }}"
|
||||
become_user: "{{ install_become_user }}"
|
||||
loop: "{{ files }}"
|
||||
loop_control:
|
||||
loop_var: file
|
||||
when:
|
||||
- file.to is defined
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "{{ file }}"
|
||||
path: "{{ install_prefix }}/{{ file.to }}"
|
||||
|
||||
- name: Check for and remove empty directories
|
||||
loop: "{{ files }}"
|
||||
loop_control:
|
||||
loop_var: dir
|
||||
when:
|
||||
- file.directory is defined
|
||||
ansible.builtin.include_tasks: internal/remove_empty_dir.yml
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
---
|
||||
- name: Clone git repository
|
||||
ansible.builtin.git:
|
||||
depth: "{{ git.depth | default(1) }}"
|
||||
dest: "{{ git.path }}"
|
||||
force: "{{ git.force | default(true) }}"
|
||||
recursive: "{{ git.recursive | default(true) }}"
|
||||
repo: "{{ git.repo }}"
|
||||
version: "{{ git.version | default(omit) }}"
|
||||
dest: "{{ path }}"
|
||||
repo: "{{ repo }}"
|
||||
depth: "{{ depth | default(1) }}"
|
||||
force: "{{ force | default(true) }}"
|
||||
recursive: "{{ recursive | default(true) }}"
|
||||
version: "{{ version | default(omit) }}"
|
||||
|
||||
40
tasks/helpers/install.yml
Normal file
40
tasks/helpers/install.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
#
|
||||
## Helper: install.yml
|
||||
## Description: install files defined in dict
|
||||
## Variables:
|
||||
## _Note_ This is mutually exclusive to having a 'to' key
|
||||
## - directory: path prefixed by {{ install_prefix }} of a directory to
|
||||
## be created
|
||||
## mode: _optional_, _default_ '0755'
|
||||
##
|
||||
## _Note_ This is mutually exclusive to having a 'directory' key
|
||||
## - to: where to install file to, prefixed with {{ install_prefix }}
|
||||
## from: source file from build path root for package
|
||||
## mode: _optional_, _default_ '0644'##
|
||||
##
|
||||
## Notes: This is only used when copying files or creating directories
|
||||
## for installing. If a source package doesn't require you to manually
|
||||
## copy anthing (go install, as an example), don't use this.
|
||||
---
|
||||
- name: Create directories
|
||||
become: "{{ install_become }}"
|
||||
become_user: "{{ install_become_user }}"
|
||||
loop: "{{ pkg_clean }}"
|
||||
loop_control:
|
||||
loop_var: dir
|
||||
when:
|
||||
- dir.directory is defined
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
mode: '0755'
|
||||
path: "{{ install_prefix }}/{{ dir.directory }}"
|
||||
|
||||
- name: Copy installable files
|
||||
become: "{{ install_become }}"
|
||||
become_user: "{{ install_become_user }}"
|
||||
loop: "{{ pkg_clean }}"
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ install_prefix }}/{{ file.to }}"
|
||||
mode: "{{ file.mode | default('0644') }}"
|
||||
src: "{{ file.builddir | default(omit) }}/"
|
||||
16
tasks/internal/remove_empty_dir.yml
Normal file
16
tasks/internal/remove_empty_dir.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
---
|
||||
- name: Check if dir is empty
|
||||
ansible.builtin.find:
|
||||
paths:
|
||||
- "{{ dir }}"
|
||||
file_type: any
|
||||
hidden: true
|
||||
register: fd_empty
|
||||
|
||||
- name: Remove empty dir
|
||||
when:
|
||||
- fd_empty.matched|int == 0
|
||||
ansible.builtin.file:
|
||||
path: "{{ dir }}"
|
||||
state: absent
|
||||
@@ -26,7 +26,7 @@
|
||||
- "{{ path_archive }}"
|
||||
- "{{ path_bin }}"
|
||||
- "{{ path_cargo }}"
|
||||
- "{{ path_git }}"
|
||||
- "{{ path_source }}"
|
||||
- "{{ path_pipx }}"
|
||||
loop_control:
|
||||
loop_var: path
|
||||
@@ -70,6 +70,9 @@
|
||||
ansible.builtin.include_tasks:
|
||||
file: "pkgs/{{ pkg }}.yml"
|
||||
|
||||
- name: Clean installations that require it
|
||||
ansible.builtin.include_tasks: "helpers/clean_install.yml"
|
||||
|
||||
- name: Install go if required
|
||||
when:
|
||||
- pkg_go|length > 0
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
when:
|
||||
- air_install_method is undefined
|
||||
ansible.builtin.set_fact:
|
||||
air_install_method: "{{ install_method if install_method in air_install_methods else air_install_methods[0] }}"
|
||||
air_install_method: "{{ install_method if install_method in air.install_methods else air.install_methods[0] }}"
|
||||
|
||||
- name: Set air build facts
|
||||
when:
|
||||
@@ -27,6 +27,7 @@
|
||||
url: "{{ air_install_url }}@{{ air_version }}"
|
||||
bin: "{{ path_bin }}/air"
|
||||
# }}}
|
||||
# {{{ air build and install steps
|
||||
- name: Append air to pkg_go
|
||||
when:
|
||||
- air_install_method == 'source'
|
||||
@@ -34,23 +35,19 @@
|
||||
- name: Clean existing air install
|
||||
when:
|
||||
- clean_install
|
||||
loop: "{{ air_build_files }}"
|
||||
loop_control:
|
||||
loop_var: air_file
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "{{ install_prefix }}/{{ air_file }}"
|
||||
ansible.builtin.set_fact:
|
||||
pkg_clean: "{{ pkg_clean + air.install_files }}"
|
||||
|
||||
- name: Configure pkg dependencies
|
||||
loop: "{{ air_pkg_deps }}"
|
||||
loop: "{{ air.pkg_deps }}"
|
||||
loop_control:
|
||||
loop_var: air_pkg_dep
|
||||
ansible.builtin.include_tasks: "{{ air_pkg_dep }}"
|
||||
loop_var: pkg
|
||||
ansible.builtin.include_tasks: "pkgs/{{ pkg }}.yml"
|
||||
|
||||
- name: Add air to install list
|
||||
ansible.builtin.set_fact:
|
||||
pkg_go: "{{ pkg_go + [air_go_pkg] }}"
|
||||
|
||||
# }}}
|
||||
- name: Finalize air configuration
|
||||
ansible.builtin.set_fact:
|
||||
__configured: "{{ __configured | combine( { 'air': true } ) }}"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
when:
|
||||
- alacritty_install_method is undefined
|
||||
ansible.builtin.set_fact:
|
||||
alacritty_install_method: "{{ install_method if install_method in alacritty_install_methods else alacritty_install_methods[0] }}"
|
||||
alacritty_install_method: "{{ install_method if install_method in alacritty.install_methods else alacritty.install_methods[0] }}"
|
||||
|
||||
- name: Configure alacritty source install
|
||||
when:
|
||||
@@ -25,20 +25,13 @@
|
||||
block:
|
||||
- name: Set alacritty build facts
|
||||
ansible.builtin.set_fact:
|
||||
alacritty_build_deps: "{{ alacritty_build_deps[ansible_os_family] }}"
|
||||
alacritty_src_install:
|
||||
build_deps: "{{ alacritty.build_deps[ansible_facts['os_family']] }}"
|
||||
build_flags: "{{ alacritty_cargo_build_flags }}"
|
||||
name: "{{ alacritty_pkgname }}"
|
||||
source_dir: "{{ alacritty.install_files.source_dir }}"
|
||||
repo: "{{ alacritty_git_repo }}"
|
||||
version: "{{ alacritty_version }}"
|
||||
files:
|
||||
- from: target/release/alacritty
|
||||
to: bin/alacritty
|
||||
mode: '0755'
|
||||
- from: extra/logo/alacritty-term.svg
|
||||
to: share/pixmaps/Alacritty.svg
|
||||
- from: extra/linux/Alacritty.desktop
|
||||
to: share/applications/Alacritty.desktop
|
||||
files: "{{ alacritty.install_files.files }}"
|
||||
|
||||
- name: Set alacritty install extra build deps
|
||||
when:
|
||||
@@ -49,13 +42,13 @@
|
||||
when:
|
||||
- ansible_distribution_major_version == 7
|
||||
ansible.builtin.set_fact:
|
||||
alacritty_build_deps: "{{ alacritty_build_deps + ['xcb-util-devel', '@Development Tools'] }}"
|
||||
alacritty_build_deps: "{{ build_deps + ['xcb-util-devel', '@Development Tools'] }}"
|
||||
|
||||
- name: Add extra dependencies for EL8
|
||||
when:
|
||||
- ansible_distribution_major_version == 8
|
||||
ansible.builtin.set_fact:
|
||||
alacritty_build_deps: "{{ alacritty_build_deps + ['@Development Tools'] }}"
|
||||
alacritty_build_deps: "{{ build_deps + ['@Development Tools'] }}"
|
||||
|
||||
# }}}
|
||||
- name: Append alacritty installation
|
||||
@@ -65,14 +58,14 @@
|
||||
- alacritty_method == 'source'
|
||||
block:
|
||||
- name: Configure pkg dependencies
|
||||
loop: "{{ alacritty_pkg_deps }}"
|
||||
loop: "{{ alacritty.pkg_deps }}"
|
||||
loop_control:
|
||||
loop_var: alacritty_pkg_dep
|
||||
ansible.builtin.include_tasks: "{{ alacritty_pkg_dep }}"
|
||||
loop_var: pkg
|
||||
ansible.builtin.include_tasks: "pkgs/{{ pkg }}.yml"
|
||||
|
||||
- name: Append build dependencies and cargo config
|
||||
ansible.builtin.set_fact:
|
||||
pkg_sys: "{{ pkg_sys + alacritty_build_deps }}"
|
||||
pkg_sys: "{{ pkg_sys + build_deps }}"
|
||||
pkg_cargo_build: "{{ pkg_cargo_build + [alacritty_src_install] }}"
|
||||
|
||||
- name: Append alacritty to pkg_sys
|
||||
|
||||
@@ -28,6 +28,7 @@ pkg_appimage: [] # appimages to install
|
||||
pkg_archive: [] # packages installed via prebuilt archive
|
||||
pkg_cargo: [] # rust packages from cargo using `cargo install`
|
||||
pkg_cargo_build: [] # rust packages using `cargo build` before install
|
||||
pkg_clean: [] # list of files to remove before running archive and source installations
|
||||
pkg_flatpak: [] # flatpak packages to install
|
||||
pkg_go: [] # go applications
|
||||
pkg_npm: [] # npm commands
|
||||
@@ -45,71 +46,14 @@ __var_to_env: {} # dict of variables to add to your env
|
||||
# Per package variables
|
||||
# {{{ air
|
||||
air_version: latest
|
||||
air_build_files:
|
||||
- bin/air
|
||||
air_install_url: github.com/air-verse/air
|
||||
air_pkg_deps:
|
||||
- pkgs/go.yml
|
||||
# }}}
|
||||
# {{{ alacritty
|
||||
alacritty_version: v0.16.1
|
||||
alacritty_git_repo: https://github.com/alacritty/alacritty
|
||||
alacritty_pkgname: alacritty
|
||||
alacritty_pkg_deps:
|
||||
- pkgs/git.yml
|
||||
- pkgs/cargo.yml
|
||||
alacritty_build_files:
|
||||
- bin/alacritty
|
||||
- share/pixmaps/Alacritty.svg
|
||||
- share/applications/Alacritty.desktop
|
||||
alacritty_cargo_build_flags:
|
||||
- --release
|
||||
alacritty_build_deps:
|
||||
RedHat:
|
||||
- cmake
|
||||
- fontconfig-devel
|
||||
- freetype-devel
|
||||
- g++
|
||||
- libxcb-devel
|
||||
- libxkbcommon-devel
|
||||
- desktop-file-utils
|
||||
Debian:
|
||||
- cmake
|
||||
- g++
|
||||
- pkg-config
|
||||
- libfontconfig1-dev
|
||||
- libxcb-xfixes0-dev
|
||||
- libxkbcommon-dev
|
||||
- python3
|
||||
- libfreetype6-dev
|
||||
- desktop-file-utils
|
||||
Alpine:
|
||||
- cmake
|
||||
- pkgconf
|
||||
- freetype-dev
|
||||
- fontconfig-dev
|
||||
- python3
|
||||
- libxcb-dev
|
||||
- g++
|
||||
- libxkbcommon-dev
|
||||
- desktop-file-utils
|
||||
Archlinux:
|
||||
- cmake
|
||||
- freetype2
|
||||
- fontconfig
|
||||
- pkg-config
|
||||
- make
|
||||
- libxcb
|
||||
- libxkbcommon
|
||||
- python
|
||||
- desktop-file-utils
|
||||
FreeBSD:
|
||||
- cmake
|
||||
- freetype2
|
||||
- fontconfig
|
||||
- pkgconf
|
||||
- python3
|
||||
- desktop-file-utils
|
||||
# }}}
|
||||
# {{{ ansible
|
||||
ansible_install_methods:
|
||||
|
||||
@@ -5,14 +5,85 @@
|
||||
## Restrictions for package install methods.
|
||||
## The first item is the default method. If only
|
||||
## one method exists, all others are ignored.
|
||||
air_install_methods:
|
||||
- source
|
||||
alacritty_install_methods:
|
||||
- source
|
||||
- system
|
||||
ansible_lint_install_methods:
|
||||
- pipx
|
||||
- system
|
||||
air: # {{{
|
||||
install_methods:
|
||||
- source
|
||||
install_files:
|
||||
- to: bin/air
|
||||
pkg_deps:
|
||||
- go
|
||||
# }}}
|
||||
alacritty: # {{{
|
||||
install_methods:
|
||||
- source
|
||||
- system
|
||||
install_files:
|
||||
source_dir: alacritty
|
||||
files:
|
||||
- from: target/release/alacritty
|
||||
to: bin/alacritty
|
||||
mode: '0755'
|
||||
- from: extra/logo/alacritty-term.svg
|
||||
to: share/pixmaps/Alacritty.svg
|
||||
mode: '0644'
|
||||
- from: extra/linux/Alacritty.desktop
|
||||
to: share/applications/Alacritty.desktop
|
||||
mode: '0644'
|
||||
pkg_deps:
|
||||
- git
|
||||
- cargo
|
||||
sys_build_deps:
|
||||
RedHat:
|
||||
- cmake
|
||||
- fontconfig-devel
|
||||
- freetype-devel
|
||||
- g++
|
||||
- libxcb-devel
|
||||
- libxkbcommon-devel
|
||||
- desktop-file-utils
|
||||
Debian:
|
||||
- cmake
|
||||
- g++
|
||||
- pkg-config
|
||||
- libfontconfig1-dev
|
||||
- libxcb-xfixes0-dev
|
||||
- libxkbcommon-dev
|
||||
- python3
|
||||
- libfreetype6-dev
|
||||
- desktop-file-utils
|
||||
Alpine:
|
||||
- cmake
|
||||
- pkgconf
|
||||
- freetype-dev
|
||||
- fontconfig-dev
|
||||
- python3
|
||||
- libxcb-dev
|
||||
- g++
|
||||
- libxkbcommon-dev
|
||||
- desktop-file-utils
|
||||
Archlinux:
|
||||
- cmake
|
||||
- freetype2
|
||||
- fontconfig
|
||||
- pkg-config
|
||||
- make
|
||||
- libxcb
|
||||
- libxkbcommon
|
||||
- python
|
||||
- desktop-file-utils
|
||||
FreeBSD:
|
||||
- cmake
|
||||
- freetype2
|
||||
- fontconfig
|
||||
- pkgconf
|
||||
- python3
|
||||
- desktop-file-utils
|
||||
# }}}
|
||||
ansible_lint: # {{{
|
||||
install_methods:
|
||||
- pipx
|
||||
- system
|
||||
# }}}
|
||||
ansible_install_methods:
|
||||
- system
|
||||
ansible_ls_install_methods:
|
||||
|
||||
Reference in New Issue
Block a user