2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-21 01:42:15 +00:00
Files
xcat-core/xCAT-genesis-base/lib/XCAT/GenesisBuildRoot.pm
T
Daniel Hilst c14d79790a fix(xcat-core): the Ubuntu Genesis image runs its awk programs under mawk
An Ubuntu compute node booted into legacy Genesis never reports a destiny. The console
shows doxcat reach "Getting initial certificate", then:

  awk: 8: unexpected character '&'
  awk: /usr/bin/allowcred.awk: line 14: syntax error at or near }

and the node stays in powering-on until the case times out. The payload built on
2026-10-23 carries /usr/bin/awk as a symlink to mawk, with no gawk.

allowcred.awk, minixcatd.awk and udpcat.awk open a TCP stream with the gawk |& coprocess
and the /inet/ special file. mawk rejects both at parse time. install() in
dracut_105/ubuntu/module-setup.sh staged /usr/bin/awk from the build root, and on Ubuntu
that alternative is mawk, so the image got an awk that cannot parse its own programs. The
EL payload is unaffected: there /usr/bin/awk is gawk.

install() now installs gawk by name and points usr/bin/awk at it, the build root carries
gawk, and XCAT::GenesisPayload reads usr/bin/awk back and refuses a payload whose awk is
not gawk. dracut_install reports a missing command and returns, and awk is a symlink the
module makes itself, so nothing in the build said why.

genesis_ubuntu_awk.bats, genesis_ubuntu_build_root.t and genesis_payload_verification.t
fail on the parent commit and pass on this one.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-24 10:04:15 -03:00

89 lines
3.1 KiB
Perl

package XCAT::GenesisBuildRoot;
# builddeb-genesis-base runs this module inside an Ubuntu build root, where only perl-base is
# installed. Use core modules only.
use strict;
use warnings;
use Exporter 'import';
our @EXPORT_OK = qw(required_packages apt_carries);
my @BASE_PACKAGES = qw(
dracut linux-image-generic
ipmitool lldpad ethtool iproute2 kexec-tools screen
openssh-server openssh-client rsyslog chrony
nfs-common rpcbind pciutils usbutils parted
dosfstools e2fsprogs lvm2 mdadm net-tools
bc psmisc rsync wget cpio gawk
isc-dhcp-client ifenslave
systemd-sysv hwdata btrfs-progs netcat-openbsd iputils-ping fdisk ncurses-term
dpkg-dev debhelper fakeroot devscripts vim-tiny
);
# Two commands the image needs changed package between releases: nslookup left dnsutils for
# bind9-dnsutils in 22.04, and hwclock left util-linux for util-linux-extra in 23.04.
my @RENAMED_PACKAGES = ([qw(bind9-dnsutils dnsutils)], [qw(util-linux-extra util-linux)]);
#-------------------------------------------------------------------------------
=head3 apt_carries
Descriptions: ask apt-cache whether the release carries a package.
Arguments:
$package: the package name
Returns:
1 when apt-cache knows the package, 0 when it does not
=cut
#-------------------------------------------------------------------------------
sub apt_carries {
my ($package) = @_;
return system('sh', '-c', 'apt-cache show "$1" >/dev/null 2>&1', 'sh', $package) == 0
? 1 : 0;
}
#-------------------------------------------------------------------------------
=head3 required_packages
Descriptions: list the packages the Genesis build root needs.
For a renamed package, apt says which name the release carries, so the list does
not branch on the codename. 26.04 moved the backward-compatibility zone names that
the dracut module installs out of tzdata into tzdata-legacy.
Arguments:
$arch: the dpkg architecture (amd64, ppc64el)
$codename: the release name, used in the error message
$carries: optional code ref. It takes a package name and returns true when the
release carries that package. The default is apt_carries.
Returns:
the package names, in install order.
Dies with "ERROR: <codename> carries none of these packages: ..." when the release
carries neither name of a renamed package.
=cut
#-------------------------------------------------------------------------------
sub required_packages {
my ($arch, $codename, $carries) = @_;
$carries ||= \&apt_carries;
my @packages = @BASE_PACKAGES;
push @packages, qw(dmidecode efibootmgr) if $arch eq 'amd64';
RENAMED:
for my $alternatives (@RENAMED_PACKAGES) {
for my $package (@$alternatives) {
if ($carries->($package)) {
push @packages, $package;
next RENAMED;
}
}
die "ERROR: $codename carries none of these packages: @$alternatives\n";
}
push @packages, 'tzdata-legacy' if $carries->('tzdata-legacy');
return @packages;
}
1;