mirror of
https://github.com/saltstack-formulas/packages-formula.git
synced 2025-04-10 14:51:42 +00:00
101 lines
3.4 KiB
Text
101 lines
3.4 KiB
Text
# -*- coding: utf-8 -*-
|
|
# vim: ft=sls
|
|
{%- from "./map.jinja" import packages with context %}
|
|
|
|
{%- set wanted_archives = packages.archives.required.archives %}
|
|
{%- do wanted_archives.update( packages.archives.wanted ) %}
|
|
{%- set unwanted_archives = packages.archives.unwanted %}
|
|
|
|
{%- if wanted_archives or unwanted_archives %}
|
|
|
|
{%- set req_packages = packages.pkgs.required.pkgs + packages.archives.pkgs.required %}
|
|
include:
|
|
- .pkgs
|
|
|
|
extend:
|
|
pkg_req_pkgs:
|
|
pkg.installed:
|
|
- pkgs: {{ req_packages | json }}
|
|
|
|
# unwanted 'archive' software
|
|
{%- for file_or_directory in unwanted_archives %}
|
|
packages-archive-unwanted-{{ file_or_directory }}:
|
|
file.absent:
|
|
- name: {{ file_or_directory }}
|
|
{%- endfor %}
|
|
|
|
# wanted 'archive' software
|
|
{%- for package, archive in wanted_archives.items() %}
|
|
{%- set archivename = archive.dl.source.split('/')[-1] if 'destname' not in archive else archive.destname %}
|
|
|
|
packages-archive-wanted-target-{{ package }}-directory:
|
|
file.directory:
|
|
- names:
|
|
- {{ archive.dest }}
|
|
{%- if packages.tmpdir != '/tmp' %}
|
|
- {{ packages.tmpdir }}
|
|
{%- endif %}
|
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
|
- mode: {{ '0755' if 'mode' not in archive else archive.mode }}
|
|
- makedirs: True
|
|
- require_in:
|
|
- packages-archive-wanted-download-{{ package }}
|
|
|
|
{%- if 'format' in archive.dl and archive.dl.format in packages.archives.types %}
|
|
|
|
packages-archive-wanted-download-{{ package }}:
|
|
cmd.run:
|
|
- name: curl -s -L -o {{ packages.tmpdir }}/{{ archivename }} {{ archive.dl.source }}
|
|
- unless: test -f {{ packages.tmpdir }}/{{ archivename }}
|
|
- retry: {{ packages.retry_options|json }}
|
|
|
|
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
|
{# see https://github.com/saltstack/salt/pull/41914 #}
|
|
|
|
packages-archive-wanted-{{ package }}-check-hashsum:
|
|
module.run:
|
|
- name: file.check_hash
|
|
- path: {{ packages.tmpdir }}/{{ archivename }}
|
|
- file_hash: {{ archive.dl.hashsum }}
|
|
- require:
|
|
- packages-archive-wanted-download-{{ package }}
|
|
- require_in:
|
|
- archive: packages-archive-wanted-install-{{ package }}
|
|
|
|
{%- endif %}
|
|
|
|
packages-archive-wanted-install-{{ package }}:
|
|
archive.extracted:
|
|
- source: file://{{ packages.tmpdir }}/{{ archivename }}
|
|
- name: {{ archive.dest }}/
|
|
- archive_format: {{ archive.dl.format }}
|
|
{%- if 'hashurl' in archive.dl and archive.dl.hashurl %}
|
|
- source_hash: {{ archive.dl.hashurl }}
|
|
{%- endif %}
|
|
{%- if 'options' in archive and archive.options %}
|
|
- options: {{ archive.options }}
|
|
- enforce_toplevel: {{ 'False' if 'strip-components' in archive.options else 'True' }}
|
|
{%- endif %}
|
|
- onlyif: test -d {{ archive.dest }}
|
|
- require:
|
|
- packages-archive-wanted-download-{{ package }}
|
|
|
|
{%- else %}
|
|
|
|
packages-archive-wanted-download-{{ package }}:
|
|
file.managed:
|
|
- name: {{ archive.dest }}/{{ archivename }}
|
|
- source: {{ archive.dl.source }}
|
|
- mode: {{ '0755' if archive.dl.format in ('bin',) else '0644' if 'mode' not in archive else archive.mode }}
|
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
|
- makedirs: True
|
|
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
|
- source_hash: {{ archive.dl.hashsum }}
|
|
{%- else %}
|
|
- skip_verify: True
|
|
{%- endif %}
|
|
- retry: {{ packages.retry_options|json }}
|
|
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- endif %}
|