2019-08-07 17:01:55 +02:00
|
|
|
{% from "php/map.jinja" import php with context %}
|
2015-02-20 11:12:19 +01:00
|
|
|
|
2019-08-07 17:01:55 +02:00
|
|
|
{% set install_file = php.lookup.pkgs.local_bin + '/' + php.lookup.pkgs.composer_bin %}
|
2016-04-27 15:04:22 +02:00
|
|
|
|
2019-08-07 17:01:55 +02:00
|
|
|
{% if not salt['config.get']('sudo_user') %}
|
|
|
|
{% set salt_user = salt['config.get']('user', 'root') %}
|
|
|
|
{% else %}
|
|
|
|
{% set salt_user = salt['config.get']('sudo_user', 'root') %}
|
|
|
|
{% endif %}
|
2016-12-13 22:37:53 +01:00
|
|
|
|
2019-08-07 17:01:55 +02:00
|
|
|
{% set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
|
2016-04-27 15:04:22 +02:00
|
|
|
|
2015-02-20 11:12:19 +01:00
|
|
|
include:
|
|
|
|
- php
|
2020-11-08 22:10:03 +01:00
|
|
|
{%- for module in php.lookup.get('composer', {}).get('required_modules', []) %}
|
|
|
|
- php.{{ module }}
|
|
|
|
{%- endfor %}
|
2015-02-20 11:12:19 +01:00
|
|
|
|
|
|
|
get-composer:
|
2015-07-20 01:00:44 +02:00
|
|
|
file.managed:
|
2019-08-07 17:01:55 +02:00
|
|
|
- name: {{ php.lookup.pkgs.temp_dir }}/installer
|
2019-10-09 16:45:51 +02:00
|
|
|
- mode: '0755'
|
2015-02-20 11:12:19 +01:00
|
|
|
- unless: test -f {{ install_file }}
|
2015-07-20 01:00:44 +02:00
|
|
|
- source: https://getcomposer.org/installer
|
2016-04-29 10:40:44 +02:00
|
|
|
- source_hash: https://composer.github.io/installer.sig
|
2015-02-20 11:12:19 +01:00
|
|
|
- require:
|
|
|
|
- pkg: php
|
|
|
|
|
2015-03-06 11:56:35 +01:00
|
|
|
install-composer:
|
2015-09-28 19:39:20 +02:00
|
|
|
cmd.run:
|
2019-08-07 17:01:55 +02:00
|
|
|
- name: php {{ php.lookup.pkgs.temp_dir }}/installer --filename={{ php.lookup.pkgs.composer_bin }} --install-dir={{ php.lookup.pkgs.local_bin }}
|
2015-09-28 19:39:20 +02:00
|
|
|
- unless: test -f {{ install_file }}
|
2016-04-27 15:04:22 +02:00
|
|
|
- env:
|
|
|
|
- HOME: {{ salt_user_home }}
|
2015-09-28 19:39:20 +02:00
|
|
|
- require:
|
2015-07-20 01:00:44 +02:00
|
|
|
- file: get-composer
|
2015-03-06 11:56:35 +01:00
|
|
|
|
2018-01-02 22:02:17 +01:00
|
|
|
# Get composer version date and check if older than 60day (defaultvalue of COMPOSER_DEV_WARNING_TIME)
|
2015-02-20 11:12:19 +01:00
|
|
|
# then it's time to run `composer selfupdate`
|
|
|
|
#
|
|
|
|
# It would be nice if composer had a command line switch to get this, but it doesn't,
|
|
|
|
# and so we just grep for it.
|
|
|
|
#
|
|
|
|
update-composer:
|
|
|
|
cmd.run:
|
|
|
|
- name: "{{ install_file }} selfupdate"
|
2018-03-15 22:12:48 +01:00
|
|
|
{% if grains['os_family'] == 'FreeBSD' %}
|
2022-08-27 01:51:26 +02:00
|
|
|
- unless: test $(date -v+60d -j -f "%Y-%m-%d %H:%M:%S" "$({{ install_file }} --version --no-interaction | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
|
2018-03-15 22:12:48 +01:00
|
|
|
{% else %}
|
2022-08-27 01:51:26 +02:00
|
|
|
- unless: test $(date -d "60 days $({{ install_file }} --version --no-interaction | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
|
2018-03-15 22:12:48 +01:00
|
|
|
{% endif %}
|
2019-08-07 17:01:55 +02:00
|
|
|
- cwd: {{ php.lookup.pkgs.local_bin }}
|
2016-04-27 15:04:22 +02:00
|
|
|
- env:
|
|
|
|
- HOME: {{ salt_user_home }}
|
2015-02-20 11:12:19 +01:00
|
|
|
- require:
|
2015-03-06 11:56:35 +01:00
|
|
|
- cmd: install-composer
|