Support multiple otherpkg and pkglist entries to work with Kit. alsofix a problem in kit.pm found during genimage.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14140 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -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"; | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user