mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
refactor(debian): map media architectures through a shared table
copycd translated the architecture the Ubuntu media reports with its own if/elsif chain, and genimage translates the same names back for debootstrap with another one. Neither can be reused, so a new architecture has to be added to both. Put both directions in xCAT::Utils and have copycd read from there. The names and the fallback do not change: media that xCAT has no name for still leave the architecture as the media reported it.
This commit is contained in:
@@ -4862,6 +4862,55 @@ sub splitkcmdline {
|
||||
}
|
||||
|
||||
|
||||
###################################################################################
|
||||
#subroutine debian_arch
|
||||
#Usage: give the Debian architecture name for an xCAT architecture. The media, the
|
||||
# package lists and debootstrap all use the Debian name.
|
||||
#Input Params:
|
||||
# $arch: the xCAT architecture, for example x86_64 or ppc64le
|
||||
#Return value:
|
||||
# the Debian architecture name, or the input when Debian names it the same
|
||||
###################################################################################
|
||||
# ppc64le is deliberately absent: the Ubuntu driver table, the NSS libraries and the
|
||||
# image paths all key on ppc64el, so translating it here alone would build an image
|
||||
# without network drivers instead of stopping at debootstrap.
|
||||
my %DEBIAN_ARCH = (
|
||||
'x86_64' => 'amd64',
|
||||
);
|
||||
|
||||
sub debian_arch {
|
||||
my $arch = shift;
|
||||
$arch = shift if ($arch =~ /xCAT::Utils/);
|
||||
return unless defined $arch;
|
||||
return $DEBIAN_ARCH{ lc $arch } // $arch;
|
||||
}
|
||||
|
||||
###################################################################################
|
||||
#subroutine xcat_arch_from_debian
|
||||
#Usage: give the xCAT architecture for the architecture the Ubuntu media reports.
|
||||
#Input Params:
|
||||
# $darch: the architecture from the media, for example amd64 or ppc64el
|
||||
#Return value:
|
||||
# the xCAT architecture, or undef when the media names one xCAT does not know
|
||||
###################################################################################
|
||||
my @XCAT_ARCH_FROM_DEBIAN = (
|
||||
[ qr/^i.86$/ => 'x86' ],
|
||||
[ qr/^ppc64el$/ => 'ppc64el' ],
|
||||
[ qr/ppc|powerpc/ => 'ppc64' ],
|
||||
[ qr/^amd64$/ => 'x86_64' ],
|
||||
);
|
||||
|
||||
sub xcat_arch_from_debian {
|
||||
my $darch = shift;
|
||||
$darch = shift if ($darch =~ /xCAT::Utils/);
|
||||
return unless defined $darch and $darch ne '';
|
||||
foreach my $rule (@XCAT_ARCH_FROM_DEBIAN) {
|
||||
my ($pattern, $arch) = @{$rule};
|
||||
return $arch if $darch =~ $pattern;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
###################################################################################
|
||||
#subroutine lookupNetboot
|
||||
#Usage: determine the possible noderes.netboot values of the osimage
|
||||
|
||||
@@ -368,22 +368,8 @@ sub copycd
|
||||
# So that I can use amd64 below
|
||||
my $debarch = $darch;
|
||||
|
||||
if ($darch and $darch =~ /i.86/)
|
||||
{
|
||||
$darch = "x86";
|
||||
}
|
||||
elsif ($darch and $darch =~ /ppc64el/)
|
||||
{
|
||||
$darch = "ppc64el";
|
||||
}
|
||||
elsif ($darch and ($darch =~ /ppc/ or $darch =~ /powerpc/))
|
||||
{
|
||||
$darch = "ppc64";
|
||||
}
|
||||
elsif ($darch and $darch =~ /amd64/)
|
||||
{
|
||||
$darch = "x86_64";
|
||||
}
|
||||
my $mapped = xCAT::Utils->xcat_arch_from_debian($darch);
|
||||
$darch = $mapped if $mapped;
|
||||
|
||||
if ($darch)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user