From 34866ebc23b47be12887470ec2c60ea1c29f3067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 22 Jul 2026 19:11:47 -0300 Subject: [PATCH] fix(template): fall back to $::XCATROOT when XCATROOT is not in %ENV envvar() resolves a template variable purely from %ENV, so a template that references $XCATROOT expands to an empty string whenever XCATROOT is not present in the environment of the process doing the substitution. $::XCATROOT is set as a package global at module load and is reliably available, so use it for that one variable before falling back to %ENV. Recovered from the unmerged lenovobuild branch (original da72c6b8). Co-authored-by: Jarrod Johnson <10814490+jjohnson42@users.noreply.github.com> --- xCAT-server/lib/perl/xCAT/Template.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index c2a5c2137..318bb930e 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -1617,6 +1617,10 @@ sub envvar $envvar =~ s/^\$//; } + # $XCATROOT is reliably set as a package global even when it is absent from + # %ENV, so a template referencing it does not expand to undef. + if ($envvar eq 'XCATROOT') { return $::XCATROOT; } + return ($ENV{$envvar}); }