/** * Retrieve packages informations * * @param Object $db A reference to the database * @param string $type The current type * * @return array */ function report($db, $type) { global $what, $smarty; $packages = null; $rpmrepo = new TableRpmRepo($db); $rpmtable = new TableRpm($db); $uptable = new TableUpstream($db); $repos = $rpmrepo->getAllRepoHash(); $smarty->assign('repos', $repos); $crit = array('type' => $type, 'ORDER' => 'name'); if (substr($what, 0, 1) == '#') { $crit['channel'] = substr($what, 1); $what = '%fedora'; } $i = 0; foreach ($uptable->request($crit) as $up) { $package = null; $rpmname = $up['name']; $verup = strtolower($up['stable'] ? $up['stable'] : $up['unstable']); $sql2 = "SELECT DISTINCT owner FROM acls WHERE name = '{$rpmname}'"; $res2 = $db->query($sql2); $owners = array(); if ($res2) { while ($owner = $res2->fetchObject()) { $owners[] = $owner->owner; } } $package['name'] = $rpmname; $rpms = array(); foreach ($rpmtable->request(array('name' => $rpmname)) as $rpm) { $rpms[$rpm['repo_main'] . '-' . $rpm['repo_sub']] = $rpm; $package['name'] = '<a href="zoom.php?rpm=' . $rpmname . '" title="' . htmlentities($rpm['summary'], ENT_QUOTES) . '">' . $rpmname . '</a>'; } switch ($what) { case '%work': $display = false; if (count($rpms) && isset($rpms['devel-']) && $rpms['devel-']['ver'] != $verup) { $display = true; } break; case '%fedora': $display = count($rpms); break; case '%stable': $display = !empty($up['stable']); break; case '%all': $display = true; break; default: // owner $display = array_search($what, $owners) !== false; break; } if ($display) { if ($up['channel'] != $up['type']) { $package['channel'] = $up['channel']; } $dispowner = ""; $package['owners'] = $owners; if ($up['stable']) { $package['upstream_stable'] = $up['stable']; } if ($up['unstable'] && (!$up['stable'] || $up['stable'] != $up['unstable'])) { $package['upstream_unstable'] = $up['unstable'] . ' <small>(' . $up['state'] . ')</small>'; } $versions = null; foreach ($repos as $repomain) { $display = ""; $class = ""; foreach ($repomain as $k => $repo) { if (isset($rpms[$repo['main'] . "-" . $repo['sub']])) { $rpm = $rpms[$repo['main'] . "-" . $repo['sub']]; $verpm = $rpm['ver']; $pat = "/\\.((beta|RC)\\d*)\\./i"; if (preg_match($pat, $rpm['rel'], $res)) { $verpm .= strtolower($res[1]); } if (strpos($repo['sub'], '-os') || strpos($repo['sub'], '-beta') || strpos($repo['sub'], '-base') || strpos($repo['sub'], '-optional') || strpos($repo['sub'], '-stable')) { // For CentOS $repotype = 'base'; } else { if (strpos($repo['sub'], 'testing')) { $repotype = 'testing'; } else { if (strpos($repo['sub'], 'updates')) { $repotype = 'updates'; } else { $repotype = $repo['sub']; } } } switch ($repotype) { case "base": if (isset($rpms[$repo['main'] . "-updates"])) { $display .= sprintf("%s-%s<br/>", $rpm['ver'], $rpm['rel']); } else { $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm['ver'], $rpm['rel']); } if ($verup == $verpm) { $class = "check"; } break; case "": $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm['ver'], $rpm['rel']); if ($verup == $verpm) { $class = "check"; } break; case "updates": $display .= sprintf("<strong>%s</strong>-%s" . "<br/><small>(%s)</small><br/>", $rpm['ver'], $rpm['rel'], $repo['sub']); if ($verup == $verpm && $class != 'check') { $class = "check"; } break; case "testing": $display .= sprintf("%s-%s<br/><small>(%s)</small>", $rpm['ver'], $rpm['rel'], $repo['sub']); if ($verup == $verpm && !$class) { $class = "info"; } break; } } // RPM exists } // sub repo if ($display && empty($class)) { $class = "attn"; } $versions[] = array('class' => $class, 'display' => $display); $package['versions'] = $versions; } // mainrepo $i++; $packages[] = $package; } } return $packages; }
/** * Retrieve packages informations * * @param Object $db A reference to the database * * @return array */ function report($db) { global $what, $smarty; $packages = null; $rpmrepo = new TableRpmRepo($db); $repos = $rpmrepo->getAllRepoHash(); $smarty->assign('repos', $repos); if (substr($what, 0, 1) == '%') { $sql = sprintf("SELECT DISTINCT name\n FROM rpm\n WHERE SUBSTRING(name,1,1)='%s'\n ORDER BY name", substr($what, 1, 1)); } else { $sql = sprintf("SELECT DISTINCT name\n FROM acls\n WHERE owner='%s'\n ORDER BY name", $what); } //echo "<p>SQL=$sql</p>"; $i = 0; $res = $db->query($sql); if ($res) { while ($desc = $res->fetchObject()) { $package = null; $rpmname = $desc->name; $sql2 = "SELECT DISTINCT owner FROM acls WHERE name LIKE '{$rpmname}'"; $res2 = $db->query($sql2); $dispowner = ""; $owners = array(); if ($res2) { while ($owner = $res2->fetchObject()) { $owners[] = $owner->owner; } } $sql3 = "SELECT * FROM rpm WHERE name LIKE '{$rpmname}'"; $res3 = $db->query($sql3); $rpm = $res3 ? $res3->fetchObject() : false; if ($rpm) { $url = $rpm->url; $des = htmlentities($rpm->summary); $rpms = array(); do { $rpms[$rpm->repo_main . "-" . $rpm->repo_sub] = $rpm; } while ($rpm = $res3->fetchObject()); $package['name'] = $rpmname; $package['description'] = $des; $package['owners'] = $owners; $versions = null; foreach ($repos as $repomain) { $display = ""; $class = ""; foreach ($repomain as $repo) { if (isset($rpms[$repo['main'] . "-" . $repo['sub']])) { $rpm = $rpms[$repo['main'] . "-" . $repo['sub']]; $maxver = isset($rpms["devel-"]) ? $rpms["devel-"]->ver : ""; if (strpos($repo['sub'], '-os') || strpos($repo['sub'], '-beta') || strpos($repo['sub'], '-base') || strpos($repo['sub'], '-optional') || strpos($repo['sub'], '-stable')) { // For CentOS $repotype = 'base'; } else { if (strpos($repo['sub'], 'testing')) { $repotype = 'testing'; } else { if (strpos($repo['sub'], 'updates')) { $repotype = 'updates'; } else { $repotype = $repo['sub']; } } } switch ($repotype) { case "base": if (isset($rpms[$repo['main'] . "-updates"])) { $display .= sprintf("%s-%s<br/>", $rpm->ver, $rpm->rel); } else { $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm->ver, $rpm->rel); $class = $rpm->ver == $maxver ? "check" : "attn"; } break; case "": $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm->ver, $rpm->rel); break; case "updates": $display .= sprintf("<strong>%s</strong>-%s<br/><small>(%s)</small><br/>", $rpm->ver, $rpm->rel, $repo['sub']); $class = $rpm->ver == $maxver ? "check" : "attn"; break; case "testing": $display .= sprintf("%s-%s<br/><small>(%s)</small><br/>", $rpm->ver, $rpm->rel, $repo['sub']); $class = $rpm->ver == $maxver ? "info" : "attn"; break; } } // RPM exists } // sub repo $versions[] = array('class' => $class && $maxver ? $class : '', 'display' => $display); $package['versions'] = $versions; } // mainrepo $i++; $packages[] = $package; } } // each Line } return $packages; }
require "class/CommonTable.php"; date_default_timezone_set('Europe/Paris'); $db = new PDO("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); $pear = new TableRRepo($db); print_r($pear->getAllRepo()); echo "PEAR\n"; $pear = new TablePearRepo($db); print_r($pear->getAllRepo()); $pear = new TablePearRepo($db); print_r($pear->getAllRepo(false)); $a = $pear->add(array('alias' => 'test', 'url' => 'testurl')); echo "Ajout : {$a}\n"; $b = $pear->delete(array('id' => $a)); echo "Del : {$b}\n"; echo "RPM:"; $rpm = new TableRpmRepo($db); if ($rpm->update(999, array('stamp' => 1))) { echo "Update 1 ok\n"; } print_r($rpm->getAllRepo()); if ($rpm->update(999, array('stamp' => 2))) { echo "Update 2 ok\n"; } $all = $rpm->getAllRepo(); print_r(array_pop($all)); echo "find(devel):"; if ($row = $rpm->find(array('main' => 'devel'))) { print_r($row); } else { echo "not found\n"; }
* @category Main * @package RPMPHP * * @author Remi Collet <*****@*****.**> * @author Johan Cwiklinski <*****@*****.**> * @copyright 2010-2014 Remi Collet * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version * @link http://github.com/remicollet/rpmphp/ * @since The begining of times. */ require 'include/main.php'; $smarty->assign('ariane', $ariane); $smarty->assign('page_title', 'Packages in Fedora / RHEL / CentOS / EPEL repositories'); try { $db = new PDO("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); $repo = new TableRpmRepo($db); $prev = false; $repositories = array(); $crit = array('id' => '>0', 'ORDER' => 'id'); if (!isset($_GET['eol']) || !$_GET['eol']) { $crit['active'] = 1; } foreach ($repo->request($crit) as $repo) { $repositories[] = array('repo_name' => $repo['main'] != $prev ? $repo['main'] : " ", 'active' => $repo['main'] != $prev ? $repo['active'] ? "<strong>Yes</strong>" : "no" : " ", 'sub_name' => $repo['sub'], 'url' => $repo['url'], 'date' => $repo['stamp'] ? date("r", $repo['stamp']) : ''); $prev = $repo['main']; } $smarty->assign('repositories', $repositories); } catch (PDOException $e) { $smarty->assign('error', sprintf("%s ERREUR : %s\n", date("r"), $e->getMessage())); } $smarty->assign('rpmphp_version', RPMPHP_VERSION);
/** * Parse the content of all RPM repository for Provides * * @param TableRpm $rpmtable the table to write to * @param TableRpmRepo $rpmrepo the table to read from * @param Array $crit array for repo selection * * @return integer number of parsed line */ public static function readProvides(TablePackagist $pkgtable, TableRpmRepo $rpmrepo, array $crit) { $tot = 0; $result = array(); foreach ($rpmrepo->request($crit) as $row) { self::readOneProv($rpmrepo, $row, $result); } if (count($result)) { $pkgtable->truncate(); foreach ($result as $rpm => $pkg) { $input = array('rpmname' => $rpm, 'pkgname' => $pkg); try { if ($pkgtable->add($input)) { $tot++; } } catch (Exception $e) { # ignore duplicate key for now # ex pimple/pimple provided by php-pimple1 and php-pimple } } } self::log("Write {$tot} packagist packages"); return $tot; }