From a7b482ebad9b36ce8fa48fd18288868a29ed9521 Mon Sep 17 00:00:00 2001 From: Manuel Hiebel Date: Fri, 11 Nov 2022 21:50:41 +0100 Subject: Extends netinstall function to rename directly the good stuff --- lib/FIDD.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/FIDD.php b/lib/FIDD.php index 655c5e1..6add12a 100644 --- a/lib/FIDD.php +++ b/lib/FIDD.php @@ -23,7 +23,7 @@ class FIDD * * @return boolean */ - public static function run($app_path, $url, $prefix, $netinstall = false) + public static function run($app_path, $url, $prefix, $netinstall = false, $netinstall_rename = '') { $tmp_path = $app_path . '/var/tmp'; @@ -38,7 +38,7 @@ class FIDD if (!$netinstall) { $info = self::build_definitions($prefix, $tmp_path, $filesizes); } else { - $info = self::build_definitions_net_install($prefix, $tmp_path, $filesizes); + $info = self::build_definitions_net_install($prefix, $tmp_path, $filesizes, $netinstall_rename); } self::save_definitions($info, $app_path . '/var/definitions'); @@ -215,7 +215,7 @@ class FIDD * * @return array */ - function build_definitions_net_install($prefix, $dir, $filesizes) + function build_definitions_net_install($prefix, $dir, $filesizes, $netinstall_rename) { $info = array(); $isos = glob($dir . '/*/install/images/'); @@ -243,13 +243,25 @@ class FIDD 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; + if ($ret['version'] == 'Cauldron') + { + $rename = str_replace('Cauldron', $netinstall_rename, $data['file']); + $data['path'] = sprintf('%s/%s/install/images', + sprintf('distrib/cauldron%s', $prefix), + $ret['arch'] + ); + $data['name'] = str_replace(array('-', '.iso', 'i586', 'x86_64'), array(' ', '', '32bit', '64bit'), $rename); + $data['size'] = $filesizes[$data['file']]; + $info[$rename] = $data; + } else { + $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; } @@ -284,7 +296,7 @@ class FIDD */ public static function is_correct_name($s) { - $re = '/^(Mageia)-(\d+(.\d)?)(-(alpha|beta|RC|rc)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BR))?(-(build\_\w+))?\.(.*)$/'; + $re = '/^(Mageia)-(\d+(.\d)?|Cauldron)(-(alpha|beta|RC|rc)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BR))?(-(build\_\w+))?\.(.*)$/'; if (preg_match($re, $s, $arr)) { $ret = array( 'name' => $arr[1], -- cgit v1.2.1