Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
made pirum only unarchive the packages if needed (major speed improve…
Browse files Browse the repository at this point in the history
…ment for large repository)
  • Loading branch information
fabpot committed Nov 9, 2009
1 parent 6e1a642 commit b08e593
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 39 deletions.
6 changes: 3 additions & 3 deletions package.xml
Expand Up @@ -15,11 +15,11 @@
<email>fabien.potencier@symfony-project.org</email>
<active>yes</active>
</lead>
<date>2009-10-18</date>
<date>2009-11-09</date>
<time>16:00:00</time>
<version>
<release>0.9.0</release>
<api>0.9.0</api>
<release>0.9.1</release>
<api>0.9.1</api>
</version>
<stability>
<release>beta</release>
Expand Down
91 changes: 55 additions & 36 deletions pirum
Expand Up @@ -769,44 +769,58 @@ EOF;
$files = array_reverse($files);

// get information for each package
$packages = array();
foreach ($files as $file)
{
$this->formatter and print $this->formatter->formatSection('INFO', 'Parsing Package '.basename($file));
$package = new Pirum_Package($file);
if (file_exists($file = $this->targetDir.'/rest/r/'.strtolower($package->getName()).'/package.'.$package->getVersion().'.xml'))
{
$package->loadPackageFromFile($file);
}
else
{
$package->loadPackageFromArchive();
}

$info = new Pirum_Package($file);
$packages[] = $package;
}

if ($info->getChannel() != $this->server->name)
foreach ($packages as $package)
{
$this->formatter and print $this->formatter->formatSection('INFO', 'Parsing Package '.basename($file));

if ($package->getChannel() != $this->server->name)
{
throw new Exception(sprintf('Package "%s" channel (%s) is not %s.', $info->getName(), $info->getChannel(), $this->server->name));
throw new Exception(sprintf('Package "%s" channel (%s) is not %s.', $package->getName(), $package->getChannel(), $this->server->name));
}

if (!isset($this->packages[$info->getName()]))
if (!isset($this->packages[$package->getName()]))
{
$this->packages[$info->getName()] = array(
'name' => $info->getName(),
'license' => $info->getLicense(),
'summary' => $info->getSummary(),
'description' => $info->getDescription(),
$this->packages[$package->getName()] = array(
'name' => $package->getName(),
'license' => $package->getLicense(),
'summary' => $package->getSummary(),
'description' => $package->getDescription(),
'releases' => array(),
'maintainers' => array(),
'current_maintainers' => $info->getMaintainers(),
'current_maintainers' => $package->getMaintainers(),
);
}

$this->packages[$info->getName()]['releases'][] = array(
'version' => $info->getVersion(),
'api_version' => $info->getApiVersion(),
'stability' => $info->getStability(),
'date' => $info->getDate(),
'filesize' => $info->getFilesize(),
'php' => $info->getMinPhp(),
'deps' => $info->getDeps(),
'notes' => $info->getNotes(),
'maintainers' => $info->getMaintainers(),
'info' => $info,
$this->packages[$package->getName()]['releases'][] = array(
'version' => $package->getVersion(),
'api_version' => $package->getApiVersion(),
'stability' => $package->getStability(),
'date' => $package->getDate(),
'filesize' => $package->getFilesize(),
'php' => $package->getMinPhp(),
'deps' => $package->getDeps(),
'notes' => $package->getNotes(),
'maintainers' => $package->getMaintainers(),
'info' => $package,
);

$this->packages[$info->getName()]['maintainers'] = array_merge($info->getMaintainers(), $this->packages[$info->getName()]['maintainers']);
$this->packages[$package->getName()]['maintainers'] = array_merge($package->getMaintainers(), $this->packages[$package->getName()]['maintainers']);
}
}

Expand Down Expand Up @@ -894,6 +908,7 @@ class Pirum_Package
protected $name;
protected $version;
protected $archive;
protected $packageFile;

public function __construct($archive)
{
Expand All @@ -909,8 +924,6 @@ class Pirum_Package
$this->tmpDir = sys_get_temp_dir().'/pirum_package_'.uniqid();

mkdir($this->tmpDir, 0777, true);

$this->loadPackage();
}

public function __destruct()
Expand Down Expand Up @@ -1025,21 +1038,14 @@ class Pirum_Package

public function copyPackageXml($target)
{
copy($this->tmpDir.'/package.xml', $target);
copy($this->packageFile, $target);
}

protected function loadPackage()
public function loadPackageFromFile($file)
{
copy($this->archive, $this->tmpDir.'/archive.tgz');
system('cd '.$this->tmpDir.' && tar zxpf archive.tgz');
$this->packageFile = $file;

if (!is_file($this->tmpDir.'/package.xml'))
{
throw new InvalidArgumentException('The PEAR package does not have a package.xml file.');
}

$packageXml = file_get_contents($this->tmpDir.'/package.xml');
$this->package = new SimpleXMLElement($packageXml);
$this->package = new SimpleXMLElement(file_get_contents($file));

// check name
if ($this->name != (string) $this->package->name)
Expand All @@ -1054,6 +1060,19 @@ class Pirum_Package
}
}

public function loadPackageFromArchive()
{
copy($this->archive, $this->tmpDir.'/archive.tgz');
system('cd '.$this->tmpDir.' && tar zxpf archive.tgz');

if (!is_file($this->tmpDir.'/package.xml'))
{
throw new InvalidArgumentException('The PEAR package does not have a package.xml file.');
}

$this->loadPackageFromFile($this->tmpDir.'/package.xml');
}

protected function XMLToArray($xml)
{
$array = array();
Expand Down

0 comments on commit b08e593

Please sign in to comment.