protected function __construct($rolepath)
    {
        if (isset(Main::$options['packagingroot'])) {
            $rolepath = Main::prepend(Main::$options['packagingroot'], $rolepath);
        }
        $rolepath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $rolepath);

        $this->rolepath = $rolepath;
        $path = dirname($rolepath) . DIRECTORY_SEPARATOR;

        $this->backuppath  = $path . '.old-' . basename($rolepath);
        $this->journalpath = $path . '.journal-' . basename($rolepath);
        $this->defaultMode = 0777 & ~octdec(Config::current()->umask);
    }
Esempio n. 2
0
    /**
     * Initialize the registry
     *
     * @param string $path
     */
    function __construct($path, $readonly = false)
    {
        $this->readonly = $readonly;
        if (isset(Main::$options['packagingroot'])) {
            $path = Main::prepend(Main::$options['packagingroot'], $path);
        }

        $this->path = $path;
        $this->channelpath = $path . DIRECTORY_SEPARATOR . '.xmlregistry' . DIRECTORY_SEPARATOR . 'channels';
        if (1 === $this->exists('pear.php.net')) {
            $this->initialized = false;
        } else {
            $this->initialized = true;
        }
    }
Esempio n. 3
0
    function __construct($path, $readonly = false)
    {
        $this->readonly = $readonly;
        if (!file_exists($path . '/.registry') && basename($path) !== 'php') {
            $path = $path . DIRECTORY_SEPARATOR . 'php';
        }

        $this->path = $path;
        if (isset(\PEAR2\Pyrus\Main::$options['packagingroot'])) {
            $path = \PEAR2\Pyrus\Main::prepend(\PEAR2\Pyrus\Main::$options['packagingroot'], $path);
        }

        $this->_channelPath = $path . DIRECTORY_SEPARATOR . '.channels';
        $this->_aliasPath   = $this->_channelPath . DIRECTORY_SEPARATOR . '.alias';
        if (!file_exists($this->_channelPath) || !is_dir($this->_channelPath)) {
            if ($readonly) {
                throw new Exception('Cannot initialize PEAR1 channel registry, directory' .
                                    ' does not exist and registry is read-only');
            }

            if (!@mkdir($this->_channelPath, 0755, true)) {
                throw new Exception('Cannot initialize PEAR1 channel registry, channel' .
                                    ' directory could not be initialized');
            }
        }

        if (!file_exists($this->_aliasPath) || !is_dir($this->_aliasPath)) {
            if ($readonly) {
                throw new Exception('Cannot initialize PEAR1 channel registry, aliasdirectory ' .
                                    'does not exist and registry is read-only');
            }

            if (!@mkdir($this->_aliasPath, 0755, true)) {
                throw new Exception('Cannot initialize PEAR1 channel registry, channel ' .
                                    'aliasdirectory could not be initialized');
            }
        }

        if (1 === $this->exists('pear.php.net')) {
            $this->initialized = false;
        } else {
            $this->initialized = true;
        }
    }
Esempio n. 4
0
 /**
  * Returns a list of registries present in the PEAR installation at $path
  * @param string
  * @return array
  */
 public static function detectRegistries($path)
 {
     if (isset(Main::$options['packagingroot'])) {
         $path = Main::prepend(Main::$options['packagingroot'], $path);
     }
     if (file_exists($path . '/.xmlregistry') || is_dir($path . '/.xmlregistry')) {
         return array('Xml');
     }
     return array();
 }
Esempio n. 5
0
    static private function _init($path, $readonly)
    {
        if (!$path) {
            $path = ':memory:';
        } else {
            $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        }

        if (static::existsRegistry($path)) {
            return;
        }

        $dbpath = $path;
        if ($path != ':memory:' && isset(Main::$options['packagingroot'])) {
            $dbpath = Main::prepend(Main::$options['packagingroot'], $path);
        }

        if ($path != ':memory:' && !file_exists(dirname($dbpath))) {
            if ($readonly) {
                throw new Exception('Cannot create SQLite3 registry, registry is read-only');
            }
            @mkdir(dirname($dbpath), 0755, true);
        }

        if ($readonly && $path != ':memory:' && !file_exists($dbpath)) {
            throw new Exception('Cannot create SQLite3 registry, registry is read-only');
        }

        static::$databases[$path] = new \SQLite3($dbpath);
        // ScottMac needs to fix sqlite3 FIXME
        if (static::$databases[$path]->lastErrorCode()) {
            $error = static::$databases[$path]->lastErrorMsg();
            throw new Exception('Cannot open SQLite3 registry: ' . $error);
        }

        $sql = 'SELECT version FROM pearregistryversion';
        if (@static::getRegistry($path)->querySingle($sql) == '1.0.0') {
            return;
        }

        if ($readonly) {
            throw new Exception('Cannot create SQLite3 registry, registry is read-only');
        }

        $a = new Sqlite3\Creator;
        try {
            $a->create(static::$databases[$path]);
        } catch (\Exception $e) {
            unset(static::$databases[$path]);
            $a = get_class($e);
            throw new $a('Database initialization failed', 0, $e);
        }
    }
Esempio n. 6
0
 /**
  * Returns a list of registries present in the PEAR installation at $path
  * @param string
  * @return array
  */
 public static function detectRegistries($path)
 {
     if (isset(Main::$options['packagingroot'])) {
         $path = Main::prepend(Main::$options['packagingroot'], $path);
     }
     if (file_exists($path . '/.registry') || is_dir($path . '/.registry')) {
         return array('Pear1');
     }
     if (basename($path) !== 'php') {
         $path = $path . DIRECTORY_SEPARATOR . 'php';
     }
     if (file_exists($path . '/.registry') || is_dir($path . '/.registry')) {
         return array('Pear1');
     }
     return array();
 }