From 8986a3151afe9d673e060edf2ad11dc4db76a70f Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 25 Jun 2012 12:03:03 +0000 Subject: [PATCH] specify the partition file: add the definition into configure file for rh,SL,CentOS,fedora git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13159 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/Template.pm | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 17e13e5f1..c0e50415b 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -46,6 +46,7 @@ sub subvars { my $pkglistfile=shift; my $media_dir = shift; my $platform=shift; + my $partitionfile=shift; my %namedargs = @_; #further expansion of this function will be named arguments, should have happened sooner. unless ($namedargs{reusemachinepass}) { $lastmachinepass=""; @@ -186,6 +187,42 @@ sub subvars { $inc =~ s/#SLES_SDK_MEDIA#/$sles_sdk_media/eg; + #if user specify the partion file, replace the default partition strategy + if ($partitionfile){ + #if the content of the partition file is definition replace the default is ok + my $partcontent = ''; + my $scriptflag = 0; + + if ($partitionfile =~ /^s:(.*)/){ + $scriptflag = 1; + $partitionfile = $1; + } + + if (-r $partitionfile){ + open ($inh, "<", $partitionfile); + while (<$inh>){ + $partcontent .= $_; + } + close ($inh); + + #the content of the specified file is a script which can write partition definition into /tmp/partitionfile + if ($scriptflag){ + my $tempstr = "%inlcude /tmp/partitionfile\n"; + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; + #modify the content in the file, and write into %pre part + $partcontent = "cat > /tmp/partscript << EOF\n" . $partcontent . "\nEOF\n"; + $partcontent .= "chmod 755 /tmp/partscript\n"; + $partcontent .= "/tmp/partscript\n"; + #replace the #XCA_PARTITION_SCRIPT# + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; + } + else{ + $partcontent =~ s/\s$//; + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; + } + } + } + if ($tmplerr) { close ($outh); return $tmplerr;