コード例 #1
0
ファイル: InternetMaker.php プロジェクト: peopleplan/Pyrus
 function getPassablePf($name, $version, $state = 'stable')
 {
     $pf = new \Pyrus\PackageFile\v2();
     $pf->name = $name;
     $pf->channel = 'pear2.php.net';
     $pf->summary = 'testing';
     $pf->version['release'] = $version;
     $pf->stability['release'] = $state;
     $pf->description = 'hi description';
     $pf->notes = 'my notes';
     $pf->maintainer['cellog']->role('lead')->email('*****@*****.**')->active('yes')->name('Greg Beaver');
     $pf->setPackagefile($this->__DIR__ . '/package.xml');
     return $pf;
 }
コード例 #2
0
ファイル: make.php プロジェクト: peopleplan/Pyrus
 * P3 -> P2 max 1.3.0, exclude 1.2.3
 *
 * P2 only has releases for 1.0.0, 1.2.0, 1.2.3, and 1.3.1
 *
 * to test composite dep failure
 */
require __DIR__ . '/../../../../../autoload.php';
set_include_path(__DIR__);
$c = \Pyrus\Config::singleton(dirname(__DIR__), dirname(__DIR__) . '/pearconfig.xml');
$c->bin_dir = __DIR__ . '/bin';
restore_include_path();
$c->saveConfig();
$chan = new PEAR2\SimpleChannelServer\Channel('pear2.php.net', 'unit test channel');
$scs = new PEAR2\SimpleChannelServer\Main($chan, __DIR__, dirname(__DIR__) . '/PEAR2');
$scs->saveChannel();
$pf = new \Pyrus\PackageFile\v2();
for ($i = 1; $i <= 6; $i++) {
    file_put_contents(__DIR__ . "/glooby{$i}", 'hi');
}
$pf->name = 'P1';
$pf->channel = 'pear2.php.net';
$pf->summary = 'testing';
$pf->version['release'] = '1.0.0';
$pf->stability['release'] = 'stable';
$pf->description = 'hi description';
$pf->notes = 'my notes';
$pf->maintainer['cellog']->role('lead')->email('*****@*****.**')->active('yes')->name('Greg Beaver');
$pf->setPackagefile(__DIR__ . '/package.xml');
$save = clone $pf;
$pf->dependencies['required']->package['pear2.php.net/P2']->min('1.1.0')->exclude('1.2.0')->exclude('1.2.3')->recommended('1.3.1')->max('2.0.0');
$pf->files['glooby1'] = array('role' => 'php');
コード例 #3
0
ファイル: Sqlite3.php プロジェクト: peopleplan/Pyrus
 /**
  * Extract a packagefile object from the registry
  * @return \Pyrus\PackageFile\v2
  */
 function toPackageFile($package, $channel)
 {
     if (!static::existsRegistry($this->_path)) {
         throw new Exception('Error: no existing SQLite3 registry for ' . $this->_path);
     }
     if (!$this->exists($package, $channel)) {
         throw new Exception('Cannot retrieve package file object ' . 'for package ' . $channel . '/' . $package . ', it is not installed');
     }
     $ret = new \Pyrus\PackageFile\v2();
     $ret->name = $this->info($package, $channel, 'name');
     $ret->channel = $channel;
     $ret->summary = $this->info($package, $channel, 'summary');
     $ret->description = $this->info($package, $channel, 'description');
     $ret->type = $this->info($package, $channel, 'packagetype');
     $sql = 'SELECT * FROM maintainers
             WHERE packages_name = :name AND packages_channel = :channel';
     $database = static::getRegistry($this->_path);
     $stmt = $database->prepare($sql);
     $stmt->bindValue(':name', strtolower($package));
     $stmt->bindValue(':channel', $channel);
     $result = @$stmt->execute();
     if (!$result) {
         throw new Exception('Could not retrieve package file object' . ' for package ' . $channel . '/' . $ret->name . ', no maintainers registered');
     }
     while ($maintainer = $result->fetchArray(SQLITE3_ASSOC)) {
         $ret->maintainer[$maintainer['user']]->name($maintainer['name'])->role($maintainer['role'])->email($maintainer['email'])->active($maintainer['active']);
     }
     $stmt->close();
     $ret->date = $this->info($package, $channel, 'date');
     // FIXME why are we querying the same info twice ?
     if ($a = $this->info($package, $channel, 'time')) {
         $ret->time = $this->info($package, $channel, 'time');
     }
     $ret->version['release'] = $this->info($package, $channel, 'version');
     $ret->version['api'] = $this->info($package, $channel, 'apiversion');
     $ret->stability['release'] = $this->info($package, $channel, 'stability');
     $ret->stability['api'] = $this->info($package, $channel, 'apistability');
     $uri = $this->info($package, $channel, 'licenseuri');
     $path = $this->info($package, $channel, 'licensepath');
     $license = $this->info($package, $channel, 'license');
     if ($uri) {
         $ret->rawlicense = array('attribs' => array('uri' => $uri), '_content' => $license);
     } elseif ($path) {
         $ret->rawlicense = array('attribs' => array('path' => $path), '_content' => $license);
     } else {
         $ret->license = $license;
     }
     $ret->notes = $this->info($package, $channel, 'releasenotes');
     $sql = 'SELECT * FROM files
             WHERE packages_name = :name AND packages_channel = :channel';
     $stmt = $database->prepare($sql);
     $stmt->bindValue(':name', strtolower($package));
     $stmt->bindValue(':channel', $channel);
     $result = @$stmt->execute();
     if (!$result) {
         throw new Exception('Could not retrieve package file object' . ' for package ' . $channel . '/' . $ret->name . ', no files registered');
     }
     while ($file = $result->fetchArray(SQLITE3_ASSOC)) {
         $ret->files[$file['origpath']] = array_merge(array('attribs' => array('role' => $file['role'])), unserialize($file['tasks']));
         if ($file['baseinstalldir']) {
             $ret->setFileAttribute($file['origpath'], 'baseinstalldir', $file['baseinstalldir']);
         }
         if ($file['md5sum'] != md5('')) {
             $ret->setFileAttribute($file['origpath'], 'md5sum', $file['md5sum']);
         }
     }
     $stmt->close();
     $sql = 'SELECT dirname, baseinstall FROM baseinstalldirs
             WHERE packages_name = :name AND packages_channel = :channel';
     $stmt = $database->prepare($sql);
     $stmt->bindValue(':name', strtolower($package));
     $stmt->bindValue(':channel', $channel);
     $result = @$stmt->execute();
     if (!$result) {
         throw new Exception('Could not retrieve package file object' . ' for package ' . $channel . '/' . $ret->name . ', no files registered');
     }
     $dirs = array();
     while ($dir = $result->fetchArray(SQLITE3_ASSOC)) {
         $dirs[$dir['dirname']] = $dir['baseinstall'];
     }
     $ret->setBaseInstallDirs($dirs);
     $stmt->close();
     $this->fetchCompatible($ret);
     $this->fetchDeps($ret);
     $ret->release = null;
     $sql = 'SELECT * FROM configureoptions
             WHERE
                 packages_name = "' . $database->escapeString(strtolower($package)) . '" AND
                 packages_channel = "' . $database->escapeString($channel) . '"';
     $a = $database->query($sql);
     while ($option = $a->fetchArray(SQLITE3_ASSOC)) {
         $ret->installrelease->configureoption[$option['name']]->prompt($option['prompt'])->default($option['defaultValue']);
     }
     return $ret;
 }
コード例 #4
0
ファイル: Base.php プロジェクト: peopleplan/Pyrus
 function toRaw()
 {
     $info = new \Pyrus\PackageFile\v2();
     $info->fromArray(array('package' => $this->packageInfo));
     return $info;
 }
コード例 #5
0
ファイル: Pear1.php プロジェクト: peopleplan/Pyrus
 public function toPackageFile($package, $channel)
 {
     if (!$this->exists($package, $channel)) {
         throw new Exception('Cannot retrieve package file object for package ' . $channel . '/' . $package . ', it is not installed');
     }
     $packagefile = $this->_nameRegistryPath(null, $channel, $package);
     if (!$packagefile) {
         throw new Exception('Cannot find registry for package ' . $channel . '/' . $package);
     }
     $contents = file_get_contents($packagefile);
     if (!$contents) {
         throw new Exception('Cannot find registry for package ' . $channel . '/' . $package);
     }
     $data = @unserialize($contents);
     if ($data === false) {
         throw new Exception('Cannot retrieve package file object for package ' . $channel . '/' . $package . ', PEAR 1.x registry file might be corrupt!');
     }
     if (isset($data['xsdversion']) && $data['xsdversion'] == '1.0' || !isset($data['attribs']) || isset($data['attribs']) && $data['attribs']['version'] == '1.0') {
         // make scrappy minimal package.xml we can use for dependencies/info
         $pf = new \Pyrus\PackageFile\v2();
         $pf->name = $data['package'];
         $pf->channel = 'pear.php.net';
         $pf->version['release'] = $pf->version['api'] = $data['version'];
         $pf->stability['release'] = $pf->stability['api'] = $data['release_state'];
         $pf->notes = $data['release_notes'];
         $pf->license['name'] = $data['release_license'];
         $pf->date = $data['release_date'];
         foreach ($data['maintainers'] as $maintainer) {
             $pf->maintainer[$maintainer['handle']]->name($maintainer['name'])->active('yes')->role($maintainer['role'])->email($maintainer['email']);
         }
         // we don't care what the ancient package depends on, really, so make it valid
         // and forget about it
         $pf->dependencies['required']->php->min = phpversion();
         $pf->dependencies['required']->pearinstaller->min = '1.4.0';
         unset($data['filelist']['dirtree']);
         foreach ($data['filelist'] as $file => $info) {
             $pf->files[$file] = array('attribs' => $info);
         }
     } else {
         // create packagefile v2 here
         $pf = new \Pyrus\PackageFile\v2();
         $pf->fromArray(array('package' => $data));
         $contents = $data['contents']['dir']['file'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         foreach ($contents as $file) {
             $pf->files[$file['attribs']['name']] = $file;
         }
     }
     return $pf;
 }