summaryrefslogtreecommitdiffstats
path: root/refresh.php
diff options
context:
space:
mode:
Diffstat (limited to 'refresh.php')
-rw-r--r--refresh.php77
1 files changed, 1 insertions, 76 deletions
diff --git a/refresh.php b/refresh.php
index aa4d486..9603c78 100644
--- a/refresh.php
+++ b/refresh.php
@@ -70,83 +70,8 @@ try {
} else {
$crit = array('active' => 1);
}
- $rpmrepo = new TableRpmRepo($db);
- $rpmtable = new TableRpm($db);
-
- foreach ($rpmrepo->request($crit) as $row) {
- echo date("r : ") . "REPOSITORY " . $row['main'] . " " .
- $row['sub'] . "\n";
- $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) {
- echo date("r : ") . "Can't read $UrlRemote\n";
-
- } else if ($TimRemote > $row['stamp']) {
- echo date("r : ") . "Loading $UrlRemote\n";
-
- //$fic=gzopen("primary.xml.gz", "r");
- $fic=gzopen($UrlRemote, "r");
- if ($fic) {
- $txt="";
- while ($buf=gzread($fic, 8196)) {
- $txt .= $buf;
- }
- echo date("r : ") . "Read " . strlen($txt) . " bytes\n";
- gzclose($fic);
-
- $primary = simplexml_load_string($txt);
- echo date("r : ") . "Read " . $primary->attributes() .
- " packages\n";
- unset($txt);
-
- $crit = array(
- 'repo_main' => $row['main'],
- 'repo_sub' => $row['sub']
- );
- $nb = $rpmtable->delete($crit);
- echo date("r : ") . "Delete $nb packages\n";
-
- $tot=0;
- foreach ($primary->package as $package) {
- if ($package->attributes()=='rpm') {
- $ver = $package->version->attributes();
-
- $input = array(
- 'repo_main' => $row['main'],
- 'repo_sub' => $row['sub'],
- 'name' => $package->name,
- 'epoch' => $ver['epoch'],
- 'ver' => $ver['ver'],
- 'rel' => $ver['rel'],
- 'summary' => $package->summary,
- 'url' => $package->url
- );
- if ($rpmtable->add($input)) {
- $tot++;
- }
- }
- }
- echo date("r : ") . "Write $tot packages\n";
-
- $rpmrepo->update($row['id'], array('stamp' =>$TimRemote));
- unset($primary);
- } else {
- echo date("r : ") . "ERROR : can't read $UrlRemote\n";
- }
- } else {
- echo date("r : ") . "no update needed : $TimRemote / " .
- $row['stamp'] . "\n";
- }
- }
+ Parser::readRpm(new TableRpm($db), new TableRpmRepo($db), $crit);
} // If ask
// -------------------------------------------------------------------