diff options
Diffstat (limited to 'files/getcomposer')
-rwxr-xr-x | files/getcomposer | 36 |
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 |