From 1130f848bdde8a56b82d95af7657330869890304 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 30 Oct 2012 07:32:23 +0000 Subject: [PATCH] Fixed a problem that if kitpkgdeps is not set in kit.conf, which is not correct, we still need to handle the KIT_RMPKGS.otherpkgs.pkglist with kitcomponent basenames anyway git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14152 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 52 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 22513502f..88a84e623 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -569,28 +569,24 @@ sub assign_to_osimage # Remove this component basename and pkgnames from KIT_RMPKGS.otherpkg.pkglist my @lines = (); - my @kitpkgdeps = (); - my @l = (); - if ( $kitcomptable->{kitpkgdeps} ) { - if ( -e "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist" ) { - if (open(RMOTHERPKGLIST, "<", "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist")) { - @lines = ; - close(RMOTHERPKGLIST); - if($::VERBOSE){ - $callback->({data=>["\nReading kit component rmpkgs file $installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist\n"]}); - } - } else { - $callback->({error => ["Could not open kit component rmpkgs file $installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist"],errorcode=>[1]}); - return 1; - } - } - - @kitpkgdeps = split ',', $kitcomptable->{kitpkgdeps}; - - } + my @kitpkgdeps = split ',', $kitcomptable->{kitpkgdeps}; push @kitpkgdeps, $basename; + my @l = (); + if ( -e "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist" ) { + if (open(RMOTHERPKGLIST, "<", "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist")) { + @lines = ; + close(RMOTHERPKGLIST); + if($::VERBOSE){ + $callback->({data=>["\nReading kit component rmpkgs file $installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist\n"]}); + } + } else { + $callback->({error => ["Could not open kit component rmpkgs file $installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist"],errorcode=>[1]}); + return 1; + } + } + my $changed = 0; foreach my $line ( @lines ) { chomp $line; @@ -2036,6 +2032,7 @@ sub rmkitcomp push @kitpkgdeps, $basename; + my $update = 0; foreach my $kitpkgdep ( @kitpkgdeps ) { my $matched = 0; foreach my $line ( @lines ) { @@ -2048,15 +2045,30 @@ sub rmkitcomp unless ( $matched ) { push @l, "-$kitreponame/$kitpkgdep\n"; + $update = 1; } } - if (open(RMPKGLIST, ">", "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist")) { + if ( $update and open(RMPKGLIST, ">", "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist") ) { print RMPKGLIST @l; close(RMPKGLIST); } + if ( $linuximagetable and $linuximagetable->{otherpkglist} ) { + my $match = 0; + my @otherpkglists= split ',', $linuximagetable->{otherpkglist}; + foreach my $otherpkglist ( @otherpkglists ) { + if ( $otherpkglist =~ /^$installdir\/osimages\/$osimage\/kits\/KIT_RMPKGS.otherpkgs.pkglist$/ ) { + $match = 1; + last; + } + } + + if ( !$match and -e "$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist" ) { + $linuximagetable->{otherpkglist} = $linuximagetable->{otherpkglist} . ",$installdir/osimages/$osimage/kits/KIT_RMPKGS.otherpkgs.pkglist" + } + } } }