Use latest neovim from GitHub on Debian based distros
This commit is contained in:
parent
b63ff02e0c
commit
5126d06e1e
@ -1,26 +1,108 @@
|
|||||||
---
|
---
|
||||||
- name: slurp /etc/os-release
|
# Don't neovim packages because they are all behind, even Debian unstable.
|
||||||
slurp:
|
# Instead use the latest pre-build Linux package from GitHub, then stow them
|
||||||
src: /etc/os-release
|
# into /usr/local.
|
||||||
register: os_release_slurp
|
|
||||||
- set_fact:
|
|
||||||
os_release: "{{ os_release_slurp.content |
|
|
||||||
b64decode | trim() | replace('=', ': ') | from_yaml }}"
|
|
||||||
|
|
||||||
- name: add neovim stable ppa
|
- name: remove apt package
|
||||||
when: "'ID_LIKE' in os_release and os_release.ID_LIKE == 'ubuntu debian'"
|
|
||||||
become: true
|
become: true
|
||||||
apt_repository:
|
apt:
|
||||||
repo: ppa:neovim-ppa/stable
|
name: neovim
|
||||||
codename: '{{os_release.UBUNTU_CODENAME}}'
|
state: absent
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: install apt package
|
- name: install python provider apt package
|
||||||
become: true
|
become: true
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- neovim
|
|
||||||
- python3-neovim
|
- python3-neovim
|
||||||
|
- stow
|
||||||
state: latest
|
state: latest
|
||||||
|
|
||||||
|
- name: stat installed executable
|
||||||
|
stat:
|
||||||
|
path: /usr/local/bin/nvim
|
||||||
|
register: nvim
|
||||||
|
|
||||||
|
- name: get installed version
|
||||||
|
when: nvim.stat.exists
|
||||||
|
command: nvim --version
|
||||||
|
register: nvim_version
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- when: nvim.stat.exists
|
||||||
|
set_fact:
|
||||||
|
installed_version: '{{nvim_version.stdout_lines[0][5:]}}'
|
||||||
|
|
||||||
|
- name: get latest version
|
||||||
|
uri:
|
||||||
|
url: https://api.github.com/repos/neovim/neovim/releases/latest
|
||||||
|
register: latest
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
install_required:
|
||||||
|
'{{installed_version is not defined or
|
||||||
|
installed_version != latest.json.tag_name}}'
|
||||||
|
asset_query: '[?contains(name, `nvim-linux64.tar.gz`)]'
|
||||||
|
package_dir: '/usr/local/lib/nvim'
|
||||||
|
- set_fact:
|
||||||
|
uninstall_required: '{{nvim.stat.exists and install_required}}'
|
||||||
|
asset: '{{latest.json.assets | json_query(asset_query)}}'
|
||||||
|
package_path: '{{package_dir}}/{{latest.json.name}}'
|
||||||
|
|
||||||
|
- name: uninstall old package from /usr/local
|
||||||
|
when: uninstall_required
|
||||||
|
become: true
|
||||||
|
command:
|
||||||
|
cmd: 'stow --delete --target /usr/local .'
|
||||||
|
chdir: '{{package_dir}}/nvim-linux64'
|
||||||
|
|
||||||
|
- name: remove old package
|
||||||
|
become: true
|
||||||
|
when: uninstall_required
|
||||||
|
file:
|
||||||
|
path: '{{package_dir}}/nvim-linux64'
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: create package directory
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: '{{package_dir}}'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: download package archive
|
||||||
|
when: install_required
|
||||||
|
become: true
|
||||||
|
get_url:
|
||||||
|
url: '{{asset[0].browser_download_url}}'
|
||||||
|
dest: '{{package_path}}'
|
||||||
|
|
||||||
|
- name: extract package archive
|
||||||
|
when: install_required
|
||||||
|
become: true
|
||||||
|
unarchive:
|
||||||
|
src: '{{package_path}}'
|
||||||
|
dest: '{{package_dir}}'
|
||||||
|
|
||||||
|
- name: remove downloaded archive
|
||||||
|
when: install_required
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: '{{package_path}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: move man to share/man
|
||||||
|
when: install_required
|
||||||
|
become: true
|
||||||
|
command:
|
||||||
|
argv:
|
||||||
|
- mv
|
||||||
|
- '{{package_dir}}/nvim-linux64/man'
|
||||||
|
- '{{package_dir}}/nvim-linux64/share'
|
||||||
|
|
||||||
|
- name: install package to /usr/local
|
||||||
|
when: install_required
|
||||||
|
become: true
|
||||||
|
command:
|
||||||
|
cmd: 'stow --target /usr/local .'
|
||||||
|
chdir: '{{package_dir}}/nvim-linux64'
|
||||||
|
|
||||||
- include_tasks: Unix.yaml
|
- include_tasks: Unix.yaml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user