dumpQueue(); exit(0); } /* --dump-all */ if ($dump_all) { $db->dump(); exit(0); } /* --refresh, need to wrap it all with ifs maybe*/ echo "Refreshing the data" . PHP_EOL; $rss = 'https://pecl.php.net/feeds/latest.rss'; echo "Fetching $rss" . PHP_EOL; $latest = simplexml_load_file($rss); if (!isset($latest->item)) { echo "No items could be found in $rss" . PHP_EOL; } /* FIXME Use a separate config for this! */ $curl = 'C:\apps\bin\curl.exe'; $get_url_tpl = 'https://pecl.php.net/get/{name}/{version}'; $download_dir = 'c:\php-snap-build\in-pkg\release'; $download_dir_pre = 'c:\php-snap-build\in-pkg\snap-pre'; foreach($latest->item as $item) { if (!$item->title) { continue; } $tmp = explode(' ', (string)$item->title); $name = $tmp[0]; $version = $tmp[1]; if (!$name || !$version) { continue; } if (!$no_fetch) { $get_url = str_replace( array('{name}', '{version}'), array($name, $version), $get_url_tpl ); /* XXX -k is needed as the host is good known, but the download can fail on certain versions because of certs */ $curl_cmd = $curl . ' -s -L -J -O -k ' . $get_url; $back = getcwd(); chdir($download_dir); $suspects = glob(strtolower($name) . "-" . strtolower($version) . "*"); if ($force_fetch) { if ($db->exists($name, $version)) { echo "<$name-$version> forcing download" . PHP_EOL; } foreach ($suspects as $f) { if (file_exists($f)) { unlink($f); } } } else if ($db->done($name, $version)) { echo "<$name-$version> is already done" . PHP_EOL; continue; } else if ($db->exists($name, $version)) { /* XXX no check if file exists here, but should be */ echo "<$name-$version> is already in the queue" . PHP_EOL; continue; } if (!$suspects) { system($curl_cmd, $status); if ($enable_pre) { copy("$name-$version.tgz", "$download_dir_pre" . DIRECTORY_SEPARATOR . "$name-$version.tgz"); } if ($status) { echo "<$name-$version> download failed" . PHP_EOL; chdir($back); continue; } } chdir($back); } if (!$db->exists($name, $version) && $db->add($name, $version, $force_fetch)) { echo "<$name-$version> added to the queue" . PHP_EOL; } /* * when need more, look here (or /r) using name and version * $url = 'https://pecl.php.net/rest/p/'; */ } exit(0);