Saltstack Official PHP Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 satır
1.7KB

  1. {%- from "php/map.jinja" import php with context %}
  2. {%- set install_file = php.local_bin + '/' + php.composer_bin %}
  3. {%- if not salt['config.get']('sudo_user') %}
  4. {%- set salt_user = salt['config.get']('user', 'root') %}
  5. {%- else %}
  6. {%- set salt_user = salt['config.get']('sudo_user', 'root') %}
  7. {%- endif %}
  8. {%- set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
  9. include:
  10. - php.deprecated
  11. - php
  12. get-composer:
  13. file.managed:
  14. - name: {{ php.temp_dir }}/installer
  15. - mode: 0755
  16. - unless: test -f {{ install_file }}
  17. - source: https://getcomposer.org/installer
  18. - source_hash: https://composer.github.io/installer.sig
  19. - require:
  20. - pkg: php
  21. install-composer:
  22. cmd.run:
  23. - name: php {{ php.temp_dir }}/installer --filename={{ php.composer_bin }} --install-dir={{ php.local_bin }}
  24. - unless: test -f {{ install_file }}
  25. - env:
  26. - HOME: {{ salt_user_home }}
  27. - require:
  28. - file: get-composer
  29. # Get composer version date and check if older than 60day (defaultvalue of COMPOSER_DEV_WARNING_TIME)
  30. # then it's time to run `composer selfupdate`
  31. #
  32. # It would be nice if composer had a command line switch to get this, but it doesn't,
  33. # and so we just grep for it.
  34. #
  35. update-composer:
  36. cmd.run:
  37. - name: "{{ install_file }} selfupdate"
  38. {% if grains['os_family'] == 'FreeBSD' %}
  39. - unless: test $(date -v+60d -j -f "%Y-%m-%d %H:%M:%S" "$({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
  40. {% else %}
  41. - unless: test $(date -d "60 days $({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
  42. {% endif %}
  43. - cwd: {{ php.local_bin }}
  44. - env:
  45. - HOME: {{ salt_user_home }}
  46. - require:
  47. - cmd: install-composer