From faabb8e54b740053b5e15a3d762efe85e5f5d3f1 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 30 Apr 2015 04:02:44 -0400 Subject: [PATCH] merge --- xCAT-server/lib/perl/xCAT/Template.pm | 90 ++++++++++++++----- xCAT-server/lib/xcat/plugins/debian.pm | 3 +- .../share/xcat/install/scripts/pre.ubuntu | 1 + .../xcat/install/scripts/pre.ubuntu.ppc64 | 3 + .../share/xcat/install/ubuntu/compute.tmpl | 1 + 5 files changed, 77 insertions(+), 21 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 34a45ca16..516d6b499 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -170,27 +170,47 @@ sub subvars { #if user specify the partion file, replace the default partition strategy my $partcontent; my $diskcontent; + my $configcontent; my $scriptflag = 0; + my $partscriptflag = 0; + my $diskscriptflag = 0; + my $configscriptflag = 0; my $preseedflag =0; + my $configfile; my $partitionfile; my $diskfile; - my $diskscriptflag; my @partitionfilelist=split(/,/,$partitionfileval); - foreach(@partitionfilelist){ - if($_ =~ /^sd:(.*)/){ + foreach my $filepath (@partitionfilelist){ + $scriptflag =0; + if($filepath =~ /^s:(.*)/){ + $scriptflag = 1; + $filepath=$1; + } + + if($filepath =~ /^d:(.*)/){ $diskfile=$1; - $diskscriptflag=1; - }elsif($_ =~ /^d:(.*)/){ - $diskfile=$1; - }elsif($_ =~ /^s:(.*)/){ - $partitionfile=$1; - $scriptflag = 1; - }else{ - $partitionfile=$_; + if($scriptflag ) {$diskscriptflag=1;}; + }elsif($filepath =~ /^c:(.*)/){ + $configfile=$1; + if($scriptflag ) {$configscriptflag=1;}; + }elsif($filepath){ + $partitionfile=$filepath; + if($scriptflag ) {$partscriptflag=1;}; } } - + if($configfile){ + if (-r $configfile){ + open ($inh, "<", $configfile); + while (<$inh>){ + $configcontent .= $_; + } + close ($inh); + } + + # append the partition file into the $inc to do the replacement + $inc .= "\nFFFFFFFFFFFFPARTITIONCONFIGFILESTART\n".$configcontent."\nFFFFFFFFFFFFPARTITIONCONFIGFILEEND\n"; + } if($diskfile){ if (-r $diskfile){ @@ -202,14 +222,10 @@ sub subvars { } # append the partition file into the $inc to do the replacement - $inc .= "\nFFFFFFFFFFFFPARTITIONDISKFILESTART\n".$diskcontent; + $inc .= "\nFFFFFFFFFFFFPARTITIONDISKFILESTART\n".$diskcontent."\nFFFFFFFFFFFFPARTITIONDISKFILEEND\n"; } if ($partitionfile){ - if ($partitionfile =~ /^s:(.*)/){ - $scriptflag = 1; - $partitionfile = $1; - } if($inc =~ /#XCA_PARTMAN_RECIPE_SCRIPT#/){ $preseedflag=1; @@ -224,7 +240,7 @@ sub subvars { } # append the partition file into the $inc to do the replacement - $inc .= "\nFFFFFFFFFFFFPARTITIONFILESTART\n".$partcontent; + $inc .= "\nFFFFFFFFFFFFPARTITIONFILESTART\n".$partcontent."\nFFFFFFFFFFFFPARTITIONFILEEND\n"; } @@ -330,7 +346,9 @@ sub subvars { #the content of the specified file is a script which can write partition definition into /tmp/partitionfile # split the partition file out from the $inc ($inc, $partcontent) = split(/FFFFFFFFFFFFPARTITIONFILESTART\n/, $inc); - if ($scriptflag or $preseedflag){ + ($partcontent, $res) = split(/\nFFFFFFFFFFFFPARTITIONFILEEND/, $partcontent); + $inc .=$res; + if ($partscriptflag or $preseedflag){ # since the whole partition file needs be packaged in %pre first and generate an executable file at running time, # all the special chars like ',",%,\ need be kept, we have to use the base64 coding to code it and put it in # %pre and decode it out during the running time. @@ -399,6 +417,8 @@ sub subvars { #the content of the specified file is the disknames to partition or a script which can write disk names into /tmp/boot_disk # split the disk file out from the $inc ($inc, $diskcontent) = split(/FFFFFFFFFFFFPARTITIONDISKFILESTART\n/, $inc); + ($diskcontent,$res) = split(/\nFFFFFFFFFFFFPARTITIONDISKFILEEND/, $diskcontent); + $inc .=$res; # since the whole partition file needs be packaged in %pre first and generate an executable file at running time, # all the special chars like ',",%,\ need be kept, we have to use the base64 coding to code it and put it in # %pre and decode it out during the running time. @@ -424,7 +444,37 @@ sub subvars { #replace the #XCA_PARTMAN_DISK_SCRIPT# $inc =~ s/#XCA_PARTMAN_DISK_SCRIPT#/$diskcontent/; } - } + } + + if ($configfile && $doneincludes) { + #the content of the specified file is the additional pressed config with 'd-i' or + # a script set the additional pressed config with "debconf-set" + # split the config file out from the $inc + ($inc, $configcontent) = split(/FFFFFFFFFFFFPARTITIONCONFIGFILESTART\n/, $inc); + ($configcontent,$res) = split(/\nFFFFFFFFFFFFPARTITIONCONFIGFILEEND/, $configcontent); + $inc .=$res; + + + + if ($configscriptflag){ + # since the whole partition file needs be packaged in %pre first and generate an executable file at running time, + # all the special chars like ',",%,\ need be kept, we have to use the base64 coding to code it and put it in + # %pre and decode it out during the running time. + use MIME::Base64; + $configcontent = encode_base64($configcontent); + $configcontent =~ s/\n//g; + # Put the base64 coded config script into %pre part + $configcontent = "cat > /tmp/configscript.enc << EOFEOF\n" . $configcontent . "\nEOFEOF\n"; + + # Put the code to decode config script and run it to generate pressed config + $configcontent .= "base64decode/tmp/configscript\n"; + $configcontent .= "chmod 755 /tmp/configscript\n"; + $configcontent .= "/tmp/configscript\n"; + $inc =~ s/#XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT#/$configcontent/; + }else{ + $inc =~ s/#XCA_PARTMAN_ADDITIONAL_CFG#/$configcontent/; + } + } } if ($tmplerr) { diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 6d96b6566..2a0c68cdc 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -696,7 +696,8 @@ sub mkinstall { $node, $pkglistfile, $pkgdir, - $platform + $platform, + $partitionfile ); } diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu b/xCAT-server/share/xcat/install/scripts/pre.ubuntu index fd578e9f7..0e0262595 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu @@ -198,5 +198,6 @@ echo " ." >> /tmp/partitioning #XCA_PARTMAN_RECIPE_SCRIPT# #XCA_PARTMAN_DISK_SCRIPT# +#XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT# exit 0 diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 index ede61c62f..5ca50160f 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 @@ -215,7 +215,10 @@ echo "2048 512 300% linux-swap" >> /tmp/partitioning echo " method{ swap } format{ }" >> /tmp/partitioning echo " ." >> /tmp/partitioning + #XCA_PARTMAN_RECIPE_SCRIPT# #XCA_PARTMAN_DISK_SCRIPT# +#XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT# + exit 0 diff --git a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl index 7a986cc8e..39398d6e5 100644 --- a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl +++ b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl @@ -73,6 +73,7 @@ d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true +#XCA_PARTMAN_ADDITIONAL_CFG# ### Account setup