Composer cleanup
This commit is contained in:
parent
9972fc6d9d
commit
f2d41885af
@ -11,46 +11,31 @@ installed() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
if installed "php"; then
|
!installed "php" && echo "WARNING: You need to have php installed"
|
||||||
if installed "composer"; then
|
|
||||||
echo "WARNING: You already have composer installed - removing to install actual version"
|
if installed "composer"; then
|
||||||
sudo apt remove -y --autoremove composer
|
echo "WARNING: Removing current composer to install its actual version"
|
||||||
sudo rm -f /bin/composer
|
sudo apt remove -y --autoremove composer
|
||||||
sudo rm -f /usr/bin/composer
|
sudo rm -f /bin/composer
|
||||||
sudo rm -f /usr/local/bin/composer
|
sudo rm -f /usr/bin/composer
|
||||||
sudo rm -rf /usr/src/composer
|
sudo rm -f /usr/local/bin/composer
|
||||||
fi
|
sudo rm -rf /usr/src/composer
|
||||||
sudo mkdir -m 0777 -p /usr/src/composer
|
|
||||||
cd /usr/src/composer
|
|
||||||
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
|
|
||||||
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
|
||||||
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
||||||
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', '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
|
|
||||||
sudo cp /usr/src/composer/composer.phar /usr/local/bin/composer
|
|
||||||
cd - >/dev/null
|
|
||||||
sudo rm -rf /usr/src/composer/
|
|
||||||
installed "composer" && composer --version
|
|
||||||
else
|
|
||||||
echo "WARNING: You need to have php installed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# title "Installing composer.phar in home dir..."
|
sudo mkdir -m 0777 -p /usr/src/composer
|
||||||
# cd ~
|
cd /usr/src/composer
|
||||||
# EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
|
|
||||||
# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
|
||||||
# ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
||||||
# if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
|
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
# then
|
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||||
# >&2 echo 'ERROR: Invalid installer signature'
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
|
||||||
# rm composer-setup.php
|
>&2 echo 'ERROR: Invalid installer checksum'
|
||||||
# exit 1
|
rm composer-setup.php
|
||||||
# fi
|
exit 1
|
||||||
# php composer-setup.php --quiet
|
fi
|
||||||
# RESULT=$?
|
php composer-setup.php --quiet
|
||||||
# rm composer-setup.php
|
sudo cp /usr/src/composer/composer.phar /usr/local/bin/composer
|
||||||
|
cd - >/dev/null
|
||||||
|
sudo rm -rf /usr/src/composer/
|
||||||
|
installed "composer" && composer --version
|
||||||
|
Loading…
Reference in New Issue
Block a user