mirror of
https://github.com/danog/docker-php-extension-installer.git
synced 2024-12-02 09:27:58 +01:00
Use package2.xml when available, accept non-namespaced package.xml files
This commit is contained in:
parent
fa904a9f51
commit
28f1ef2155
@ -104,7 +104,12 @@ function inspectPackageVersion(string $package, string $version): PackageVersion
|
||||
mkdir($extractedDir);
|
||||
|
||||
try {
|
||||
$archive->extractTo($extractedDir, 'package.xml');
|
||||
try {
|
||||
$archive->extractTo($extractedDir, 'package2.xml');
|
||||
rename("{$extractedDir}/package2.xml", "{$extractedDir}/package.xml");
|
||||
} catch (PharException $x) {
|
||||
$archive->extractTo($extractedDir, 'package.xml');
|
||||
}
|
||||
|
||||
try {
|
||||
$dom = new DOMDocument();
|
||||
@ -113,16 +118,21 @@ function inspectPackageVersion(string $package, string $version): PackageVersion
|
||||
}
|
||||
$xpath = new DOMXPath($dom);
|
||||
$xpath->registerNamespace('v2', 'http://pear.php.net/dtd/package-2.0');
|
||||
if ($xpath->query('/v2:package/v2:dependencies')->count() !== 1) {
|
||||
if ($xpath->query('/v2:package/v2:dependencies')->count() === 1) {
|
||||
$ns = 'v2:';
|
||||
} elseif ($xpath->query('/package/release/version')->count() === 1) {
|
||||
$ns = '';
|
||||
} else {
|
||||
throw new RuntimeException('Unsupported namespace');
|
||||
}
|
||||
$maxPHPVersionNodes = $xpath->query('/v2:package/v2:dependencies/v2:required/v2:php/v2:max');
|
||||
$minPHPVersionNodes = $xpath->query("/{$ns}package/{$ns}dependencies/{$ns}required/{$ns}php/{$ns}min");
|
||||
$maxPHPVersionNodes = $xpath->query("/{$ns}package/{$ns}dependencies/{$ns}required/{$ns}php/{$ns}max");
|
||||
$info = new PackageVersion(
|
||||
$version,
|
||||
$xpath->query('/v2:package/v2:dependencies/v2:required/v2:php/v2:min')[0]->nodeValue,
|
||||
$minPHPVersionNodes->count() === 0 ? '' : $minPHPVersionNodes[0]->nodeValue,
|
||||
$maxPHPVersionNodes->count() === 0 ? '' : $maxPHPVersionNodes[0]->nodeValue
|
||||
);
|
||||
foreach ($xpath->query('/v2:package/v2:extsrcrelease/v2:configureoption') as $configureOptionNode) {
|
||||
foreach ($xpath->query("/{$ns}package/{$ns}extsrcrelease/{$ns}configureoption") as $configureOptionNode) {
|
||||
$info->addConfigureOption(new PackageConfigureOption(
|
||||
$configureOptionNode->getAttribute('name'),
|
||||
$configureOptionNode->getAttribute('prompt'),
|
||||
|
Loading…
Reference in New Issue
Block a user