Migrate to repo.packagist.org for package metadata
parent
2f69739c1a
commit
c5fa3bdde0
|
@ -59,7 +59,7 @@ The main repository type is the `composer` repository. It uses a single
|
||||||
This is also the repository type that packagist uses. To reference a
|
This is also the repository type that packagist uses. To reference a
|
||||||
`composer` repository, supply the path before the `packages.json` file.
|
`composer` repository, supply the path before the `packages.json` file.
|
||||||
In the case of packagist, that file is located at `/packages.json`, so the URL of
|
In the case of packagist, that file is located at `/packages.json`, so the URL of
|
||||||
the repository would be `packagist.org`. For `example.org/packages.json` the
|
the repository would be `repo.packagist.org`. For `example.org/packages.json` the
|
||||||
repository URL would be `example.org`.
|
repository URL would be `example.org`.
|
||||||
|
|
||||||
#### packages
|
#### packages
|
||||||
|
|
|
@ -81,7 +81,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$config->merge(array('config' => array('secure-http' => false)));
|
$config->merge(array('config' => array('secure-http' => false)));
|
||||||
$config->prohibitUrlByConfig('http://packagist.org', new NullIO);
|
$config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
|
||||||
|
|
||||||
$this->rfs = Factory::createRemoteFilesystem($io, $config);
|
$this->rfs = Factory::createRemoteFilesystem($io, $config);
|
||||||
$this->process = new ProcessExecutor($io);
|
$this->process = new ProcessExecutor($io);
|
||||||
|
@ -208,7 +208,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->rfs->getContents('packagist.org', $proto . '://packagist.org/packages.json', false);
|
$this->rfs->getContents('packagist.org', $proto . '://repo.packagist.org/packages.json', false);
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
if (false !== strpos($e->getMessage(), 'cafile')) {
|
if (false !== strpos($e->getMessage(), 'cafile')) {
|
||||||
$result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
|
$result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
|
||||||
|
@ -230,11 +230,11 @@ EOT
|
||||||
{
|
{
|
||||||
$protocol = extension_loaded('openssl') ? 'https' : 'http';
|
$protocol = extension_loaded('openssl') ? 'https' : 'http';
|
||||||
try {
|
try {
|
||||||
$json = json_decode($this->rfs->getContents('packagist.org', $protocol . '://packagist.org/packages.json', false), true);
|
$json = json_decode($this->rfs->getContents('packagist.org', $protocol . '://repo.packagist.org/packages.json', false), true);
|
||||||
$hash = reset($json['provider-includes']);
|
$hash = reset($json['provider-includes']);
|
||||||
$hash = $hash['sha256'];
|
$hash = $hash['sha256'];
|
||||||
$path = str_replace('%hash%', $hash, key($json['provider-includes']));
|
$path = str_replace('%hash%', $hash, key($json['provider-includes']));
|
||||||
$provider = $this->rfs->getContents('packagist.org', $protocol . '://packagist.org/'.$path, false);
|
$provider = $this->rfs->getContents('packagist.org', $protocol . '://repo.packagist.org/'.$path, false);
|
||||||
|
|
||||||
if (hash('sha256', $provider) !== $hash) {
|
if (hash('sha256', $provider) !== $hash) {
|
||||||
return 'It seems that your proxy is modifying http traffic on the fly';
|
return 'It seems that your proxy is modifying http traffic on the fly';
|
||||||
|
@ -255,7 +255,7 @@ EOT
|
||||||
*/
|
*/
|
||||||
private function checkHttpProxyFullUriRequestParam()
|
private function checkHttpProxyFullUriRequestParam()
|
||||||
{
|
{
|
||||||
$url = 'http://packagist.org/packages.json';
|
$url = 'http://repo.packagist.org/packages.json';
|
||||||
try {
|
try {
|
||||||
$this->rfs->getContents('packagist.org', $url, false);
|
$this->rfs->getContents('packagist.org', $url, false);
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ EOT
|
||||||
}
|
}
|
||||||
$repos[] = RepositoryFactory::createRepo($io, $config, array(
|
$repos[] = RepositoryFactory::createRepo($io, $config, array(
|
||||||
'type' => 'composer',
|
'type' => 'composer',
|
||||||
'url' => 'https://packagist.org',
|
'url' => 'https://repo.packagist.org',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->repos = new CompositeRepository($repos);
|
$this->repos = new CompositeRepository($repos);
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Config
|
||||||
public static $defaultRepositories = array(
|
public static $defaultRepositories = array(
|
||||||
'packagist.org' => array(
|
'packagist.org' => array(
|
||||||
'type' => 'composer',
|
'type' => 'composer',
|
||||||
'url' => 'https?://packagist.org',
|
'url' => 'https?://repo.packagist.org',
|
||||||
'allow_ssl_downgrade' => true,
|
'allow_ssl_downgrade' => true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -90,6 +90,12 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->options = $repoConfig['options'];
|
$this->options = $repoConfig['options'];
|
||||||
$this->url = $repoConfig['url'];
|
$this->url = $repoConfig['url'];
|
||||||
|
|
||||||
|
// force url for packagist.org to repo.packagist.org
|
||||||
|
if (preg_match('{^(?P<proto>https?)://packagist.org/?$}i', $this->url, $match)) {
|
||||||
|
$this->url = $match['proto'].'://repo.packagist.org';
|
||||||
|
}
|
||||||
|
|
||||||
$this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
|
$this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
|
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
|
||||||
|
@ -539,10 +545,10 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
// force values for packagist
|
// force values for packagist
|
||||||
if (preg_match('{^https?://packagist.org/?$}i', $this->url) && !empty($this->repoConfig['force-lazy-providers'])) {
|
if (preg_match('{^https?://repo\.packagist\.org/?$}i', $this->url) && !empty($this->repoConfig['force-lazy-providers'])) {
|
||||||
$this->url = 'https://packagist.org';
|
$this->url = 'https://repo.packagist.org';
|
||||||
$this->baseUrl = 'https://packagist.org';
|
$this->baseUrl = 'https://repo.packagist.org';
|
||||||
$this->lazyProvidersUrl = $this->canonicalizeUrl('https://packagist.org/p/%package%.json');
|
$this->lazyProvidersUrl = $this->canonicalizeUrl('https://repo.packagist.org/p/%package%.json');
|
||||||
$this->providersUrl = null;
|
$this->providersUrl = null;
|
||||||
} elseif (!empty($this->repoConfig['force-lazy-providers'])) {
|
} elseif (!empty($this->repoConfig['force-lazy-providers'])) {
|
||||||
$this->lazyProvidersUrl = $this->canonicalizeUrl('/p/%package%.json');
|
$this->lazyProvidersUrl = $this->canonicalizeUrl('/p/%package%.json');
|
||||||
|
|
|
@ -283,9 +283,9 @@ class RemoteFilesystem
|
||||||
$options['http']['ignore_errors'] = true;
|
$options['http']['ignore_errors'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->degradedMode && substr($fileUrl, 0, 21) === 'http://packagist.org/') {
|
if ($this->degradedMode && substr($fileUrl, 0, 26) === 'http://repo.packagist.org/') {
|
||||||
// access packagist using the resolved IPv4 instead of the hostname to force IPv4 protocol
|
// access packagist using the resolved IPv4 instead of the hostname to force IPv4 protocol
|
||||||
$fileUrl = 'http://' . gethostbyname('packagist.org') . substr($fileUrl, 20);
|
$fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
|
||||||
$degradedPackagist = true;
|
$degradedPackagist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ class RemoteFilesystem
|
||||||
unset($origFileUrl, $actualContextOptions);
|
unset($origFileUrl, $actualContextOptions);
|
||||||
|
|
||||||
// Check for secure HTTP, but allow insecure Packagist calls to $hashed providers as file integrity is verified with sha256
|
// Check for secure HTTP, but allow insecure Packagist calls to $hashed providers as file integrity is verified with sha256
|
||||||
if ((substr($fileUrl, 0, 23) !== 'http://packagist.org/p/' || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
|
if ((!preg_match('{^http://(repo\.)?packagist.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
|
||||||
$this->config->prohibitUrlByConfig($fileUrl, $this->io);
|
$this->config->prohibitUrlByConfig($fileUrl, $this->io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ConfigTest extends TestCase
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['local config inherits system defaults'] = array(
|
$data['local config inherits system defaults'] = array(
|
||||||
array(
|
array(
|
||||||
'packagist.org' => array('type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true),
|
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
);
|
);
|
||||||
|
@ -59,7 +59,7 @@ class ConfigTest extends TestCase
|
||||||
array(
|
array(
|
||||||
1 => array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
1 => array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
||||||
0 => array('type' => 'pear', 'url' => 'http://pear.composer.org'),
|
0 => array('type' => 'pear', 'url' => 'http://pear.composer.org'),
|
||||||
'packagist.org' => array('type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true),
|
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
||||||
|
@ -70,7 +70,7 @@ class ConfigTest extends TestCase
|
||||||
$data['system config adds above core defaults'] = array(
|
$data['system config adds above core defaults'] = array(
|
||||||
array(
|
array(
|
||||||
'example.com' => array('type' => 'composer', 'url' => 'http://example.com'),
|
'example.com' => array('type' => 'composer', 'url' => 'http://example.com'),
|
||||||
'packagist.org' => array('type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true),
|
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
array(
|
array(
|
||||||
|
@ -107,7 +107,7 @@ class ConfigTest extends TestCase
|
||||||
|
|
||||||
$data['incorrect local config does not cause ErrorException'] = array(
|
$data['incorrect local config does not cause ErrorException'] = array(
|
||||||
array(
|
array(
|
||||||
'packagist.org' => array('type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true),
|
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
|
||||||
'type' => 'vcs',
|
'type' => 'vcs',
|
||||||
'url' => 'http://example.com',
|
'url' => 'http://example.com',
|
||||||
),
|
),
|
||||||
|
|
|
@ -119,7 +119,7 @@ class ValidatingArrayLoaderTest extends TestCase
|
||||||
'repositories' => array(
|
'repositories' => array(
|
||||||
array(
|
array(
|
||||||
'type' => 'composer',
|
'type' => 'composer',
|
||||||
'url' => 'https://packagist.org/',
|
'url' => 'https://repo.packagist.org/',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'config' => array(
|
'config' => array(
|
||||||
|
|
Loading…
Reference in New Issue