mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-30 19:02:27 +00:00 
			
		
		
		
	for defect 3012545,
"netboot/imgutils/imgutils.pm" is created to hold all the functions used in different "genimage" commands; git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6683 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -5,12 +5,17 @@ BEGIN | ||||
| } | ||||
| use lib "$::XCATROOT/lib/perl"; | ||||
|  | ||||
| use lib "../imgutils"; | ||||
|  | ||||
| use File::Basename; | ||||
| use File::Path; | ||||
| use File::Copy; | ||||
| use File::Find; | ||||
| use Getopt::Long; | ||||
| use Cwd qw(realpath); | ||||
|  | ||||
| use imgutils; | ||||
|  | ||||
| #use strict; | ||||
| Getopt::Long::Configure("bundling"); | ||||
| Getopt::Long::Configure("pass_through"); | ||||
| @@ -229,9 +234,9 @@ unless ($onlyinitrd) { | ||||
|    mkpath("$rootimg_dir/var/lib/yum"); | ||||
|  | ||||
|    if (!$imagename) { | ||||
|        $pkglist= get_profile_def_filename($customdir, "pkglist"); | ||||
|        $pkglist= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); | ||||
|        if (!$pkglist) { | ||||
| 	   $pkglist= get_profile_def_filename($pathtofiles, "pkglist"); | ||||
| 	   $pkglist= imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); | ||||
|        }   | ||||
|    } | ||||
|  | ||||
| @@ -261,8 +266,8 @@ unless ($onlyinitrd) { | ||||
|  | ||||
|    #Now let's handle extra packages | ||||
|     if (!$imagename) { | ||||
| 	$otherpkglist=get_profile_def_filename($customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_profile_def_filename($pathtofiles, "otherpkgs.pkglist"); } | ||||
| 	$otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } | ||||
|     } | ||||
|     my %extra_hash=(); | ||||
|     if ($otherpkglist) { | ||||
| @@ -395,9 +400,9 @@ unlink "/tmp/genimage.$$.yum.conf"; | ||||
|  | ||||
| #-- run postinstall script | ||||
| if (!$imagename) { | ||||
|     $postinstall_filename= get_profile_def_filename($customdir, "postinstall"); | ||||
|     $postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); | ||||
|     if (!$postinstall_filename) { | ||||
| 	$postinstall_filename= get_profile_def_filename($pathtofiles, "postinstall"); | ||||
| 	$postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); | ||||
|     } | ||||
| }  | ||||
|  | ||||
| @@ -1195,28 +1200,3 @@ sub include_file | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| sub get_profile_def_filename { | ||||
|    my $base=shift; | ||||
|    my $ext=shift; | ||||
|    my $dotpos = rindex($osver, "."); | ||||
|    my $osbase = substr($osver, 0, $dotpos); | ||||
|    if (-r "$base/$profile.$osver.$arch.$ext") { | ||||
|       return "$base/$profile.$osver.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$arch.$ext") { | ||||
|       return "$base/$profile.$osbase.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$arch.$ext") { | ||||
|       return "$base/$profile.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osver.$ext") { | ||||
|       return "$base/$profile.$osver.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$ext") { | ||||
|       return "$base/$profile.$osbase.$ext"; | ||||
|    } elsif (-r "$base/$profile.$ext") { | ||||
|       return "$base/$profile.$ext"; | ||||
|    }  | ||||
|  | ||||
|    return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
| 	 | ||||
|   | ||||
							
								
								
									
										35
									
								
								xCAT-server/share/xcat/netboot/imgutils/imgutils.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								xCAT-server/share/xcat/netboot/imgutils/imgutils.pm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| #!/usr/bin/perl -w | ||||
| # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
| # #(C)IBM Corp | ||||
| package imgutils; | ||||
|  | ||||
| use strict; | ||||
| use warnings "all"; | ||||
|  | ||||
| sub get_profile_def_filename { | ||||
|    my $osver = shift; | ||||
|    my $profile = shift; | ||||
|    my $arch = shift; | ||||
|     | ||||
|    my $base=shift; | ||||
|    my $ext=shift; | ||||
|    my $dotpos = rindex($osver, "."); | ||||
|    my $osbase = substr($osver, 0, $dotpos); | ||||
|    if (-r "$base/$profile.$osver.$arch.$ext") { | ||||
|       return "$base/$profile.$osver.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$arch.$ext") { | ||||
|       return "$base/$profile.$osbase.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$arch.$ext") { | ||||
|       return "$base/$profile.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osver.$ext") { | ||||
|       return "$base/$profile.$osver.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$ext") { | ||||
|       return "$base/$profile.$osbase.$ext"; | ||||
|    } elsif (-r "$base/$profile.$ext") { | ||||
|       return "$base/$profile.$ext"; | ||||
|    }  | ||||
|  | ||||
|    return ""; | ||||
| } | ||||
|  | ||||
| 1; | ||||
| @@ -5,12 +5,17 @@ BEGIN | ||||
| } | ||||
| use lib "$::XCATROOT/lib/perl"; | ||||
|  | ||||
| use lib "../imgutils"; | ||||
|  | ||||
| use File::Basename; | ||||
| use File::Path; | ||||
| use File::Copy qw/copy cp mv move/; | ||||
| use File::Find; | ||||
| use Getopt::Long; | ||||
| use Cwd qw(realpath); | ||||
|  | ||||
| use imgutils; | ||||
|  | ||||
| #use strict; | ||||
| Getopt::Long::Configure("bundling"); | ||||
| Getopt::Long::Configure("pass_through"); | ||||
| @@ -265,9 +270,9 @@ unless ($onlyinitrd) { | ||||
|    mkpath("$rootimg_dir/var/lib/yum"); | ||||
|  | ||||
|    if (!$imagename) { | ||||
|        $pkglist= get_profile_def_filename($customdir, "pkglist"); | ||||
|        $pkglist= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); | ||||
|        if (!$pkglist) { | ||||
| 	   $pkglist= get_profile_def_filename($pathtofiles, "pkglist"); | ||||
| 	   $pkglist= imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); | ||||
|        }   | ||||
|    } | ||||
|  | ||||
| @@ -297,8 +302,8 @@ unless ($onlyinitrd) { | ||||
|  | ||||
|    #Now let's handle extra packages | ||||
|     if (!$imagename) { | ||||
| 	$otherpkglist=get_profile_def_filename($customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_profile_def_filename($pathtofiles, "otherpkgs.pkglist"); } | ||||
| 	$otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } | ||||
|     } | ||||
|     my %extra_hash=(); | ||||
|     if ($otherpkglist) { | ||||
| @@ -437,9 +442,9 @@ if (-d "$rootimg_dir/usr/share/dracut") { | ||||
|  | ||||
| #-- run postinstall script | ||||
| if (!$imagename) { | ||||
|     $postinstall_filename= get_profile_def_filename($customdir, "postinstall"); | ||||
|     $postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); | ||||
|     if (!$postinstall_filename) { | ||||
| 	$postinstall_filename= get_profile_def_filename($pathtofiles, "postinstall"); | ||||
| 	$postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); | ||||
|     } | ||||
| }  | ||||
|  | ||||
| @@ -1396,28 +1401,3 @@ sub include_file | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| sub get_profile_def_filename { | ||||
|    my $base=shift; | ||||
|    my $ext=shift; | ||||
|    my $dotpos = rindex($osver, "."); | ||||
|    my $osbase = substr($osver, 0, $dotpos); | ||||
|    if (-r "$base/$profile.$osver.$arch.$ext") { | ||||
|       return "$base/$profile.$osver.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$arch.$ext") { | ||||
|       return "$base/$profile.$osbase.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$arch.$ext") { | ||||
|       return "$base/$profile.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osver.$ext") { | ||||
|       return "$base/$profile.$osver.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$ext") { | ||||
|       return "$base/$profile.$osbase.$ext"; | ||||
|    } elsif (-r "$base/$profile.$ext") { | ||||
|       return "$base/$profile.$ext"; | ||||
|    }  | ||||
|  | ||||
|    return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
| 	 | ||||
|   | ||||
| @@ -5,12 +5,17 @@ BEGIN | ||||
| } | ||||
| use lib "$::XCATROOT/lib/perl"; | ||||
|  | ||||
| use lib "../imgutils"; | ||||
|  | ||||
| use File::Basename; | ||||
| use File::Path; | ||||
| use File::Copy; | ||||
| use File::Find; | ||||
| use Getopt::Long; | ||||
| use Cwd qw(realpath); | ||||
|  | ||||
| use imgutils; | ||||
|  | ||||
| #use strict; | ||||
| Getopt::Long::Configure("bundling"); | ||||
| Getopt::Long::Configure("pass_through"); | ||||
| @@ -235,8 +240,8 @@ if(`grep VERSION /etc/SuSE-release` =~ /VERSION = (\d+)/) { | ||||
|  | ||||
| unless ($onlyinitrd) { | ||||
|     if (!$imagename) { | ||||
| 	$otherpkglist=get_profile_def_filename($customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=get_profile_def_filename($pathtofiles, "otherpkgs.pkglist"); } | ||||
| 	$otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); | ||||
| 	if (!$otherpkglist) { $otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } | ||||
|     } | ||||
|     my %extra_hash=(); | ||||
|     if ($otherpkglist) { | ||||
| @@ -307,9 +312,9 @@ unless ($onlyinitrd) { | ||||
|    #-- add custom repositories to the image   | ||||
|    #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this | ||||
|    my $repolist; | ||||
|     $repolist = get_profile_def_filename($customdir, "repolist"); | ||||
|     $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist"); | ||||
|     if(!$repolist) { | ||||
|         $repolist = get_profile_def_filename($pathtofiles, "repolist"); | ||||
|         $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist"); | ||||
|     } | ||||
|  | ||||
|    if ( -r "$repolist") { | ||||
| @@ -339,8 +344,8 @@ unless ($onlyinitrd) { | ||||
|    #install packages from pkglist file | ||||
|    my $pkgnames; | ||||
|    if (!$imagename) { | ||||
|        $pkglist=get_profile_def_filename($customdir, "pkglist"); | ||||
|        if (!$pkglist) { $pkglist=get_profile_def_filename($pathtofiles, "pkglist"); } | ||||
|        $pkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); | ||||
|        if (!$pkglist) { $pkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); } | ||||
|    } | ||||
|  | ||||
|    if (!$pkglist) { | ||||
| @@ -411,9 +416,9 @@ unlink "/tmp/genimage.$$.yum.conf"; | ||||
|  | ||||
| #-- run postinstall script | ||||
| if (!$imagename) { | ||||
|     $postinstall_filename= get_profile_def_filename($customdir, "postinstall"); | ||||
|     $postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); | ||||
|     if (!$postinstall_filename) { | ||||
| 	$postinstall_filename= get_profile_def_filename($pathtofiles, "postinstall"); | ||||
| 	$postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); | ||||
|     } | ||||
| }  | ||||
|  | ||||
| @@ -1356,28 +1361,4 @@ sub include_file | ||||
|    return join(',', @text); | ||||
| } | ||||
|  | ||||
| sub get_profile_def_filename { | ||||
|    my $base=shift; | ||||
|    my $ext=shift; | ||||
|    my $dotpos = rindex($osver, "."); | ||||
|    my $osbase = substr($osver, 0, $dotpos); | ||||
|    if (-r "$base/$profile.$osver.$arch.$ext") { | ||||
|       return "$base/$profile.$osver.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$arch.$ext") { | ||||
|       return "$base/$profile.$osbase.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$arch.$ext") { | ||||
|       return "$base/$profile.$arch.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osver.$ext") { | ||||
|       return "$base/$profile.$osver.$ext"; | ||||
|    } elsif (-r "$base/$profile.$osbase.$ext") { | ||||
|       return "$base/$profile.$osbase.$ext"; | ||||
|    } elsif (-r "$base/$profile.$ext") { | ||||
|       return "$base/$profile.$ext"; | ||||
|    }  | ||||
|  | ||||
|    return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user