From 43631ccd5b89950d8ece86bbf7b42a39fa1ec02e Mon Sep 17 00:00:00 2001 From: Kirill chEbba Chebunin Date: Fri, 30 Sep 2011 01:05:30 +0400 Subject: [PATCH] Add Tar and Phar downloaders --- src/Composer/Downloader/PearDownloader.php | 10 +++++-- src/Composer/Downloader/PharDownloader.php | 33 ++++++++++++++++++++++ src/Composer/Downloader/TarDownloader.php | 33 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/Composer/Downloader/PharDownloader.php create mode 100644 src/Composer/Downloader/TarDownloader.php diff --git a/src/Composer/Downloader/PearDownloader.php b/src/Composer/Downloader/PearDownloader.php index 2bb1f9c72..07ffc1a09 100644 --- a/src/Composer/Downloader/PearDownloader.php +++ b/src/Composer/Downloader/PearDownloader.php @@ -15,13 +15,19 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; /** + * Downloader for pear packages + * * @author Jordi Boggiano + * @author Kirill chEbba Chebunin */ -class PearDownloader extends FileDownloader +class PearDownloader extends TarDownloader { + /** + * {@inheritDoc} + */ protected function extract($file, $path) { - system(sprintf('tar -zxf %s', escapeshellarg($file))); + parent::extract($file, $path); @unlink($path . '/package.sig'); @unlink($path . '/package.xml'); } diff --git a/src/Composer/Downloader/PharDownloader.php b/src/Composer/Downloader/PharDownloader.php new file mode 100644 index 000000000..290b0281e --- /dev/null +++ b/src/Composer/Downloader/PharDownloader.php @@ -0,0 +1,33 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Downloader; + +use Composer\Package\PackageInterface; + +/** + * Downloader for phar files + * + * @author Kirill chEbba Chebunin + */ +class PharDownloader extends FileDownloader +{ + /** + * {@inheritDoc} + */ + protected function extract($file, $path) + { + // Can throw an UnexpectedValueException + $archive = new \Phar($file); + $archive->extractTo($path); + } +} diff --git a/src/Composer/Downloader/TarDownloader.php b/src/Composer/Downloader/TarDownloader.php new file mode 100644 index 000000000..c239475f7 --- /dev/null +++ b/src/Composer/Downloader/TarDownloader.php @@ -0,0 +1,33 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Downloader; + +use Composer\Package\PackageInterface; + +/** + * Downloader for tar files: tar, tar.gz or tar.bz2 + * + * @author Kirill chEbba Chebunin + */ +class TarDownloader extends FileDownloader +{ + /** + * {@inheritDoc} + */ + protected function extract($file, $path) + { + // Can throw an UnexpectedValueException + $archive = new \PharData($file); + $archive->extractTo($path); + } +}