From e87c72c38d6ed9331fd1d08ac85536e79fcc70ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:42:40 -0300 Subject: [PATCH] fix(template): read each partitionfile entry with its own s: prefix linuximage.partitionfile takes a comma-separated list of layout, d: disk and c: configuration entries, any of them prefixed with s: for a script. The Ubuntu layout step chose between decoding a layout file and running a layout script by the s: prefix of the last entry in the whole list, so a layout file followed by an s:d: disk script was run as a script, and a layout script followed by a d: disk file was copied into the layout as text. The parser also kept a script flag set by an earlier entry of the same kind after a later entry replaced it. Give each kind the prefix of the entry that is used, the last one of that kind, and decode the Ubuntu layout by it. --- xCAT-server/lib/perl/xCAT/Template.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 747ba01e04..d332a91f5e 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -224,15 +224,16 @@ sub subvars { $filepath = $1; } + # The last entry of each kind wins, with its own s: prefix. if ($filepath =~ /^d:(.*)/) { - $diskfile = $1; - if ($scriptflag) { $diskscriptflag = 1; } + $diskfile = $1; + $diskscriptflag = $scriptflag; } elsif ($filepath =~ /^c:(.*)/) { - $configfile = $1; - if ($scriptflag) { $configscriptflag = 1; } + $configfile = $1; + $configscriptflag = $scriptflag; } elsif ($filepath) { - $partitionfile = $filepath; - if ($scriptflag) { $partscriptflag = 1; } + $partitionfile = $filepath; + $partscriptflag = $scriptflag; } } @@ -483,7 +484,7 @@ sub subvars { # Put the base64 coded partitionfile into %pre part $partcontent = "cat > /tmp/partscript.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; - if ($scriptflag) { + if ($partscriptflag) { # Put the code to decode preseed script and run it to generate pressed recipe file #$partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partscript\n";