这将下载 Composer 安装程序,验证其签名,然后运行安装程序:
<target name="composer" description="Install composer">
<exec executable="wget">
<arg value="-O" />
<arg value="composer-setup.sig" />
<arg value="https://composer.github.io/installer.sig" />
</exec>
<exec executable="wget">
<arg value="-O" />
<arg value="composer-setup.php" />
<arg value="https://getcomposer.org/installer" />
</exec>
<exec executable="bash">
<arg value="-c" />
<arg value="awk '{print $$0 " composer-setup.php"}' composer-setup.sig | sha384sum --check" />
</exec>
<exec executable="php">
<arg value="composer-setup.php" />
</exec>
<exec executable="rm">
<arg value="composer-setup.php" />
</exec>
<exec executable="rm">
<arg value="composer-setup.sig" />
</exec>
<exec executable="mv">
<arg value="composer.phar" />
<arg value="composer" />
</exec>
</target>
如果您使用的是 GNU Make,这是等价的:
all: vendor
vendor: composer composer.json composer.lock
./composer install
composer:
wget -O composer-setup.sig https://composer.github.io/installer.sig
wget -O composer-setup.php https://getcomposer.org/installer
awk '{print $$0 " composer-setup.php"}' composer-setup.sig | sha384sum --check
php composer-setup.php --quiet
rm composer-setup.*
mv composer.phar composer