diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-11-01 10:25:14 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-11-01 10:25:14 +0100 |
commit | da00c9df1bf03fe3989c9cc34f0007f285a1ad5e (patch) | |
tree | e850f00ef07ae5fff9f078e3f481d664669192d4 /refresh.php | |
parent | 93c01077b80cc8d6044d1ec82e981c9f2b26f362 (diff) |
use Parser::readRpm()
Diffstat (limited to 'refresh.php')
-rw-r--r-- | refresh.php | 77 |
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 // ------------------------------------------------------------------- |