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"; } echo "find(rawhide):";
/** * Get the metadata of a RPM repository * * @param TableRpmRepo $rpmrepo the table to store timestamp * @param hastable $row the repo to read from * * @return simplexml */ private static function readMetadata(TableRpmRepo $rpmrepo, array $row) { self::log("REPOSITORY " . $row['main'] . " " . $row['sub']); $TimRemote = 0; $repomd = @simplexml_load_file($row['url'] . "repodata/repomd.xml"); if ($repomd) { foreach ($repomd->data as $data) { if ($data->attributes() == "primary") { $TimRemote = $data->timestamp; $UrlRemote = $row['url'] . $data->location->attributes(); } } } if (!$TimRemote) { self::log("Can't read {$UrlRemote}"); } else { if ($TimRemote > $row['stamp']) { self::log("Loading {$UrlRemote}"); $fic = gzopen($UrlRemote, "r"); if ($fic) { $txt = ""; while ($buf = gzread($fic, 8196)) { $txt .= $buf; } self::log("Read " . strlen($txt) . " bytes"); gzclose($fic); $primary = simplexml_load_string($txt); if ($primary) { self::log("Read " . $primary->attributes() . " packages"); $rpmrepo->update($row['id'], array('stamp' => $TimRemote)); return $primary; } else { self::log("ERROR : can't parse {$UrlRemote}"); } } else { self::log("ERROR : can't read {$UrlRemote}"); } } else { self::log("no update needed : {$TimRemote} / " . $row['stamp']); } } return NULL; }