mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-31 10:06:39 +00:00
Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core
This commit is contained in:
commit
9ed9a9d061
@ -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.enc >/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) {
|
||||
|
@ -696,7 +696,8 @@ sub mkinstall {
|
||||
$node,
|
||||
$pkglistfile,
|
||||
$pkgdir,
|
||||
$platform
|
||||
$platform,
|
||||
$partitionfile
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -198,5 +198,6 @@ echo " ." >> /tmp/partitioning
|
||||
|
||||
#XCA_PARTMAN_RECIPE_SCRIPT#
|
||||
#XCA_PARTMAN_DISK_SCRIPT#
|
||||
#XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT#
|
||||
exit 0
|
||||
|
||||
|
@ -120,7 +120,77 @@ chmod 755 /tmp/foo.sh
|
||||
|
||||
/tmp/foo.sh >/tmp/foo.log 2>&1 &
|
||||
|
||||
# This function is intend to be used in the busybox sh inside debian-installer
|
||||
# initrd image. Due to the limitation of the commands can be used in such an
|
||||
# environment, there are some strange parts is this script.
|
||||
#
|
||||
# Command printf is the only external command to be called.
|
||||
#
|
||||
# This function can run under bash as well, but will failed under bash invoked
|
||||
# with the name sh.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# base64encode <input_file >out_file
|
||||
#
|
||||
|
||||
base64decode()
|
||||
{
|
||||
h0="0"; h1="1"; h2="2"; h3="3"; h4="4"; h5="5"; h6="6"; h7="7";
|
||||
h8="8"; h9="9"; h10="A"; h11="B"; h12="C"; h13="D"; h14="E"; h15="F";
|
||||
|
||||
while :
|
||||
do
|
||||
i=0
|
||||
while [ "$i" -lt 4 ]
|
||||
do
|
||||
read -n 1 c || return
|
||||
|
||||
case "${c}" in
|
||||
"A") d=0 ;; "B") d=1 ;; "C") d=2 ;; "D") d=3 ;;
|
||||
"E") d=4 ;; "F") d=5 ;; "G") d=6 ;; "H") d=7 ;;
|
||||
"I") d=8 ;; "J") d=9 ;; "K") d=10 ;; "L") d=11 ;;
|
||||
"M") d=12 ;; "N") d=13 ;; "O") d=14 ;; "P") d=15 ;;
|
||||
"Q") d=16 ;; "R") d=17 ;; "S") d=18 ;; "T") d=19 ;;
|
||||
"U") d=20 ;; "V") d=21 ;; "W") d=22 ;; "X") d=23 ;;
|
||||
"Y") d=24 ;; "Z") d=25 ;; "a") d=26 ;; "b") d=27 ;;
|
||||
"c") d=28 ;; "d") d=29 ;; "e") d=30 ;; "f") d=31 ;;
|
||||
"g") d=32 ;; "h") d=33 ;; "i") d=34 ;; "j") d=35 ;;
|
||||
"k") d=36 ;; "l") d=37 ;; "m") d=38 ;; "n") d=39 ;;
|
||||
"o") d=40 ;; "p") d=41 ;; "q") d=42 ;; "r") d=43 ;;
|
||||
"s") d=44 ;; "t") d=45 ;; "u") d=46 ;; "v") d=47 ;;
|
||||
"w") d=48 ;; "x") d=49 ;; "y") d=50 ;; "z") d=51 ;;
|
||||
"0") d=52 ;; "1") d=53 ;; "2") d=54 ;; "3") d=55 ;;
|
||||
"4") d=56 ;; "5") d=57 ;; "6") d=58 ;; "7") d=59 ;;
|
||||
"8") d=60 ;; "9") d=61 ;; "+") d=62 ;; "/") d=63 ;;
|
||||
"=") d=0 ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
|
||||
eval "a${i}=${c}"
|
||||
eval "b${i}=${d}"
|
||||
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
|
||||
o0=$(( ((b0 << 2) | (b1 >> 4)) & 0xff ))
|
||||
o1=$(( ((b1 << 4) | (b2 >> 2)) & 0xff ))
|
||||
o2=$(( ((b2 << 6) | b3) & 0xff ))
|
||||
|
||||
[ "${a2}" == "=" ] &&
|
||||
eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
|
||||
))}\"" &&
|
||||
return
|
||||
[ "${a3}" == "=" ] &&
|
||||
eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
|
||||
))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16
|
||||
))}\"" &&
|
||||
return
|
||||
eval "printf \"\\x\${h$(( o0 / 16 ))}\${h$(( o0 % 16
|
||||
))}\\x\${h$(( o1 / 16 ))}\${h$(( o1 % 16
|
||||
))}\\x\${h$(( o2 / 16 ))}\${h$(( o2 % 16 ))}\""
|
||||
done
|
||||
}
|
||||
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
echo "ubuntu-efi ::" > /tmp/partitioning
|
||||
@ -145,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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user