aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fidd.php9
-rw-r--r--lib/FIDD.php110
2 files changed, 90 insertions, 29 deletions
diff --git a/fidd.php b/fidd.php
index 3a5f741..62ad91d 100644
--- a/fidd.php
+++ b/fidd.php
@@ -13,18 +13,21 @@
// params
-$prefix = '/mageia8-alpha1';
-$bcd_path = 'cauldron/mageia8-alpha1';
+$prefix = '';
+$bcd_path = '8';
-#$bcd_url = 'rsync://isoqa@bcd.mageia.org/isos/%s/';
+//$bcd_url = 'rsync://isoqa@bcd.mageia.org/isos/%s/';
$bcd_url = 'rsync://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/iso/%s/';
+$netinstall = 'rsync://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/8/';
+
// don't touch below
$ts0 = microtime(true);
require_once __DIR__ . '/lib/FIDD.php';
+FIDD::run(__DIR__, $netinstall, $prefix, true);
FIDD::run(__DIR__, sprintf($bcd_url, $bcd_path), $prefix);
echo sprintf("done in %2.2f s.\n", microtime(true) - $ts0);
diff --git a/lib/FIDD.php b/lib/FIDD.php
index f26f604..655c5e1 100644
--- a/lib/FIDD.php
+++ b/lib/FIDD.php
@@ -23,24 +23,25 @@ class FIDD
*
* @return boolean
*/
- public static function run($app_path, $url, $prefix)
+ public static function run($app_path, $url, $prefix, $netinstall = false)
{
$tmp_path = $app_path . '/var/tmp';
-
+
echo sprintf("rsync'ing bcd.mageia.org files from %s...\n", $url);
- if (self::rsync_mirror_files($url, $tmp_path)) {
+ if (self::rsync_mirror_files($url, $tmp_path, $netinstall)) {
echo "Failed to rsync remote ISOs...\n";
return false;
}
-
echo "fetching ISOs filesize...\n";
- $filesizes = self::rsync_get_filesizes($url);
-
+ $filesizes = self::rsync_get_filesizes($url, $netinstall);
echo "building definition file...\n";
- $info = self::build_definitions($prefix, $tmp_path, $filesizes);
-
+ if (!$netinstall) {
+ $info = self::build_definitions($prefix, $tmp_path, $filesizes);
+ } else {
+ $info = self::build_definitions_net_install($prefix, $tmp_path, $filesizes);
+ }
self::save_definitions($info, $app_path . '/var/definitions');
-
+
return true;
}
@@ -80,14 +81,18 @@ class FIDD
* @param string $url
* @param string $dir where to mirror files
*/
- private static function rsync_mirror_files($url, $dir)
+ private static function rsync_mirror_files($url, $dir, $netinstall = false)
{
+ if (!$netinstall){
$cmd = sprintf('/usr/bin/rsync -avHP --exclude=*.iso %s %s',
escapeshellarg($url),
escapeshellarg($dir));
-
+ } else {
+ $cmd = sprintf('/usr/bin/rsync -avHP --exclude=*.iso --exclude=*.img --include=i586 --include=x86_64 --include=*/install --include=*/install/images --include=*/install/images/* --exclude=* %s %s',
+ escapeshellarg($url),
+ escapeshellarg($dir));
+ }
exec($cmd, $out, $ret);
-
return $ret;
}
@@ -98,13 +103,16 @@ class FIDD
*
* @return array ["file.iso" => "size", ...]
*/
- private static function rsync_get_filesizes($url)
+ private static function rsync_get_filesizes($url, $netinstall = false)
{
- $cmd = sprintf('/usr/bin/rsync -a --list-only --no-h %s | awk \'{print $2"\t"$5}\'',
+ if (!$netinstall){
+ $cmd = sprintf('/usr/bin/rsync -a --list-only --no-h %s | awk \'{print $2"\t"$5}\'',
escapeshellarg($url));
-
+ }else{
+ $cmd = sprintf('/usr/bin/rsync -a --list-only --include=i586 --include=x86_64 --include=*/install --include=*/install/images --include=*/install/images/* --exclude=* --no-h %s | awk \'{print $2"\t"$5}\'',
+ escapeshellarg($url));
+ }
$isos = array();
-
exec($cmd, $out, $ret);
if ($ret === 0) {
foreach ($out as $line) {
@@ -112,12 +120,15 @@ class FIDD
if (count($line) > 1) {
if (trim(substr($line[1], -3, 3)) == 'iso') {
$file = explode('/', $line[1]);
- $isos[$file[1]] = formatBytes($line[0], 1);
+ if (!$netinstall) {
+ $isos[$file[1]] = formatBytes($line[0], 1);
+ } else {
+ $isos[$file[3]] = formatBytes($line[0], 1);
+ }
}
}
}
}
-
return $isos;
}
@@ -134,17 +145,13 @@ class FIDD
{
$info = array();
$isos = glob($dir . '/*');
-
+
foreach ($isos as $isodir) {
-
$data = array();
$files = glob($isodir . '/*.*');
-
foreach ($files as $f) {
-
$fi = pathinfo($f);
$ext = $fi['extension'];
-
switch ($fi['extension'])
{
case 'md5':
@@ -169,8 +176,6 @@ class FIDD
}
}
-
-
if ( count($data) == 0) {
// skip the first one
} else if (null !== ($ret = self::is_correct_name($data['file']))) {
@@ -202,6 +207,59 @@ class FIDD
}
/**
+ * Parse mirrors files in $dir and build a catalog of these.
+ *
+ * @param string $prefix
+ * @param string $dir where to look for files
+ * @param array $filesizes sizes of each .iso file
+ *
+ * @return array
+ */
+ function build_definitions_net_install($prefix, $dir, $filesizes)
+ {
+ $info = array();
+ $isos = glob($dir . '/*/install/images/');
+
+ foreach ($isos as $isodir) {
+ $data = array();
+ $files = glob($isodir . '/*.iso*');
+ foreach ($files as $f){
+ $fi = pathinfo($f);
+ $ext = $fi['extension'];
+ switch ($fi['extension'])
+ {
+ case 'md5':
+ $key = str_replace('.iso.md5', '.iso', basename($f));
+ $data['file'] = $key;
+ $data['md5'] = self::get_checksum_value($f);
+ break;
+ case 'sha3':
+ $data['sha3'] = self::get_checksum_value($f);
+ break;
+ case 'sha512':
+ $data['sha512'] = self::get_checksum_value($f);
+ break;
+ }
+ if ( count($data) == 0) {
+ // skip the first one
+ } else if (null !== ($ret = self::is_correct_name($data['file']))) {
+ $data['path'] = sprintf('%s/%s/install/images',
+ $ret['release'] == '' ? sprintf('distrib/%s', $ret['version']) : sprintf('distrib/cauldron%s', $prefix),
+ $ret['arch']
+ );
+ $data['name'] = str_replace(array('-', '.iso', 'i586', 'x86_64'), array(' ', '', '32bit', '64bit'), $data['file']);
+ $data['size'] = $filesizes[$data['file']];
+ $info[$data['file']] = $data;
+ } else {
+ $info['invalid'][] = $data;
+ }
+ }
+ }
+
+ return $info;
+ }
+
+ /**
* Extract checksum from .md5 or .sha1 file.
*
* @param string $f
@@ -233,7 +291,7 @@ class FIDD
'version' => $arr[2],
'release' => $arr[4] . $arr[5],
'variant' => $arr[7],
- 'arch' => $arr[8],
+ 'arch' => $arr[9],
'medium' => $arr[10],
'build' => $arr[12],
'ext' => $arr[13]