function getPassablePf($name, $version, $state = 'stable')
 {
     $pf = new \PEAR2\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;
 }
Exemple #2
0
}

require __DIR__ . '/../../../../../autoload.php';

set_include_path(__DIR__);
$c = \PEAR2\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 \PEAR2\Pyrus\PackageFile\v2;

for ($i = 1; $i <= 1; $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->files['glooby1'] = array('role' => 'php');
Exemple #3
0
    /**
     * Extract a packagefile object from the registry
     * @return \PEAR2\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 \PEAR2\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;
    }
Exemple #4
0
 function toRaw()
 {
     $info = new \PEAR2\Pyrus\PackageFile\v2();
     $info->fromArray(array('package' => $this->packageInfo));
     return $info;
 }
Exemple #5
0
    public function installCustomRole()
    {
        $pf = new \PEAR2\Pyrus\PackageFile\v2;

        $pf->name = 'PyrusBundlePlugin';
        $pf->channel = 'pear2.php.net';
        $pf->summary = 'Local';
        $pf->description = 'Description';
        $pf->notes = 'My Notes';
        $pf->maintainer['naderman']->role('lead')->email('*****@*****.**')->active('yes')->name('Nils Adermann');
        $pf->files['Bundle.xml'] = array(
            'attribs' => array('role' => 'customrole'),
        );
        $pf->files['PyrusBundlePlugin/Role/Bundle.php'] = array(
            'attribs' => array('role' => 'php'),
        );

        $package_xml = __DIR__ . '/plugin/package.xml';
        $pf->setPackagefile($package_xml);

        $package = new \PEAR2\Pyrus\Package(false);
        $xmlcontainer = new \PEAR2\Pyrus\PackageFile($pf);
        $xml = new \PEAR2\Pyrus\Package\Xml($package_xml, $package, $xmlcontainer);
        $package->setInternalPackage($xml);
        \PEAR2\Pyrus\Main::$options['install-plugins'] = true;

        \PEAR2\Pyrus\Installer::begin();
        \PEAR2\Pyrus\Installer::prepare($package);
        \PEAR2\Pyrus\Installer::commit();

        $this->readConfig();
    }
Exemple #6
0
 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 \PEAR2\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 \PEAR2\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;
 }