2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-07-15 02:10:44 +00:00

fix(xcat-server): default the Ubuntu apt mirror for netboot and Subiquity

The Ubuntu live-server ISO copycds imports is not a complete apt pool, so
both Ubuntu install paths fail without an external mirror: the netboot
genimage's debootstrap from the ISO-only pkgdir cannot resolve packages,
and the Subiquity diskful install (Template.pm) fell back to the airgapped
file:///cdrom config. Default site.ubuntu_apt_mirror to
http://archive.ubuntu.com/ubuntu when unset (overridable for local/geo/
ports mirrors). In the Ubuntu genimage, when pkgdir has no http mirror,
build the debootstrap source and chroot sources.list from that mirror with
the codename derived from osvers and the release/-updates/-security pockets
(main + universe) -- the compute pkglist needs universe (busybox-static,
dracut*) and the security-updated openssh. Ubuntu-only; EL netboot
(netboot/rh) and copycds/packimage are untouched.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-06-24 11:21:59 -03:00
parent c0731a5e33
commit 03e1559989
2 changed files with 36 additions and 7 deletions
+7 -7
View File
@@ -1654,15 +1654,15 @@ sub crydb_or_locked
sub ubuntu_subiquity_apt_mirror
{
# Online apt mirror for Subiquity installs. When site.ubuntu_apt_mirror is set
# (e.g. http://archive.ubuntu.com/ubuntu or a local full mirror), the generated
# autoinstall apt config pulls from it so packages missing from the minimal
# live-server install media are fetched over the network. Unset => keep the
# airgapped file:///cdrom config (backward compatible).
# Apt mirror for Subiquity installs. site.ubuntu_apt_mirror overrides; otherwise default to the
# public archive. The minimal live-server install media is not a complete package source, so a
# real mirror is always required -- set site.ubuntu_apt_mirror to a local full mirror for
# airgapped clusters (or to a geo/ports mirror as needed).
my $default = 'http://archive.ubuntu.com/ubuntu';
my $site_tab = xCAT::Table->new('site');
return '' unless $site_tab;
return $default unless $site_tab;
my $ent = $site_tab->getAttribs({ key => 'ubuntu_apt_mirror' }, 'value');
return ($ent && defined($ent->{value}) && length($ent->{value})) ? $ent->{value} : '';
return ($ent && defined($ent->{value}) && length($ent->{value})) ? $ent->{value} : $default;
}
sub ubuntu_subiquity_apt_config
@@ -257,6 +257,35 @@ unless ($onlyinitrd) {
}
}
# If pkgdir provided no http mirror, fall back to site.ubuntu_apt_mirror -- the same knob the
# Subiquity diskful install uses (Template.pm::ubuntu_subiquity_apt_mirror). The Ubuntu
# live-server ISO that copycds imports is NOT a complete apt mirror, so debootstrap needs a
# real online/local mirror to build the netboot/statelite rootimg. The mirror is codename-
# independent (one URL serves all releases); the codename comes from the osimage's osvers.
# The parser below expects the entry as "<url> <codename>".
unless (@pkgdir_internet) {
# site.ubuntu_apt_mirror overrides; otherwise default to the public archive. A live-server
# ISO is never a complete debootstrap source, so a real mirror is always required here.
my @aptmirror = xCAT::TableUtils->get_site_attribute("ubuntu_apt_mirror");
my $mirror = (defined $aptmirror[0] && length $aptmirror[0])
? $aptmirror[0] : 'http://archive.ubuntu.com/ubuntu';
(my $codename = $osver) =~ s/^ubuntu//;
$codename =~ s/\.\d+$//; # 24.04.4 -> 24.04
my %cn = ('24.04' => 'noble', '22.04' => 'jammy', '20.04' => 'focal',
'18.04' => 'bionic', '26.04' => 'resolute');
$codename = $cn{$codename} if exists $cn{$codename};
# "<url> <suite> <components>": debootstrap consumes only url+suite of the FIRST entry
# (ignores the rest); every entry becomes a line in the chroot's sources.list. The compute
# pkglist pulls from main + universe (busybox-static, dracut*), and needs the -updates /
# -security pockets too -- e.g. openssh-server depends on a security-updated openssh-client
# absent from the base release pocket. archive.ubuntu.com (and standard mirrors) serve all
# three pockets from the one base URL.
foreach my $pocket ($codename, "$codename-updates", "$codename-security") {
push @pkgdir_internet, "$mirror $pocket main universe";
}
print "genimage: pkgdir has no http mirror; using '$mirror' [$codename {,-updates,-security} main universe] (site.ubuntu_apt_mirror or default)\n";
}
# Add the dir for kernel deb to be installed
if ($kernelver) {
find(\&isaptdir, <$kerneldir/>);