コード例 #1
0
ファイル: Base.php プロジェクト: peopleplan/Pyrus
 function toRaw()
 {
     $info = new \Pyrus\PackageFile\v2();
     $info->fromArray(array('package' => $this->packageInfo));
     return $info;
 }
コード例 #2
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;
 }