summaryrefslogtreecommitdiffstats
path: root/class/Parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'class/Parser.php')
-rw-r--r--class/Parser.php70
1 files changed, 50 insertions, 20 deletions
diff --git a/class/Parser.php b/class/Parser.php
index 124b36e..bb5306f 100644
--- a/class/Parser.php
+++ b/class/Parser.php
@@ -186,23 +186,40 @@ class Parser
}
}
if (!$TimRemote) {
- self::log("Can't read $UrlRemote");
+ self::log("Can't read " . $row['url']);
} else if ($TimRemote > $row['stamp']) {
self::log("Loading $UrlRemote");
- $fic=gzopen($UrlRemote, "r");
- if ($fic) {
- $txt="";
- while ($buf=gzread($fic, 8196)) {
- $txt .= $buf;
+ $txt = file_get_contents($UrlRemote);
+ if (!$txt) {
+ self::log("ERROR : can't read $UrlRemote");
+ } else if (str_ends_with($UrlRemote, '.xml')) {
+ // OK
+ } else if (str_ends_with($UrlRemote, '.xz')) {
+ if (function_exists('xzdecode')) {
+ $txt = xzdecode($txt);
+ } else {
+ self::log("ERROR : missing xz php extension");
+ return NULL;
}
- self::log("Read " . strlen($txt) . " bytes");
- gzclose($fic);
-
+ } else if (str_ends_with($UrlRemote, '.zst')) {
+ if (function_exists('zstd_uncompress')) {
+ $txt = zstd_uncompress($txt);
+ } else {
+ self::log("ERROR : missing zstd php extension");
+ return NULL;
+ }
+ } else if (str_ends_with($UrlRemote, '.gz')) {
+ $txt = gzdecode($txt);
+ } else {
+ self::log("ERROR : unkown compression");
+ return NULL;
+ }
+ if ($txt) {
$primary = simplexml_load_string($txt);
if ($primary) {
- self::log("Read " . $primary->attributes() . " packages");
+ self::log("Read " . $primary->attributes() . " packages from primary");
$rpmrepo->update($row['id'], array('stamp' =>$TimRemote));
return $primary;
@@ -210,7 +227,7 @@ class Parser
self::log("ERROR : can't parse $UrlRemote");
}
} else {
- self::log("ERROR : can't read $UrlRemote");
+ self::log("ERROR : can't uncompress $UrlRemote");
}
} else {
self::log("no update needed : $TimRemote / " . $row['stamp']);
@@ -318,16 +335,21 @@ class Parser
// Parse the provides
foreach ($fmt as $fmt2) {
$prov = $fmt2->attributes()['name'];
- if (preg_match('/^php-composer\((.*)\)$/', $prov, $reg)) {
- list($vend, $proj) = explode('/', $reg[1], 2);
+ if (preg_match('/^php-(composer|pie)\((.*)\)$/', $prov, $reg)) {
+ $type = $reg[1];
+ $name = $reg[2];
+ if (!strpos($name, '/')) {
+ continue;
+ }
+ list($vend, $proj) = explode('/', $name, 2);
if ($vend == 'zendframework') {
if (!$composer) { // only if empty to keep laminas
- $composer = $reg[1];
+ $composer = $name;
}
} else if (substr($reg[1], 0, 4) != 'ext-'
- && substr($reg[1], -15) != '-implementation'
+ && substr($name, -15) != '-implementation'
&& !in_array($reg[1], $excl)) {
- $composer = $reg[1];
+ $composer = $name;
}
}
}
@@ -338,7 +360,7 @@ class Parser
}
}
}
- self::log("Read $tot packages");
+ self::log("Read $tot packages for provides");
}
return $tot;
}
@@ -494,12 +516,20 @@ class Parser
self::log("Packagist search releases");
$pk = new PackagistClient();
- $nb = $uptable->delete(array('type'=>'composer'));
+ $nb = $uptable->delete(['type'=>'composer']);
self::log("Delete $nb packages");
$tot = 0;
foreach($pktable->request(array('ORDER'=>'rpmname')) as $rec) {
- if ($rep = $pk->getPackage($rec['pkgname'])) {
+ if (preg_match('/[0-9]+$/', $rec['rpmname'], $reg)) {
+ // This already a versionned name
+ $crt = intval($reg[0]);
+ $max = $crt+1;
+ } else {
+ $crt = 0;
+ $max = 99999;
+ }
+ if ($rep = $pk->getPackage($rec['pkgname'], $crt, $max)) {
$v = explode('/', $rec['pkgname']);
switch(count($v)) {
case 3:
@@ -747,4 +777,4 @@ class Parser
}
}
-?> \ No newline at end of file
+?>