2016-12-13 22:37:53 +01:00
|
|
|
{% from "php/ng/map.jinja" import php with context %}
|
|
|
|
|
|
|
|
{% set install_file = php.lookup.pkgs.local_bin + '/' + php.lookup.pkgs.composer_bin %}
|
|
|
|
|
|
|
|
{% 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 %}
|
|
|
|
|
|
|
|
{% set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
|
|
|
|
|
|
|
|
include:
|
|
|
|
- php.ng
|
2018-03-15 15:14:13 +01:00
|
|
|
{% if grains['os_family'] == 'FreeBSD' %}
|
|
|
|
- php.ng.filter
|
|
|
|
- php.ng.hash
|
|
|
|
- php.ng.json
|
|
|
|
- php.ng.mbstring
|
|
|
|
- php.ng.openssl
|
|
|
|
- php.ng.phar
|
|
|
|
{% endif %}
|
2016-12-13 22:37:53 +01:00
|
|
|
|
|
|
|
get-composer:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ php.lookup.pkgs.temp_dir }}/installer
|
|
|
|
- mode: 0755
|
|
|
|
- unless: test -f {{ install_file }}
|
|
|
|
- source: https://getcomposer.org/installer
|
|
|
|
- source_hash: https://composer.github.io/installer.sig
|
|
|
|
- require:
|
|
|
|
- pkg: php
|
|
|
|
|
|
|
|
install-composer:
|
|
|
|
cmd.run:
|
|
|
|
- name: php {{ php.lookup.pkgs.temp_dir }}/installer --filename={{ php.lookup.pkgs.composer_bin }} --install-dir={{ php.lookup.pkgs.local_bin }}
|
|
|
|
- unless: test -f {{ install_file }}
|
|
|
|
- env:
|
|
|
|
- HOME: {{ salt_user_home }}
|
|
|
|
- require:
|
|
|
|
- file: get-composer
|
|
|
|
|
2018-01-02 22:02:17 +01:00
|
|
|
# Get composer version date and check if older than 60day (defaultvalue of COMPOSER_DEV_WARNING_TIME)
|
2016-12-13 22:37:53 +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-01-02 22:02:17 +01:00
|
|
|
- unless: test $(date -d "60 days $({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") \> $(date "+%s")
|
2016-12-13 22:37:53 +01:00
|
|
|
- cwd: {{ php.lookup.pkgs.local_bin }}
|
|
|
|
- env:
|
|
|
|
- HOME: {{ salt_user_home }}
|
|
|
|
- require:
|
|
|
|
- cmd: install-composer
|