aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2020-07-24 16:42:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2020-07-24 16:42:51 -0300
commit92010b852f0d353c81fdd969368912dddb730e5d (patch)
treea8cb2e5b8796ec6623139c917b1547bf60ba11c9
parent8b5f4bf41d07c2a90350c78fab8585f5c2d5298d (diff)
downloadpuppet-php-92010b852f0d353c81fdd969368912dddb730e5d.tar.gz
puppet-php-92010b852f0d353c81fdd969368912dddb730e5d.tar.bz2
Updates getcomposer
-rwxr-xr-xfiles/getcomposer36
1 files changed, 27 insertions, 9 deletions
diff --git a/files/getcomposer b/files/getcomposer
index 289c970..a69c805 100755
--- a/files/getcomposer
+++ b/files/getcomposer
@@ -2,17 +2,35 @@
#
# See https://getcomposer.org/download/
# https://composer.github.io/pubkeys.html
+# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
#
-# Download
-#php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-rm -f composer-setup.php
-wget https://getcomposer.org/installer -O composer-setup.php || exit 1
+## Download
+##php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+#rm -f composer-setup.php
+#wget https://getcomposer.org/installer -O composer-setup.php || exit 1
+#
+#php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+#
+#if [ -e "composer-setup.php" ]; then
+# php composer-setup.php --install-dir=/usr/local/bin --filename=composer
+# #php -r "unlink('composer-setup.php');"
+# rm composer-setup.php
+#fi
-php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
+php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
-if [ -e "composer-setup.php" ]; then
- php composer-setup.php --install-dir=/usr/local/bin --filename=composer
- #php -r "unlink('composer-setup.php');"
- rm composer-setup.php
+if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
+then
+ >&2 echo 'ERROR: Invalid installer checksum'
+ rm composer-setup.php
+ exit 1
fi
+
+php composer-setup.php --quiet
+RESULT=$?
+rm composer-setup.php
+mv composer.phar /usr/local/bin/composer
+exit $RESULT