From 89209d885b03211ff370ca630998c410ea55ae28 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Mon, 1 Apr 2013 10:37:42 +0000 Subject: [PATCH] Fixing bug 3410: don't remove kitrepo if there is other kitcomponent assigned to the osimage git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15759 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 36810e509..c30ecdd46 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2136,9 +2136,26 @@ sub rmkitcomp my $otherpkgdir = $linuximagetable->{otherpkgdir}; foreach my $kitcomponent (keys %kitcomps) { + if ( $kitcomps{$kitcomponent}{kitreponame} ) { if ( -d "$otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}" ) { - system("rm -rf $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}"); + + # Check if this repo is used by other kitcomponent before removing the link + my $match = 0; + foreach my $osikitcomp ( @osikitcomps ) { + next if ( $osikitcomp =~ /$kitcomponent/ ); + my $depkitrepodir; + (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $osikitcomp}, 'kitreponame'); + if ( $kitcomptable and $kitcomptable->{kitreponame} ) { + $depkitrepodir = "$otherpkgdir/$kitcomptable->{kitreponame}"; + } + if ( $depkitrepodir =~ /^$otherpkgdir\/$kitcomps{$kitcomponent}{kitreponame}$/) { + $match = 1; + } + } + if ( !$match ) { + system("rm -rf $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}"); + } } } }