mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	Find correct template and postinstall file to build osimage for copycds -n command (#5300)
* Parse copycd -n options to get correct tmpl and postinstall file * Add support for Ubuntu
This commit is contained in:
		| @@ -452,37 +452,59 @@ sub get_file_name { | ||||
|     #usally there're only 4 arguments passed for this function | ||||
|     #the $genos is only used for the Redhat family | ||||
|  | ||||
|     my $dotpos = rindex($os, "."); | ||||
|     my $osbase = substr($os, 0, $dotpos); | ||||
|  | ||||
|     #handle the following ostypes: sles10.2, sles11.1, rhels5.3, rhels5.4, etc | ||||
|  | ||||
|     if (-r "$searchpath/$profile.$os.$arch.$extension") { | ||||
|         return "$searchpath/$profile.$os.$arch.$extension"; | ||||
|     } | ||||
|     elsif (-r "$searchpath/$profile.$os.$extension") { | ||||
|     if (-r "$searchpath/$profile.$os.$extension") { | ||||
|         return "$searchpath/$profile.$os.$extension"; | ||||
|     } | ||||
|     elsif (($genos) && (-r "$searchpath/$profile.$genos.$arch.$extension")) { | ||||
|     if (($genos) && (-r "$searchpath/$profile.$genos.$arch.$extension")) { | ||||
|         return "$searchpath/$profile.$genos.$arch.$extension"; | ||||
|     } | ||||
|     elsif (($genos) && (-r "$searchpath/$profile.$genos.$extension")) { | ||||
|     if (($genos) && (-r "$searchpath/$profile.$genos.$extension")) { | ||||
|         return "$searchpath/$profile.$genos.$extension"; | ||||
|     } | ||||
|  | ||||
|     my $dotpos = rindex($os, "."); | ||||
|     my $osbase = substr($os, 0, $dotpos); | ||||
|     # If the osimge name was specified with -n, the name might contain multiple "." | ||||
|     # Chop them off one at a time until filename match is found | ||||
|     else { | ||||
|         while ($dotpos > 0) { | ||||
|     while ($dotpos > 0) { | ||||
|         if (-r "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-r "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|         # Chop off "." from the end and try again | ||||
|         $dotpos = rindex($osbase, "."); | ||||
|         $osbase = substr($osbase, 0, $dotpos); | ||||
|     } | ||||
|  | ||||
|             if (-r "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|                 return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|             } | ||||
|             elsif (-r "$searchpath/$profile.$osbase.$extension") { | ||||
|                 return "$searchpath/$profile.$osbase.$extension"; | ||||
|             } | ||||
|             # Chop off "." from the end and try again | ||||
|             $dotpos = rindex($osbase, "."); | ||||
|             $osbase = substr($osbase, 0, $dotpos); | ||||
|     #if there are no '.', pick the two numbers follow by leading string, like sles11 | ||||
|     #then pick one number follow by leading string, like centos7, rhels7 | ||||
|     if ($os =~ m/([a-zA-Z]+\d\d)/) | ||||
|     { | ||||
|         $osbase=$1; | ||||
|         if (-r "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-r "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if ($os =~ m/([a-zA-Z]+\d)/) | ||||
|     { | ||||
|         $osbase = $1; | ||||
|         if (-r "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-r "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -490,12 +512,11 @@ sub get_file_name { | ||||
|     if (-r "$searchpath/$profile.$arch.$extension") { | ||||
|         return "$searchpath/$profile.$arch.$extension"; | ||||
|     } | ||||
|     elsif (-r "$searchpath/$profile.$extension") { | ||||
|     if (-r "$searchpath/$profile.$extension") { | ||||
|         return "$searchpath/$profile.$extension"; | ||||
|     } | ||||
|     else { | ||||
|         return undef; | ||||
|     } | ||||
|  | ||||
|     return undef; | ||||
| } | ||||
|  | ||||
| sub get_tmpl_file_name { | ||||
| @@ -541,24 +562,60 @@ sub get_postinstall_file_name { | ||||
|     if (-x "$searchpath/$profile.$os.$arch.$extension") { | ||||
|         return "$searchpath/$profile.$os.$arch.$extension"; | ||||
|     } | ||||
|     elsif (-x "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|     if (-x "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|         return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|     } | ||||
|     elsif (-x "$searchpath/$profile.$os.$extension") { | ||||
|     if (-x "$searchpath/$profile.$os.$extension") { | ||||
|         return "$searchpath/$profile.$os.$extension"; | ||||
|     } | ||||
|     elsif (-x "$searchpath/$profile.$osbase.$extension") { | ||||
|     if (-x "$searchpath/$profile.$osbase.$extension") { | ||||
|         return "$searchpath/$profile.$osbase.$extension"; | ||||
|     } | ||||
|     elsif (-x "$searchpath/$profile.$arch.$extension") { | ||||
|     # If the osimge name was specified with -n, the name might contain multiple "." | ||||
|     # Chop them off one at a time until filename match is found | ||||
|     while ($dotpos > 0) { | ||||
|         if (-x "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-x "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|         # Chop off "." from the end and try again | ||||
|         $dotpos = rindex($osbase, "."); | ||||
|         $osbase = substr($osbase, 0, $dotpos); | ||||
|     } | ||||
|  | ||||
|     #if there are no '.', pick the two numbers follow by leading string, like sles11 | ||||
|     #then pick one number follow by leading string, like centos7, rhels7 | ||||
|     if ($os =~ m/([a-zA-Z]+\d\d)/) | ||||
|     { | ||||
|         $osbase=$1; | ||||
|         if (-x "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-x "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if ($os =~ m/([a-zA-Z]+\d)/) | ||||
|     { | ||||
|         $osbase = $1; | ||||
|         if (-x "$searchpath/$profile.$osbase.$arch.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$arch.$extension"; | ||||
|         } | ||||
|         if (-x "$searchpath/$profile.$osbase.$extension") { | ||||
|             return "$searchpath/$profile.$osbase.$extension"; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (-x "$searchpath/$profile.$arch.$extension") { | ||||
|         return "$searchpath/$profile.$arch.$extension"; | ||||
|     } | ||||
|     elsif (-x "$searchpath/$profile.$extension") { | ||||
|     if (-x "$searchpath/$profile.$extension") { | ||||
|         return "$searchpath/$profile.$extension"; | ||||
|     } | ||||
|     else { | ||||
|         return undef; | ||||
|     } | ||||
|     return undef; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user