예제 #1
0
 /**
  * @param array $data
  */
 public function unserialize($data)
 {
     $data = json_decode($data, true);
     $packageName = key($data['packages']);
     $packages =& $data['packages'][$packageName];
     foreach ($packages as $version => $info) {
         $tmpPackage = new Package();
         $tmpPackage->setName($packageName);
         $tmpPackage->setTag($version);
         $tmpPackage->setFromArray($info);
         $this->data[$version] = $tmpPackage;
     }
     $this->name = $packageName;
     list($this->vendorName, $this->packageName) = explode('/', $packageName);
 }
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
include "prepend.inc.php";
$Server = getData("Server", "integer");
$User = getData("User");
$Packagename = getData("Packagename");
$html = "<h1> Database  " . $DB->Name($Server) . " - Package " . $Packagename . "</h1>";
if ($Packagename) {
    $pack = new Package($Server);
    $pack->setOwner($User);
    $pack->setName($Packagename);
    $pack->getData();
    $html .= "<table border=0><tr><th>Tag</th><th>Value</th></tr>";
    $html .= "<tr><td>Name</td><td>" . $pack->name . "</td></tr>";
    $html .= "<tr><td>Owner</td><td>" . $pack->owner . "</td></tr>";
    $html .= "<tr><td>Created</td><td>" . $pack->created . "</td></tr>";
    $html .= "<tr><td>Last Modified</td><td>" . $pack->lastmodified . "</td></tr>";
    $html .= "<tr><td>Status</td><td>" . $pack->status . "</td></tr>";
    $html .= "</table>";
    $html .= "<P><B>Package body:</b><br>";
    $html .= nl2br($pack->sql) . "<br>";
    $html .= "</P>";
}
$page = new Page("Package Properties");
$page->setHead();
$page->setBody();
예제 #3
0
 /**
  * Installs a package.
  * 
  * @param string $name
  * @param bool $simulate
  * @return bool
  */
 public static function installPackage($name, $simulate = false)
 {
     $package = Curry_PackageManager::getPackage($name);
     if (!$package) {
         throw new Exception('Package not found');
     }
     $installedPackage = PackageQuery::create()->findPk($name);
     if ($installedPackage) {
         throw new Exception('Package already installed');
     }
     if (!$simulate && !self::execTask($package, 'preInstall', true)) {
         return new Exception('Package installation prevented by preInstall hook.');
     }
     if (!$simulate) {
         $installedPackage = new Package();
         $installedPackage->setName($package['name']);
         $installedPackage->setVersion($package['version']);
         $installedPackage->save();
     }
     $tar = new Curry_Archive(self::getCachedFile($package['source'], true));
     foreach ($tar as $tarFile) {
         $file = $tarFile->getPathname();
         try {
             $target = PackageFile::mapFile($file);
         } catch (Exception $e) {
             self::log('Skipping: ' . $file);
             continue;
         }
         // create directory
         if ($tarFile->isDir()) {
             if (!$simulate) {
                 if (!file_exists($target)) {
                     mkdir($target, 0777, true);
                 }
             }
             continue;
         }
         // Extract file
         self::log('Adding: ' . $file, Curry_Backend::MSG_SUCCESS);
         if (!$simulate) {
             if (file_exists($target)) {
                 $backupTarget = $target . "." . date("-Ymd_His");
                 if (file_exists($backupTarget)) {
                     throw new Exception('Unable to backup existing file.');
                 }
                 rename($target, $backupTarget);
             }
             $tarFile->extract($target);
             $packageFile = new PackageFile();
             $packageFile->setPackage($installedPackage);
             $packageFile->setFilename($file);
             $packageFile->setChecksum(sha1_file($target));
             $packageFile->save();
         }
     }
     if (!$simulate) {
         self::execTaskWithReload($package, 'postInstall');
     }
     self::$installed = null;
     return true;
 }
예제 #4
0
 public function testGetAndSetName()
 {
     $this->assertEquals(null, $this->sut->getName());
     $this->sut->setName('bar');
     $this->assertEquals('bar', $this->sut->getName());
 }