summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-11-01 11:02:02 +0100
committerRemi Collet <fedora@famillecollet.com>2010-11-01 11:02:02 +0100
commit8b50ace3024268b3067c0bf43bbd68f824b90d81 (patch)
tree80bca053cfe2c5cde53faf4b4fa8da33fb203f16
parentdce8f805bb2d7b46e51449086e35cb0b2af37daf (diff)
use Parser::readPear() - end of work for refresh
-rw-r--r--class/Parser.php203
-rw-r--r--refresh.php197
2 files changed, 210 insertions, 190 deletions
diff --git a/class/Parser.php b/class/Parser.php
index 3113718..ef4a751 100644
--- a/class/Parser.php
+++ b/class/Parser.php
@@ -363,5 +363,208 @@ class Parser
}
return $nb;
}
+
+ /**
+ * Parse the content of all PEAR repository
+ *
+ * @param TableUpstream $uptable the table to write to
+ * @param string $channelname the channel name
+ * @param string $channelurl the channel URL
+ *
+ * @return integer number of parsed line
+ */
+ static public function readOnePear(TableUpstream $uptable, $channelname, $channelurl)
+ {
+ $channel = @simplexml_load_file("http://$channelurl/channel.xml");
+ if (!$channel) {
+ self::log("can't read PEAR site (channel of $channelname)");
+ return 0;
+ }
+
+ $rest = $channel->servers->primary->rest->baseurl[0];
+ self::log("PEAR reading channel=$channelname, baseurl = $rest");
+
+ $categories = @simplexml_load_file($rest."c/categories.xml");
+ if (!$categories) {
+ self::log("can't read PEAR site (categories)");
+ return 0;
+ }
+
+ $crit = array('type'=>'pear', 'channel'=>$channelname);
+ $nb = $uptable->delete($crit);
+ self::log("Delete $nb packages");
+
+ $nb=0;
+ if (!isset($categories->c[0])) {
+ self::log("Reading ALL"); // ezc only
+ $pitxt = @file_get_contents($rest."p/packages.xml");
+ if (!$pitxt) {
+ self::log("can't read PEAR site (".$rest."p/packagesinfo.xml)");
+ return 0;
+ }
+ $allpi = @simplexml_load_string($pitxt);
+ foreach ($allpi->p as $name) {
+ $pitxt = @file_get_contents(
+ $rest."r/".strtolower($name)."/allreleases.xml"
+ );
+ if (!$pitxt) {
+ self::log(
+ "can't read PEAR site (".$rest."r/".
+ strtolower($name)."/allreleases.xml"
+ );
+ continue;
+ }
+ $pi = @simplexml_load_string($pitxt);
+
+ $rpmname1="php-".$channelname."-".
+ str_replace("_", "-", $name);
+ $rpmname2="php-".$channelname."-".$name;
+
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname1,
+ (string)$pi->r[0]->v,
+ false,
+ (string)$pi->r[0]->s
+ );
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname2,
+ (string)$pi->r[0]->v,
+ false,
+ (string)$pi->r[0]->s
+ );
+ foreach ($pi->r as $rev) {
+ if ($rev->s=='stable') {
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname1,
+ (string)$rev->v,
+ true
+ );
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname2,
+ (string)$rev->v,
+ true
+ );
+ break;
+ }
+ }
+ $nb++;
+ }
+
+ } else {
+ foreach ($categories->c as $cat) {
+ self::log("Reading $cat");
+
+ $pitxt = @file_get_contents(
+ $rest."c/".urlencode($cat)."/packagesinfo.xml"
+ );
+ if (!$pitxt) {
+ self::log(
+ "can't read PEAR site (".$rest."c/".
+ urlencode($cat)."/packagesinfo.xml)"
+ );
+ continue;
+ }
+ $pitxt = "<?" . preg_replace(
+ "/<\?xml.*?>/U",
+ "",
+ str_replace("\r\n", "\n", substr($pitxt, 2))
+ );
+
+ $pi = @simplexml_load_string($pitxt);
+ if (!$pi) {
+ self::log("can't read response ($cat)");
+ continue;
+ }
+ foreach ($pi->pi as $ps) {
+ if (isset($ps->p->n) && isset($ps->a->r)) {
+ $name=(string)$ps->p->n;
+
+ if ($channelname=='phing' && $name=='phing') {
+ $rpmname1="php-pear-phing";
+ } else if ($channelname=='phpunit'
+ && $name=='PHPUnit'
+ ) {
+ $rpmname1="php-pear-PHPUnit";
+ } else {
+ $rpmname1="php-".$channelname."-".
+ str_replace("_", "-", $name);
+ }
+ $rpmname2="php-".$channelname."-".$name;
+
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname1,
+ (string)$ps->a->r[0]->v,
+ false,
+ (string)$ps->a->r[0]->s
+ );
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname2,
+ (string)$ps->a->r[0]->v,
+ false,
+ (string)$ps->a->r[0]->s
+ );
+ foreach ($ps->a->r as $rev) {
+ if ($rev->s=='stable') {
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname1,
+ (string)$rev->v,
+ true
+ );
+ $uptable->record(
+ "pear",
+ $channelname,
+ $rpmname2,
+ (string)$rev->v,
+ true
+ );
+ break;
+ }
+ }
+ $nb++;
+ }
+ }
+ }
+ }
+ self::log("read $nb packages in $channelname");
+ return $nb;
+
+ }
+ /**
+ * Parse the content of all PEAR repository
+ *
+ * @param TableUpstream $uptable the table to write to
+ * @param TablePearRepo $pear the table to read from
+ *
+ * @return integer number of parsed line
+ */
+ static public function readPear(TableUpstream $uptable, TablePearRepo $pear)
+ {
+ $tot = 0;
+
+ self::log("PEAR reading channels");
+
+ $channels = $pear->getAllRepo(true);
+ foreach ($channels as $channelname => $channelurl) {
+ $tot += self::readOnePear($uptable, $channelname, $channelurl);
+ }
+
+ self::log("Write $tot packages in all channels");
+ return $tot;
+ }
+
}
?> \ No newline at end of file
diff --git a/refresh.php b/refresh.php
index 14b0020..6c7827b 100644
--- a/refresh.php
+++ b/refresh.php
@@ -63,6 +63,7 @@ try {
echo date("r : ") . "Refreshing " . MYBASE . " database\n";
if ($_SERVER['argc']==1 || in_array('repo', $_SERVER['argv'])) {
+
if (in_array('empty', $_SERVER['argv'])) {
$crit = array('stamp' => null);
} else if (in_array('old', $_SERVER['argv'])) {
@@ -72,7 +73,7 @@ try {
}
Parser::readRpm(new TableRpm($db), new TableRpmRepo($db), $crit);
- } // If ask
+ }
// -------------------------------------------------------------------
// Upstream Version
@@ -83,202 +84,19 @@ try {
if ($_SERVER['argc']==1 || in_array('pecl', $_SERVER['argv'])) {
Parser::readPecl($uptable, 'http://pecl.php.net/xmlrpc.php');
-
- } // if in options
+ }
// -------------------------------------------------------------------
if ($_SERVER['argc']==1 || in_array('pear', $_SERVER['argv'])) {
- echo date("r : ") . "PEAR reading channels\n";
- $pear = new TablePearRepo($db);
- $channels = $pear->getAllRepo(true);
- try {
- $nbtot=0;
-
- foreach ($channels as $channelname => $channelurl) {
- $channel = @simplexml_load_file("http://$channelurl/channel.xml");
- if (!$channel) {
- throw new Exception(
- "can't read PEAR site (channel of $channelname)"
- );
- }
-
- $rest = $channel->servers->primary->rest->baseurl[0];
- echo date("r : ") . "PEAR reading channel=$channelname" .
- ", baseurl = $rest\n";
-
- $categories = @simplexml_load_file($rest."c/categories.xml");
- if (!$categories) {
- throw new Exception("can't read PEAR site (categories)");
- }
-
- $crit = array('type'=>'pear', 'channel'=>$channelname);
- $nb = $uptable->delete($crit);
- echo date("r : ") . "Delete $nb packages\n";
-
- $nb=0;
- if (!isset($categories->c[0])) {
- echo date("r : ") . "Reading ALL\n"; // ezc only
- $pitxt = @file_get_contents($rest."p/packages.xml");
- if (!$pitxt) {
- throw new Exception(
- "can't read PEAR site (".$rest."p/packagesinfo.xml)"
- );
- }
- $allpi = @simplexml_load_string($pitxt);
- foreach ($allpi->p as $name) {
- $pitxt = @file_get_contents(
- $rest."r/".strtolower($name)."/allreleases.xml"
- );
- if (!$pitxt) {
- throw new Exception(
- "can't read PEAR site (".$rest."r/".
- strtolower($name)."/allreleases.xml"
- );
- }
- $pi = @simplexml_load_string($pitxt);
-
- $rpmname1="php-".$channelname."-".
- str_replace("_", "-", $name);
- $rpmname2="php-".$channelname."-".$name;
-
- //echo $rpmname ."/".(string)$pi->r[0]->v."/".
- // (string)$pi->r[0]->s."\n";
- $uptable->record(
- "pear",
- $channelname,
- $rpmname1,
- (string)$pi->r[0]->v,
- false,
- (string)$pi->r[0]->s
- );
- $uptable->record(
- "pear",
- $channelname,
- $rpmname2,
- (string)$pi->r[0]->v,
- false,
- (string)$pi->r[0]->s
- );
- foreach ($pi->r as $rev) {
- if ($rev->s=='stable') {
- //echo $rpmname ."/".(string)$rev->v."/".
- // (string)$rev->s."\n";
- $uptable->record(
- "pear",
- $channelname,
- $rpmname1,
- (string)$rev->v,
- true
- );
- $uptable->record(
- "pear",
- $channelname,
- $rpmname2,
- (string)$rev->v,
- true
- );
- break;
- }
- }
- $nb++;
- }
- } else {
- foreach ($categories->c as $cat) {
- echo date("r : ") . "Reading $cat\n";
-
- $pitxt = @file_get_contents(
- $rest."c/".urlencode($cat)."/packagesinfo.xml"
- );
- if (!$pitxt) {
- throw new Exception(
- "can't read PEAR site (".$rest."c/".
- urlencode($cat)."/packagesinfo.xml)"
- );
- }
- $pitxt = "<?" . preg_replace(
- "/<\?xml.*?>/U",
- "",
- str_replace("\r\n", "\n", substr($pitxt, 2))
- );
-
- $pi = @simplexml_load_string($pitxt);
- if (!$pi) {
- throw new Exception("can't read response ($cat)");
- }
- foreach ($pi->pi as $ps) {
- if (isset($ps->p->n) && isset($ps->a->r)) {
- $name=(string)$ps->p->n;
-
- if ($channelname=='phing' && $name=='phing') {
- $rpmname1="php-pear-phing";
- } else if ($channelname=='phpunit'
- && $name=='PHPUnit'
- ) {
- $rpmname1="php-pear-PHPUnit";
- } else {
- $rpmname1="php-".$channelname."-".
- str_replace("_", "-", $name);
- }
- $rpmname2="php-".$channelname."-".$name;
-
- $uptable->record(
- "pear",
- $channelname,
- $rpmname1,
- (string)$ps->a->r[0]->v,
- false,
- (string)$ps->a->r[0]->s
- );
- $uptable->record(
- "pear",
- $channelname,
- $rpmname2,
- (string)$ps->a->r[0]->v,
- false,
- (string)$ps->a->r[0]->s
- );
- foreach ($ps->a->r as $rev) {
- if ($rev->s=='stable') {
- $uptable->record(
- "pear",
- $channelname,
- $rpmname1,
- (string)$rev->v,
- true
- );
- $uptable->record(
- "pear",
- $channelname,
- $rpmname2,
- (string)$rev->v,
- true
- );
- break;
- }
- }
- $nb++;
- // echo $ps->p->n."\n";
- }
- }
- }
- }
- echo date("r : ") . "read $nb packages in $channelname\n";
- $nbtot += $nb;
- }
- echo date("r : ") . "read $nbtot packages in all channels\n";
-
- } catch (Exception $e) {
- echo date("r : ") . 'ERROR ' . $e->getMessage(), "\n";
- }
- } // if in options
+ Parser::readPear($uptable, new TablePearRepo($db));
+ }
// -------------------------------------------------------------------
if ($_SERVER['argc']==1 || in_array('R', $_SERVER['argv'])) {
Parser::readR($uptable, new TableRRepo($db));
-
- } // If R in options
+ }
// -------------------------------------------------------------------
// Package Owners from pkgdb (thanks Smootherfrog)
@@ -287,8 +105,7 @@ try {
$url = "https://admin.fedoraproject.org/pkgdb/lists/bugzilla?tg_format=plain";
Parser::readAcls(new TableAcls($db), $url);
-
- } // If in options
+ }
} catch(PDOException $e) {
printf("%s ERREUR : %s\n", date("r"), $e->getMessage());