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.

63 line
2.0KB

  1. {% from "php/ng/map.jinja" import php with context %}
  2. {% set install_file = php.lookup.pkgs.local_bin + '/' + php.lookup.pkgs.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.ng.deprecated
  11. - php.ng
  12. {% if grains['os_family'] == 'FreeBSD' %}
  13. - php.ng.filter
  14. - php.ng.hash
  15. - php.ng.json
  16. - php.ng.mbstring
  17. - php.ng.openssl
  18. - php.ng.phar
  19. {% endif %}
  20. get-composer:
  21. file.managed:
  22. - name: {{ php.lookup.pkgs.temp_dir }}/installer
  23. - mode: 0755
  24. - unless: test -f {{ install_file }}
  25. - source: https://getcomposer.org/installer
  26. - source_hash: https://composer.github.io/installer.sig
  27. - require:
  28. - pkg: php
  29. install-composer:
  30. cmd.run:
  31. - name: php {{ php.lookup.pkgs.temp_dir }}/installer --filename={{ php.lookup.pkgs.composer_bin }} --install-dir={{ php.lookup.pkgs.local_bin }}
  32. - unless: test -f {{ install_file }}
  33. - env:
  34. - HOME: {{ salt_user_home }}
  35. - require:
  36. - file: get-composer
  37. # Get composer version date and check if older than 60day (defaultvalue of COMPOSER_DEV_WARNING_TIME)
  38. # then it's time to run `composer selfupdate`
  39. #
  40. # It would be nice if composer had a command line switch to get this, but it doesn't,
  41. # and so we just grep for it.
  42. #
  43. update-composer:
  44. cmd.run:
  45. - name: "{{ install_file }} selfupdate"
  46. {% if grains['os_family'] == 'FreeBSD' %}
  47. - 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")
  48. {% else %}
  49. - unless: test $(date -d "60 days $({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
  50. {% endif %}
  51. - cwd: {{ php.lookup.pkgs.local_bin }}
  52. - env:
  53. - HOME: {{ salt_user_home }}
  54. - require:
  55. - cmd: install-composer