120 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
---
 | 
						|
# Don't neovim packages because they are all behind, even Debian unstable.
 | 
						|
# Instead use the latest pre-build Linux package from GitHub, then stow them
 | 
						|
# into /usr/local.
 | 
						|
 | 
						|
- name: remove apt package
 | 
						|
  become: true
 | 
						|
  apt:
 | 
						|
    name: neovim
 | 
						|
    state: absent
 | 
						|
 | 
						|
- set_fact:
 | 
						|
    old_package_dirs:
 | 
						|
      - /usr/local/lib/nvim/nvim-linux-x86_64
 | 
						|
      - /usr/local/stow/nvim/nvim-linux64
 | 
						|
 | 
						|
- include_tasks: sudo-rmdir.yaml
 | 
						|
  with_items: '{{old_package_dirs}}'
 | 
						|
 | 
						|
- name: install gnu stow for managing tar.gz package
 | 
						|
  become: true
 | 
						|
  apt:
 | 
						|
    name:
 | 
						|
      - stow
 | 
						|
    state: latest
 | 
						|
 | 
						|
- name: install python provider pip package
 | 
						|
  pip:
 | 
						|
    name: pynvim
 | 
						|
    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
 | 
						|
    headers: '{{github_auth_headers}}'
 | 
						|
  register: latest
 | 
						|
 | 
						|
- set_fact:
 | 
						|
    install_required:
 | 
						|
      '{{installed_version is not defined or
 | 
						|
         installed_version != latest.json.tag_name}}'
 | 
						|
    asset_query: '[?contains(name, `nvim-linux-x86_64.tar.gz`)]'
 | 
						|
    package_dir: '/usr/local/stow/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: remove nuisance mimeinfo.cache file
 | 
						|
  become: true
 | 
						|
  file:
 | 
						|
    path: /usr/local/stow/nvim/nvim-linux-x86_64/share/applications/mimeinfo.cache
 | 
						|
    state: absent
 | 
						|
 | 
						|
- name: uninstall old package from /usr/local
 | 
						|
  when: uninstall_required
 | 
						|
  become: true
 | 
						|
  command:
 | 
						|
    cmd: 'stow --delete --target /usr/local .'
 | 
						|
    chdir: '{{package_dir}}/nvim-linux-x86_64'
 | 
						|
 | 
						|
- name: remove old package
 | 
						|
  become: true
 | 
						|
  when: uninstall_required
 | 
						|
  file:
 | 
						|
    path: '{{package_dir}}/nvim-linux-x86_64'
 | 
						|
    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}}'
 | 
						|
  environment: '{{proxy_environment}}'
 | 
						|
 | 
						|
- 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: install package to /usr/local
 | 
						|
  when: install_required
 | 
						|
  become: true
 | 
						|
  command:
 | 
						|
    cmd: 'stow --no-folding --target /usr/local .'
 | 
						|
    chdir: '{{package_dir}}/nvim-linux-x86_64'
 | 
						|
 | 
						|
- include_tasks: Unix.yaml
 |