示例#1
0
 /**
  * Detect any files already installed that would be overwritten by
  * files inside the package represented by $package
  */
 public function detectFileConflicts(\Pyrus\PackageFileInterface $package)
 {
     if (!static::existsRegistry($this->_path)) {
         throw new \Pyrus\ChannelRegistry\Exception('Error: no existing SQLite3 channel registry for ' . $this->_path);
     }
     $database = static::getRegistry($this->_path);
     $ret = array();
     $sql = 'SELECT
                 packages_channel, packages_name
             FROM files
             WHERE
                 packagepath = :path
             ORDER BY packages_channel, packages_name';
     $stmt = $database->prepare($sql);
     // now iterate over each file in the package, and note all the conflicts
     $roles = array();
     foreach (Role::getValidRoles($package->getPackageType()) as $role) {
         // set up a list of file role => configuration variable
         // for storing in the registry
         $roles[$role] = Role::factory($package->getPackageType(), $role);
     }
     $ret = array();
     $config = Config::current();
     foreach ($package->installcontents as $file) {
         $stmt->reset();
         $relativepath = $roles[$file->role]->getRelativeLocation($package, $file);
         if (!$relativepath) {
             continue;
         }
         $testpath = $config->{$roles[$file->role]->getLocationConfig()} . DIRECTORY_SEPARATOR . $relativepath;
         $stmt->bindValue(':path', $testpath, SQLITE3_TEXT);
         $result = $stmt->execute();
         while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
             $pn = $this->info($res['packages_name'], $res['packages_channel'], 'name');
             $ret[] = array($relativepath => $res['packages_channel'] . '/' . $pn);
         }
     }
     return $ret;
 }
示例#2
0
文件: Xml.php 项目: peopleplan/Pyrus
 /**
  * Detect any files already installed that would be overwritten by
  * files inside the package represented by $package
  */
 public function detectFileConflicts(\Pyrus\PackageFileInterface $package)
 {
     // construct list of all installed files
     $filesByPackage = $allfiles = array();
     $config = \Pyrus\Config::current();
     foreach ($config->channelregistry as $channel) {
         foreach ($this->listPackages($channel->name) as $packagename) {
             $files = $this->info($packagename, $channel->name, 'installedfiles');
             $newfiles = array();
             foreach ($files as $file) {
                 $newfiles[$file['installed_as']] = $file;
             }
             $filesByPackage[$channel->name . '/' . $packagename] = $newfiles;
             $allfiles = array_merge($allfiles, $newfiles);
         }
     }
     // now iterate over each file in the package, and note all the conflicts
     $roles = array();
     foreach (Role::getValidRoles($package->getPackageType()) as $role) {
         // set up a list of file role => configuration variable
         // for storing in the registry
         $roles[$role] = Role::factory($package->getPackageType(), $role);
     }
     $ret = array();
     foreach ($package->installcontents as $file) {
         $relativepath = $roles[$file->role]->getRelativeLocation($package, $file);
         if (!$relativepath) {
             continue;
         }
         $testpath = $config->{$roles[$file->role]->getLocationConfig()} . DIRECTORY_SEPARATOR . $relativepath;
         if (isset($allfiles[$testpath])) {
             foreach ($filesByPackage as $pname => $files) {
                 if (isset($files[$testpath])) {
                     $ret[] = array($relativepath => $pname);
                     break;
                 }
             }
         }
     }
     return $ret;
 }
示例#3
0
 /**
  * Detect any files already installed that would be overwritten by
  * files inside the package represented by $package
  */
 public function detectFileConflicts(\Pyrus\PackageFileInterface $package)
 {
     $filemap = $this->readFileMap();
     if (!$filemap) {
         return array();
     }
     // now iterate over each file in the package, and note all the conflicts
     $roles = array();
     foreach (Role::getValidRoles($package->getPackageType()) as $role) {
         // set up a list of file role => configuration variable
         // for storing in the registry
         $roles[$role] = Role::factory($package->getPackageType(), $role);
     }
     $ret = array();
     foreach ($package->installcontents as $file) {
         $relativepath = $roles[$file->role]->getRelativeLocation($package, $file);
         if (!$relativepath) {
             continue;
         }
         if (isset($filemap[$file->role][$relativepath])) {
             if (is_array($filemap[$file->role][$relativepath])) {
                 $ret[] = array($relativepath => $filemap[$file->role][$relativepath][0] . '/' . $this->info($filemap[$file->role][$relativepath][1], $filemap[$file->role][$relativepath][0], 'name'));
             } else {
                 $ret[] = array($relativepath => 'pear.php.net/' . $this->info($filemap[$file->role][$relativepath], 'pear.php.net', 'name'));
             }
         }
     }
     return $ret;
 }