From 866302c88addbb12b1bec973c16dfe27e9654c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 22 Aug 2026 11:29:10 -0300 Subject: [PATCH] fix(template): omit the default HTTP port from installer URLs The template renderer writes the HTTP port into the URLs of a kickstart file, an autoyast profile and a preseed file. It writes the port always, so a URL gets the text ":80" when the site keeps the default port. A URL that gives no port already goes to port 80. Write the port only when the site sets a port that is not 80. The netboot plugins xnba, dhcp and mknb already do this. The module gave the port in three different ways. One place wrote the port always. One place wrote the port only when the port was not 80. One place wrote the port always from the environment. Put the rule in one routine and let the four places use that routine. The routine also accepts a port that is set to nothing. Before, an empty value made a URL that ends with a colon. --- xCAT-server/lib/perl/xCAT/Template.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 547910e78..d02048c88 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -47,6 +47,12 @@ my %tab_replacement = ( "noderes:tftpserver" => "noderes:xcatmaster", ); +sub httpport_suffix { + my $httpport = shift; + $httpport = "80" unless defined $httpport and length $httpport; + return "" if $httpport eq "80"; + return ":$httpport"; +} sub subvars { my $self = shift; @@ -150,7 +156,7 @@ sub subvars { } $ENV{HTTPPORT} = $httpport; - $httpportsuffix=":$httpport"; + $httpportsuffix = httpport_suffix($httpport); #replace the env with the right value so that correct include files can be found $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; my $res; @@ -545,7 +551,7 @@ sub subvars { } } elsif ("ubuntu" eq $platform) { - my $default_script = " wget http://`cat /tmp/xcatserver`".':'.$ENV{HTTPPORT} . $ENV{INSTALLDIR} . "/autoinst/getinstdisk; chmod u+x getinstdisk; ./getinstdisk;"; + my $default_script = " wget http://`cat /tmp/xcatserver`" . httpport_suffix($ENV{HTTPPORT}) . $ENV{INSTALLDIR} . "/autoinst/getinstdisk; chmod u+x getinstdisk; ./getinstdisk;"; $inc =~ s/#INCLUDE_GET_INSTALL_DISK_SCRIPT#/$default_script/; } else { @@ -1132,7 +1138,7 @@ sub mirrorspec { $pkgdir = $_; } else { my $httpport = $ENV{HTTPPORT} || $ENV{httpport} || '80'; - my $osuurl = "http://" . $masternode . ':' . $httpport . $_ . " ./"; + my $osuurl = "http://" . $masternode . httpport_suffix($httpport) . $_ . " ./"; push @mirrors, $osuurl; } } @@ -1141,7 +1147,7 @@ sub mirrorspec { if ($pkgdir) { my $httpport = $ENV{HTTPPORT} || $ENV{httpport} || '80'; my $security_host = $masternode; - $security_host .= ':' . $httpport if $httpport ne '80'; + $security_host .= httpport_suffix($httpport); $line .= " d-i mirror/country string manual\n d-i mirror/protocol string http\n