Refactor structure of DerGeret's disk
This commit is contained in:
parent
021f9c767a
commit
41bfc2df9e
1 changed files with 24 additions and 8 deletions
|
@ -11,28 +11,44 @@ $Global:SetupConfigPostprocessor = {
|
|||
$diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace);
|
||||
$installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace);
|
||||
|
||||
$newIndex = [int]$installationPartition.InnerText;
|
||||
$newIndex = 2;
|
||||
$installationPartition.InnerText = "$($newIndex + 1)";
|
||||
$partitionCreations = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
|
||||
$newPartition = $partitionCreations.SelectNodes("./ua:CreatePartition", $namespace)[0].CloneNode($true);
|
||||
$winPartition = ($partitionCreations.SelectNodes("./ua:CreatePartition", $namespace) | Select-Object -Last)[0];
|
||||
$newPartition = $winPartition.CloneNode($true);
|
||||
|
||||
$offset = 0;
|
||||
|
||||
for ($i = 0; $i -lt $partitionCreations.ChildNodes.Count; $i++) {
|
||||
$partition = $partitionCreations.ChildNodes[$i];
|
||||
$order = [int]$partition.SelectSingleNode("./ua:Order", $namespace).InnerText;
|
||||
$offset += [int]$partition.SelectSingleNode("./ua:Size", $namespace).InnerText;
|
||||
$newOrder = $order;
|
||||
|
||||
if ($order -ge $newIndex) {
|
||||
$partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$($order + 1)";
|
||||
if ($order -eq 2) {
|
||||
$newOrder--;
|
||||
} else {
|
||||
$offset += [int]$partition.SelectSingleNode("./ua:Size", $namespace).InnerText;
|
||||
if ($order -ge $newIndex) {
|
||||
$newOrder++;
|
||||
}
|
||||
|
||||
if ($order -lt 2) {
|
||||
$newOrder++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($order -ne $newOrder) {
|
||||
$partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newOrder";
|
||||
}
|
||||
}
|
||||
|
||||
# Add 1 TB space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
|
||||
$newPartition.SelectSingleNode("./ua:Size", $namespace).InnerText = "$((64 * 1024) - $offset)";
|
||||
$newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
|
||||
# Add space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw.
|
||||
$size = $winPartition.OwnerDocument.CreateElement("Size");
|
||||
$size.InnerText = "$((1 * 1024 * 1024) - $offset)";
|
||||
$winPartition.RemoveChild($winPartition.SelectSingleNode("./Extend"));
|
||||
$winPartition.AppendChild($size);
|
||||
|
||||
$newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex";
|
||||
$null = $partitionCreations.AppendChild($newPartition);
|
||||
|
||||
$partitionModifications = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
|
||||
|
|
Loading…
Reference in a new issue