Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the depedency tracker and version comparator

  • Loading branch information...
commit ee3b04b26301dba4bad9693592a9062a7e26e44b 1 parent a2b04a6
@c9s c9s authored
View
27 src/Onion/Dependency/DependencyPool.php
@@ -26,15 +26,17 @@ class DependencyPool
public $packages = array();
public $packagesById = array();
+ /**
+ * @var array target package versions.
+ */
+ public $packageVersion = array();
-
- function hasPackage($package)
+ public function hasPackage($package)
{
return isset( $this->packagesById[ $package->getId() ] );
}
-
- function addPackage($package)
+ public function addPackage($package, $version)
{
// check package
if( isset( $this->packagesById[ $package->getId() ] ) ) {
@@ -42,15 +44,24 @@ function addPackage($package)
} else {
$this->packages[] = $this->packagesById[ $package->getId() ] = $package;
+ $this->packageVersions[ $package->getId() ] = $version;
+ }
+ }
+
+ public function getPackageVersion($package)
+ {
+ if( isset($this->packageVersions[ $package->getId() ]) ) {
+ return $this->packageVersions[ $package->getId() ];
}
}
- function removePackage($name)
+ public function removePackage($id)
{
- unset( $this->packagesById[ $name ] );
+ unset( $this->packagesById[ $id ] );
+ unset( $this->packageVersions[ $id ] );
}
- function getPackage($id)
+ public function getPackage($id)
{
return $this->packagesById[ $id ];
}
@@ -59,7 +70,7 @@ function getPackage($id)
/**
* return all packages
*/
- function getPackages()
+ public function getPackages()
{
return $this->packages;
}
View
5 src/Onion/Dependency/DependencyResolver.php
@@ -45,8 +45,6 @@ public function resolvePearPackage($package, $depInfo)
return;
}
- // get installed version, compare version
- $this->pool->addPackage($package);
// get dependent package info
$this->logger->info( "Resolving PEAR package dependency: {$package->getId()}" );
@@ -91,6 +89,9 @@ public function resolvePearPackage($package, $depInfo)
$this->logger->debug('Target version: ' . $targetVersion);
}
+ // get installed version, compare version
+ $this->pool->addPackage($package, $targetVersion);
+
if( isset( $package->deps[$targetVersion]['required']['extension']) ) {
foreach( (array) $package->deps[ $targetVersion ]['required']['extension'] as $extension ) {
// XXX: install extensions
View
14 src/Onion/Installer.php
@@ -9,7 +9,7 @@
*
*/
namespace Onion;
-
+use Exception;
/**
* main installer
@@ -27,7 +27,7 @@ class Installer
* @param DependencyPool $pool
* @param array $options
*/
- function __construct($pool, $options = array() )
+ public function __construct($pool, $options = array() )
{
$this->pool = $pool;
@@ -44,27 +44,27 @@ function __construct($pool, $options = array() )
$this->libpath = 'vendor';
}
- function getWorkspace()
+ public function getWorkspace()
{
return $this->workspace;
}
- function getLibraryInstaller()
+ public function getLibraryInstaller()
{
return new Installer\LibraryInstaller( $this );
}
- function getPearInstaller()
+ public function getPearInstaller()
{
return new Installer\PearInstaller( $this );
}
- function install()
+ public function install()
{
$packages = $this->pool->getPackages();
foreach( $packages as $package ) {
$installer = $this->getPearInstaller();
- $installer->install( $package );
+ $installer->install($package , $this->pool->getPackageVersion($package) );
}
}
}
View
12 src/Onion/Installer/PearInstaller.php
@@ -23,7 +23,7 @@ public function __construct($main)
$this->mainInstaller = $main;
}
- public function install( $package )
+ public function install( $package , $targetVersion = null )
{
$logger = \Onion\Application::getInstance()->getLogger();
$logger->info( "Installing {$package->name}" );
@@ -32,15 +32,19 @@ public function install( $package )
// (PHP 5 >= 5.2.1)
// $tmpDir = sys_get_temp_dir();
+ if( ! $targetVersion )
+ $targetVersion = $package->latest;
+
+
$workspace = $this->mainInstaller->getWorkspace();
$packageDir = $workspace . DIRECTORY_SEPARATOR . $package->name;
- $packageSourceDir = $packageDir . DIRECTORY_SEPARATOR . $package->name . '-' . $package->latest;
+ $packageSourceDir = $packageDir . DIRECTORY_SEPARATOR . $package->name . '-' . $targetVersion;
- $url = $package->getReleaseDistUrl( $package->latest );
+ $url = $package->getReleaseDistUrl( $targetVersion );
$info = parse_url( $url );
// download the package.
- $logger->info( "Downloading " . $package->name . '-' . $package->latest . "..." );
+ $logger->info( "Downloading " . $package->name . '-' . $targetVersion . "..." );
// switch to workspace and download the package.
$cwd = getcwd();
Please sign in to comment.
Something went wrong with that request. Please try again.