diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 212181f8b..9e040593d 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -519,10 +519,11 @@ sub assign_to_osimage } # Adding kit component basename to osimage.otherpkgs.pkglist - if ( $kitcomptable and $kitcomptable->{basename} ) { + if ( $kitcomptable and $kitcomptable->{basename} and $kitcomptable->{kitreponame} ) { my @lines; my $basename = $kitcomptable->{basename}; + my $kitreponame = $kitcomptable->{kitreponame}; # Adding kit component basename to KIT_COMPONENTS.otherpkgs.pkglist file mkpath("$installdir/osimages/$osimage/kits"); @@ -538,10 +539,10 @@ sub assign_to_osimage return 1; } } - unless ( grep(/^$basename$/, @lines) ) { + unless ( grep(/^$kitreponame\/$basename$/, @lines) ) { if (open(NEWOTHERPKGLIST, ">>", "$installdir/osimages/$osimage/kits/KIT_COMPONENTS.otherpkgs.pkglist")) { - print NEWOTHERPKGLIST "$basename\n"; + print NEWOTHERPKGLIST "$kitreponame/$basename\n"; close(NEWOTHERPKGLIST); } } @@ -595,7 +596,7 @@ sub assign_to_osimage chomp $line; my $matched = 0; foreach my $kitpkgdep ( @kitpkgdeps ) { - if ( $line =~ /^-$kitpkgdep$/ ) { + if ( $line =~ /^-$kitreponame\/$kitpkgdep$/ ) { $matched = 1; $changed = 1; last; @@ -1968,12 +1969,13 @@ sub rmkitcomp } my $basename = ''; - if ( exists($kitcomps{$kitcomponent}{basename}) ) { + if ( exists($kitcomps{$kitcomponent}{basename}) and exists($kitcomps{$kitcomponent}{kitreponame})) { $basename = $kitcomps{$kitcomponent}{basename}; + my $kitreponame = $kitcomps{$kitcomponent}{kitreponame}; my @newlines = (); foreach my $line ( @lines ) { - if ( $line =~ /^$basename$/ ) { + if ( $line =~ /^$kitreponame\/$basename$/ ) { next; } push @newlines, $line; @@ -2011,10 +2013,12 @@ sub rmkitcomp my @l = @lines; my $basename = ''; + my $kitreponame = ''; my @kitpkgdeps = (); - if ( exists($kitcomps{$kitcomponent}{basename}) ) { + if ( exists($kitcomps{$kitcomponent}{basename}) and exists($kitcomps{$kitcomponent}{kitreponame}) ) { $basename = $kitcomps{$kitcomponent}{basename}; + $kitreponame = $kitcomps{$kitcomponent}{kitreponame}; } else { my %rsp; push@{ $rsp{data} }, "Could not open kit component table and read basename for kit component $kitcomp"; @@ -2032,14 +2036,14 @@ sub rmkitcomp my $matched = 0; foreach my $line ( @lines ) { chomp $line; - if ( $line =~ /^-$kitpkgdep$/ ) { + if ( $line =~ /^-$kitreponame\/$kitpkgdep$/ ) { $matched = 1; last; } } unless ( $matched ) { - push @l, "-$kitpkgdep\n"; + push @l, "-$kitreponame/$kitpkgdep\n"; } } diff --git a/xCAT-server/share/xcat/netboot/imgutils/imgutils.pm b/xCAT-server/share/xcat/netboot/imgutils/imgutils.pm index a96adfc77..c93e8fb19 100644 --- a/xCAT-server/share/xcat/netboot/imgutils/imgutils.pm +++ b/xCAT-server/share/xcat/netboot/imgutils/imgutils.pm @@ -79,78 +79,81 @@ sub include_file } sub get_package_names { - my $plist_file_name=shift; + my $plist_file_list=shift; my %pkgnames=(); my @tmp_array=(); + my @plist_file_names = split ',', $plist_file_list; + foreach my $plist_file_name ( @plist_file_names ) { + if ($plist_file_name && -r $plist_file_name) { + my $pkgfile; + open($pkgfile,"<","$plist_file_name"); + while (<$pkgfile>) { + chomp; + s/\s+$//; #remove trailing white spaces + next if /^\s*$/; #-- skip empty lines + next + if ( /^\s*#/ + && !/^\s*#INCLUDE:[^#^\n]+#/ + && !/^\s*#NEW_INSTALL_LIST#/ + && !/^\s*#ENV:[^#^\n]+#/); #-- skip comments + push(@tmp_array,$_); + } + close($pkgfile); - if ($plist_file_name && -r $plist_file_name) { - my $pkgfile; - open($pkgfile,"<","$plist_file_name"); - while (<$pkgfile>) { - chomp; - s/\s+$//; #remove trailing white spaces - next if /^\s*$/; #-- skip empty lines - next - if ( /^\s*#/ - && !/^\s*#INCLUDE:[^#^\n]+#/ - && !/^\s*#NEW_INSTALL_LIST#/ - && !/^\s*#ENV:[^#^\n]+#/); #-- skip comments - push(@tmp_array,$_); - } - close($pkgfile); - - if ( @tmp_array > 0) { - my $pkgtext=join(',',@tmp_array); - #handle the #INLCUDE# tag recursively - my $idir = dirname($plist_file_name); - my $doneincludes=0; - while (not $doneincludes) { - $doneincludes=1; - if ($pkgtext =~ /#INCLUDE:[^#^\n]+#/) { - $doneincludes=0; - $pkgtext =~ s/#INCLUDE:([^#^\n]+)#/include_file($1,$idir)/eg; - } - } - - #print "pkgtext=$pkgtext\n"; - my @tmp=split(',', $pkgtext); - my $pass=1; - foreach (@tmp) { - my $idir; - if (/^--/) { - $idir="POST_REMOVE"; #line starts with -- means the package should be removed after otherpkgs are installed - s/^--//; - } elsif (/^-/) { - $idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed - s/^-//; - } elsif (/^#NEW_INSTALL_LIST#/) { - $pass++; - next; - } elsif (/^#ENV:([^#^\n]+)#/) { - my $pa=$pkgnames{$pass}{ENVLIST}; - my $env = $1; - if (exists($pkgnames{$pass}{ENVLIST})){ - push(@$pa,$env); - } else { - $pkgnames{$pass}{ENVLIST} = [$env]; + if ( @tmp_array > 0) { + my $pkgtext=join(',',@tmp_array); + #handle the #INLCUDE# tag recursively + my $idir = dirname($plist_file_name); + my $doneincludes=0; + while (not $doneincludes) { + $doneincludes=1; + if ($pkgtext =~ /#INCLUDE:[^#^\n]+#/) { + $doneincludes=0; + $pkgtext =~ s/#INCLUDE:([^#^\n]+)#/include_file($1,$idir)/eg; + } } - next; - } elsif (/^#/) { - # ignore all other comment lines - next; - } else { - $idir=dirname($_); - } - my $fn=basename($_); - if (exists($pkgnames{$pass}{$idir})) { - my $pa=$pkgnames{$pass}{$idir}; - push(@$pa, $fn); - } else { - $pkgnames{$pass}{$idir}=[$fn]; - } - } - } + + #print "pkgtext=$pkgtext\n"; + my @tmp=split(',', $pkgtext); + my $pass=1; + foreach (@tmp) { + my $idir; + if (/^--/) { + $idir="POST_REMOVE"; #line starts with -- means the package should be removed after otherpkgs are installed + s/^--//; + } elsif (/^-/) { + $idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed + s/^-//; + } elsif (/^#NEW_INSTALL_LIST#/) { + $pass++; + next; + } elsif (/^#ENV:([^#^\n]+)#/) { + my $pa=$pkgnames{$pass}{ENVLIST}; + my $env = $1; + if (exists($pkgnames{$pass}{ENVLIST})){ + push(@$pa,$env); + } else { + $pkgnames{$pass}{ENVLIST} = [$env]; + } + next; + } elsif (/^#/) { + # ignore all other comment lines + next; + } else { + $idir=dirname($_); + } + my $fn=basename($_); + if (exists($pkgnames{$pass}{$idir})) { + my $pa=$pkgnames{$pass}{$idir}; + push(@$pa, $fn); + } else { + $pkgnames{$pass}{$idir}=[$fn]; + } + + } + } + } } return %pkgnames;