---
{%- from "ipbl/map.jinja" import ipbl with context %}
ipbl-dependencies:
  pkg.installed:
    - name: libczmq4

ipbl-archive-extract:
  archive.extracted:
    - name: {{ ipbl.release_dir }}/ipbl-{{ ipbl.version }}
    - source: {{ ipbl.mirror }}/{{ ipbl.version }}/ipbl-{{ ipbl.version }}-{{ ipbl.os }}-{{ ipbl.arch }}.tar.gz
    - skip_verify: true
    - enforce_toplevel: false
    - if_missing: {{ ipbl.release_dir }}/ipbl-{{ ipbl.version }}
    - watch_in:
      - service: ipbl-service

ipbl-binary-symlink:
  file.symlink:
    - name: {{ ipbl.install_dir }}/ipbl
    - target: {{ ipbl.release_dir }}/ipbl-{{ ipbl.version }}
    - require:
      - archive: ipbl-archive-extract
    - watch_in:
      - service: ipbl-service

ipbl-cleanup:
  software.cleanup:
    - name: ipbl
    - path: {{ ipbl.release_dir }}
    - version: "{{ ipbl.version }}"