From 6eb9250efc30ad6c91c52cd006e669336bdb0482 Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 17 Oct 2008 15:11:26 +0000 Subject: [PATCH] reduced duplication in postscropts. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2357 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Postage.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Postage.pm b/perl-xCAT/xCAT/Postage.pm index 3597360e6..59961266a 100644 --- a/perl-xCAT/xCAT/Postage.pm +++ b/perl-xCAT/xCAT/Postage.pm @@ -252,12 +252,16 @@ sub makescript { ###Please do not remove or modify this line of code!!! xcatdsklspost depends on it push @scriptd, "# postscripts-start-here\n"; + my %post_hash=(); #used to reduce duplicates # get the xcatdefaults entry in the postscripts table my $et = $posttab->getAttribs({node=>"xcatdefaults"},'postscripts'); my $defscripts = $et->{'postscripts'}; if ($defscripts) { foreach my $n (split(/,/, $defscripts)) { - push @scriptd, $n."\n"; + if (! exists($post_hash{$n})) { + $post_hash{$n}=1; + push @scriptd, $n."\n"; + } } } @@ -266,7 +270,10 @@ sub makescript { $ps = $et->{'postscripts'}; if ($ps) { foreach my $n (split(/,/, $ps)) { - push @scriptd, $n."\n"; + if (! exists($post_hash{$n})) { + $post_hash{$n}=1; + push @scriptd, $n."\n"; + } } }