Browse Source

Group packages to install/remove when possible for better performance (#62)

* Allow to install package without specifying any version

* Group packages to install/remove when possible for better performance
tags/2017.4
Bruno Binet 7 years ago
parent
commit
b691efe5f9
1 changed files with 39 additions and 10 deletions
  1. +39
    -10
      linux/system/package.sls

+ 39
- 10
linux/system/package.sls View File

pkg.installed: pkg.installed:
- pkgs: {{ system.pkgs }} - pkgs: {{ system.pkgs }}


{%- set pkgs_groups = {
'latest': [],
'purged': [],
'removed': [],
'installed': [],
} %}
{%- for name, package in system.package.iteritems() %} {%- for name, package in system.package.iteritems() %}


{%- if package.repo is defined or package.hold is defined or package.verify is defined %}
linux_extra_package_{{ name }}: linux_extra_package_{{ name }}:
{%- if package.version == 'latest' %}
{%- if package.version is defined %}
{%- if package.version == 'latest' %}
pkg.latest: pkg.latest:
{%- elif package.version == 'purged' %}
{%- elif package.version == 'purged' %}
pkg.purged: pkg.purged:
{%- elif package.version == 'removed' %}
{%- elif package.version == 'removed' %}
pkg.removed: pkg.removed:
{%- else %}
{%- else %}
pkg.installed: pkg.installed:
- version: {{ package.version }} - version: {{ package.version }}
{%- endif %}
{%- endif %}
{%- else %}
pkg.installed:
{%- endif %}
- name: {{ name }} - name: {{ name }}
{%- if package.repo is defined %}
{%- if package.repo is defined %}
- fromrepo: {{ package.repo }} - fromrepo: {{ package.repo }}
{%- endif %}
{%- if package.hold is defined %}
{%- endif %}
{%- if package.hold is defined %}
- hold: {{ package.hold }} - hold: {{ package.hold }}
{%- endif %}
{%- if package.verify is defined %}
{%- endif %}
{%- if package.verify is defined %}
- skip_verify: {{ true if package.verify else false }} - skip_verify: {{ true if package.verify else false }}
{%- endif %}
{%- else %}
{%- if package.version is not defined %}
{%- do pkgs_groups['installed'].append(name) %}
{%- elif package.version in ('latest', 'purged', 'removed') %}
{%- do pkgs_groups[package.version].append(name) %}
{%- else %}
{%- do pkgs_groups['installed'].append({name: package.version}) %}
{%- endif %}
{%- endif %}

{%- endfor %}

{%- for pkgs_group, pkgs in pkgs_groups.iteritems() %}
{%- if pkgs %}
linux_extra_packages_{{ pkgs_group }}:
pkg.{{ pkgs_group }}:
- pkgs: {{ pkgs }}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}



Loading…
Cancel
Save