mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-02 00:41:42 +00:00
feat(openeuler): provision installed and diskless images
Add native compute and service profiles, installer dispatch and partition defaults. Use strict DNF image creation. Check stateless boot-file and archive publication. Preserve native image customizations on reimport. Restore missing image records during reimport.
This commit is contained in:
@@ -1295,6 +1295,7 @@ sub getImageitems_for_node
|
||||
elsif ($os =~ /sles.*/) { $platform = "sles"; }
|
||||
elsif ($os =~ /ubuntu.*/) { $platform = "ubuntu"; }
|
||||
elsif ($os =~ /debian.*/) { $platform = "debian"; }
|
||||
elsif ($os =~ /^openeuler/) { $platform = "openeuler"; }
|
||||
elsif ($os =~ /aix.*/) { $platform = "aix"; }
|
||||
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
|
||||
}
|
||||
|
||||
@@ -916,8 +916,6 @@ sub update_tables_with_templates
|
||||
}
|
||||
}
|
||||
|
||||
# if ($found) { next; }
|
||||
|
||||
my $imagename = $osver . "-" . $arch . "-install-" . $profile;
|
||||
|
||||
#TODO: check if there happen to be a row that has the same imagename but with different contents
|
||||
@@ -941,7 +939,9 @@ sub update_tables_with_templates
|
||||
if ($args{description}) {
|
||||
$tb_cols{description} = $args{description};
|
||||
}
|
||||
$osimagetab->setAttribs(\%key_col, \%tb_cols);
|
||||
$osimagetab->setAttribs(\%key_col, \%tb_cols)
|
||||
unless $osver =~ /^openeuler/
|
||||
&& $osimagetab->getAttribs(\%key_col, 'imagename');
|
||||
|
||||
if ($osname =~ /^win/) {
|
||||
if (!$winimagetab) { $winimagetab = xCAT::Table->new('winimage', -create => 1); }
|
||||
@@ -964,7 +964,9 @@ sub update_tables_with_templates
|
||||
_apply_new_linuximage_defaults(
|
||||
$linuximagetab, $imagename, \%tb_cols);
|
||||
|
||||
$linuximagetab->setAttribs(\%key_col, \%tb_cols);
|
||||
$linuximagetab->setAttribs(\%key_col, \%tb_cols)
|
||||
unless $osver =~ /^openeuler/
|
||||
&& $linuximagetab->getAttribs(\%key_col, 'imagename');
|
||||
|
||||
} else {
|
||||
return (1, "Cannot open the linuximage table.");
|
||||
@@ -1352,7 +1354,6 @@ sub update_tables_with_diskless_image
|
||||
}
|
||||
if ($found) {
|
||||
print "The image is already in the db.\n";
|
||||
|
||||
# next;
|
||||
}
|
||||
|
||||
@@ -1369,7 +1370,9 @@ sub update_tables_with_diskless_image
|
||||
osarch => $arch,
|
||||
synclists => $synclistfile,
|
||||
osdistroname => $osdistroname);
|
||||
$osimagetab->setAttribs(\%key_col, \%tb_cols);
|
||||
$osimagetab->setAttribs(\%key_col, \%tb_cols)
|
||||
unless $osver =~ /^openeuler/
|
||||
&& $osimagetab->getAttribs(\%key_col, 'imagename');
|
||||
|
||||
if ($osname !~ /^win/) {
|
||||
if (!$linuximagetab) { $linuximagetab = xCAT::Table->new('linuximage', -create => 1); }
|
||||
@@ -1384,7 +1387,9 @@ sub update_tables_with_diskless_image
|
||||
rootimgdir => "$installroot/netboot/$osver/$arch/$profile");
|
||||
_apply_new_linuximage_defaults(
|
||||
$linuximagetab, $imagename, \%tb_cols);
|
||||
$linuximagetab->setAttribs(\%key_col, \%tb_cols);
|
||||
$linuximagetab->setAttribs(\%key_col, \%tb_cols)
|
||||
unless $osver =~ /^openeuler/
|
||||
&& $linuximagetab->getAttribs(\%key_col, 'imagename');
|
||||
|
||||
} else {
|
||||
return (1, "Cannot open the linuximage table.");
|
||||
|
||||
@@ -384,7 +384,7 @@ sub subvars {
|
||||
$inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg;
|
||||
$inc =~ s/#CRYPTORLOCKED:([^:]+):([^:]+):([^#]+)#/crydb_or_locked($1,$2,$3)/eg;
|
||||
$inc =~ s/#COMMAND:([^#]+)#/command($1)/eg;
|
||||
$inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg;
|
||||
$inc =~ s/#KICKSTARTNET#/kickstartnetwork($platform)/eg;
|
||||
$inc =~ s/#MIRRORSPEC#/mirrorspec()/eg;
|
||||
$inc =~ s/#YAST2NET#/yast2network()/eg;
|
||||
$inc =~ s/#KICKSTARTBOOTLOADER#/kickstartbootloader()/eg;
|
||||
@@ -1046,6 +1046,7 @@ sub esxipv6setup {
|
||||
|
||||
|
||||
sub kickstartnetwork {
|
||||
my $platform = shift;
|
||||
my $line = "network --onboot=yes --bootproto=";
|
||||
my $hoststab;
|
||||
my $mactab = xCAT::Table->new('mac', -create => 0);
|
||||
@@ -1108,6 +1109,7 @@ sub kickstartnetwork {
|
||||
#return "#KSNET static unsupported";
|
||||
} else {
|
||||
$line .= "dhcp --device=$suffix";
|
||||
$line .= " --hostname=$node" if (defined($platform) && $platform eq 'openeuler');
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ sub _set_driver_disk_marker
|
||||
|
||||
sub _driver_disk_kernel_arg
|
||||
{
|
||||
my ($kversion, $initrd) = @_;
|
||||
my ($kversion, $initrd, $modern_installer) = @_;
|
||||
my $marker = _driver_disk_marker_path($initrd);
|
||||
|
||||
return '' unless defined($marker) && -f $initrd && -f $marker;
|
||||
return '' if xCAT::Utils->version_cmp($kversion, "7.0") < 0;
|
||||
return '' unless $modern_installer || xCAT::Utils->version_cmp($kversion, "7.0") >= 0;
|
||||
return " inst.dd=/dd.img";
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ sub handled_commands
|
||||
{
|
||||
return {
|
||||
copycd => "anaconda",
|
||||
mknetboot => "nodetype:os=(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh.*)|(fedora.*)|(SL.*)",
|
||||
mkinstall => "nodetype:os=(pkvm.*)|(esxi4.1)|(esx[34].*)|(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh(?!evh).*)|(fedora.*)|(SL.*)",
|
||||
mknetboot => "nodetype:os=(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh.*)|(fedora.*)|(SL.*)|(openeuler.*)",
|
||||
mkinstall => "nodetype:os=(pkvm.*)|(esxi4.1)|(esx[34].*)|(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh(?!evh).*)|(fedora.*)|(SL.*)|(openeuler.*)",
|
||||
mksysclone => "nodetype:os=(esxi4.1)|(esx[34].*)|(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh(?!evh).*)|(fedora.*)|(SL.*)",
|
||||
mkstatelite => "nodetype:os=(esx[34].*)|(^ol[0-9].*)|(centos.*)|(alma.*)|(rocky.*)|(rh.*)|(fedora.*)|(SL.*)",
|
||||
|
||||
@@ -1508,10 +1508,12 @@ sub mkinstall
|
||||
my $kversion = $os;
|
||||
$kversion =~ s/^\D*([\.0-9]+)/$1/;
|
||||
$kversion =~ s/\.$//;
|
||||
my $modern_installer = $os =~ /^openeuler/
|
||||
|| xCAT::Utils->version_cmp($kversion, "7.0") >= 0;
|
||||
if ($pkvm) {
|
||||
$kcmdline = "ksdevice=bootif kssendmac text selinux=0 rd.dm=0 rd.md=0 repo=$httpmethod://$instserver:$httpport$httpprefix/packages/ kvmp.inst.auto=$httpmethod://$instserver:$httpport/install/autoinst/$node root=live:$httpmethod://$instserver:$httpport$httpprefix/LiveOS/squashfs.img";
|
||||
} else {
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") < 0) {
|
||||
if (!$modern_installer) {
|
||||
$kcmdline = "repo=$httpmethod://$instserver:$httpport$httpprefix ks=$httpmethod://"
|
||||
. $instserver . ":" . $httpport
|
||||
. "/install/autoinst/"
|
||||
@@ -1542,7 +1544,7 @@ sub mkinstall
|
||||
|
||||
my $nicname = $net_params->{nicname};
|
||||
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") < 0) {
|
||||
if (!$modern_installer) {
|
||||
$kcmdline .= " $net_params->{ksdevice} ";
|
||||
} elsif ($arch =~ /ppc/) {
|
||||
$kcmdline .= " $net_params->{BOOTIF} ";
|
||||
@@ -1562,7 +1564,7 @@ sub mkinstall
|
||||
unless ($gatewayd[0]) { $gateway = $gatewayd[1]; }
|
||||
}
|
||||
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") < 0) {
|
||||
if (!$modern_installer) {
|
||||
$kcmdline .= " ip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname ";
|
||||
} else {
|
||||
$kcmdline .= " ip=$ipaddr" . "::" . "$gateway" . ":" . "$netmask" . ":" . "$hostname" . ":";
|
||||
@@ -1593,7 +1595,7 @@ sub mkinstall
|
||||
}
|
||||
|
||||
if (scalar @nameserversIP) {
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") < 0) {
|
||||
if (!$modern_installer) {
|
||||
$kcmdline .= " dns=" . join(",", @nameserversIP);
|
||||
} else {
|
||||
foreach (@nameserversIP) {
|
||||
@@ -1602,7 +1604,7 @@ sub mkinstall
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") >= 0) {
|
||||
if ($modern_installer) {
|
||||
$kcmdline .= " $net_params->{ip} ";
|
||||
}
|
||||
}
|
||||
@@ -1613,7 +1615,7 @@ sub mkinstall
|
||||
$instserver = $ip;
|
||||
}
|
||||
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") >= 0) {
|
||||
if ($modern_installer) {
|
||||
if ($::XCATSITEVALS{xcatdebugmode} eq "2") {
|
||||
|
||||
#enable ssh access during installation
|
||||
@@ -1637,7 +1639,7 @@ sub mkinstall
|
||||
|
||||
|
||||
$kcmdline .= _driver_disk_kernel_arg(
|
||||
$kversion, "$tftppath/initrd.img"
|
||||
$kversion, "$tftppath/initrd.img", $modern_installer
|
||||
);
|
||||
if (defined($sent->{serialport})) {
|
||||
unless ($sent->{serialspeed}) {
|
||||
@@ -1646,7 +1648,7 @@ sub mkinstall
|
||||
}
|
||||
|
||||
#go cmdline if serial console is requested, the shiny ansi is just impractical
|
||||
if (xCAT::Utils->version_cmp($kversion, "7.0") < 0) {
|
||||
if (!$modern_installer) {
|
||||
$kcmdline .= " cmdline ";
|
||||
} else {
|
||||
$kcmdline .= " inst.cmdline ";
|
||||
|
||||
@@ -166,6 +166,10 @@ sub process_request {
|
||||
$callback->({ error => ["\'$imagename\' cannot be used to build diskless image. Make sure osimage.provmethod is 'netboot'."], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
if ($osver =~ /^openeuler/ && $provmethod eq 'statelite') {
|
||||
$callback->({ error => ['openEuler StateLite images are not supported.'], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
|
||||
unless ($ref_linuximage_tab->{'pkglist'}) {
|
||||
$callback->({ error => ["A .pkglist file must be specified for image \'$imagename\' in the linuximage table."], errorcode => [1] });
|
||||
@@ -289,6 +293,14 @@ sub process_request {
|
||||
if ($osver =~ /^leap15/) {
|
||||
$osfamily = "sles";
|
||||
}
|
||||
if ($osver =~ /^openeuler/) {
|
||||
unless (defined(xCAT::Utils::normalize_openeuler_version(substr($osver, 9)))
|
||||
&& $arch =~ /^(?:x86_64|ppc64le)$/) {
|
||||
$callback->({ error => ["Unsupported openEuler release or architecture: $osver $arch"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
$osfamily = 'openeuler';
|
||||
}
|
||||
|
||||
$osfamily =~ s/ //g;
|
||||
|
||||
|
||||
@@ -191,6 +191,22 @@ sub process_request {
|
||||
}
|
||||
$rootimg_dir = "$destdir/rootimg";
|
||||
|
||||
my $is_openeuler = $osver =~ /^openeuler/;
|
||||
if ($is_openeuler) {
|
||||
unless (defined(xCAT::Utils::normalize_openeuler_version(substr($osver, 9)))
|
||||
&& $arch =~ /^(?:x86_64|ppc64le)$/) {
|
||||
$callback->({ error => ["Unsupported openEuler image release or architecture: $osver $arch"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
if (-f "$rootimg_dir/.statelite/litefile.save") {
|
||||
$callback->({ error => ["openEuler StateLite images are not supported"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
unless (-d $rootimg_dir) {
|
||||
$callback->({ error => ["$rootimg_dir does not exist; run genimage first"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $retcode;
|
||||
($retcode,$lock)=xCAT::Utils->acquire_lock_imageop($rootimg_dir);
|
||||
@@ -241,15 +257,13 @@ sub process_request {
|
||||
my $rootimg_status = 0; # 0 means stateless mode, while 1 means statelite mode
|
||||
$rootimg_status = 1 if (-f "$rootimg_dir/.statelite/litefile.save");
|
||||
|
||||
my $ref_liteList; # get the litefile entries
|
||||
|
||||
my @ret = xCAT::Utils->runcmd("ilitefile $osver-$arch-statelite-$profile", 0, 1);
|
||||
$ref_liteList = $ret[0];
|
||||
|
||||
my %liteHash; # create hash table for the entries in @listList
|
||||
if (parseLiteFiles($ref_liteList, \%liteHash)) {
|
||||
$callback->({ error => ["Failed for parsing litefile table!"], errorcode => [1] });
|
||||
return 1;
|
||||
unless ($is_openeuler) {
|
||||
my @ret = xCAT::Utils->runcmd("ilitefile $osver-$arch-statelite-$profile", 0, 1);
|
||||
if (parseLiteFiles($ret[0], \%liteHash)) {
|
||||
$callback->({ error => ["Failed for parsing litefile table!"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$verbose && $callback->({ data => [ "rootimg_status = $rootimg_status at line " . __LINE__ ] });
|
||||
@@ -287,26 +301,28 @@ sub process_request {
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: following the old genimage code, to update the stateles-only files/directories
|
||||
# # another file should be /opt/xcat/xcatdsklspost, but it seems not necessary
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/etc/init.d/statelite $rootimg_dir/.statebackup/statelite ", 0, 1) if (-e "$rootimg_dir/etc/init.d/statelite");
|
||||
if (-e "$rootimg_dir/usr/share/dracut") {
|
||||
unless ($is_openeuler) {
|
||||
# TODO: following the old genimage code, to update the stateles-only files/directories
|
||||
# # another file should be /opt/xcat/xcatdsklspost, but it seems not necessary
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/etc/init.d/statelite $rootimg_dir/.statebackup/statelite ", 0, 1) if (-e "$rootimg_dir/etc/init.d/statelite");
|
||||
if (-e "$rootimg_dir/usr/share/dracut") {
|
||||
|
||||
# currently only used for redhat families, not available for SuSE families
|
||||
if (-e "$rootimg_dir/etc/rc.sysinit.backup") {
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/etc/rc.sysinit.backup $rootimg_dir/etc/rc.sysinit", 0, 1);
|
||||
# currently only used for redhat families, not available for SuSE families
|
||||
if (-e "$rootimg_dir/etc/rc.sysinit.backup") {
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/etc/rc.sysinit.backup $rootimg_dir/etc/rc.sysinit", 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#restore the install.netboot of xcat dracut module
|
||||
if (-e "$rootimg_dir/usr/lib/dracut/modules.d/97xcat/install") {
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/usr/lib/dracut/modules.d/97xcat/install $rootimg_dir/.statebackup/install", 0, 1);
|
||||
#restore the install.netboot of xcat dracut module
|
||||
if (-e "$rootimg_dir/usr/lib/dracut/modules.d/97xcat/install") {
|
||||
xCAT::Utils->runcmd("mv $rootimg_dir/usr/lib/dracut/modules.d/97xcat/install $rootimg_dir/.statebackup/install", 0, 1);
|
||||
}
|
||||
my $dracut_install = "$::XCATROOT/share/xcat/netboot/$distname/dracut_033/install.netboot";
|
||||
if (!-r $dracut_install) {
|
||||
$dracut_install = "$::XCATROOT/share/xcat/netboot/rh/dracut_033/install.netboot";
|
||||
}
|
||||
xCAT::Utils->runcmd("cp $dracut_install $rootimg_dir/usr/lib/dracut/modules.d/97xcat/install", 0, 1);
|
||||
}
|
||||
my $dracut_install = "$::XCATROOT/share/xcat/netboot/$distname/dracut_033/install.netboot";
|
||||
if (!-r $dracut_install) {
|
||||
$dracut_install = "$::XCATROOT/share/xcat/netboot/rh/dracut_033/install.netboot";
|
||||
}
|
||||
xCAT::Utils->runcmd("cp $dracut_install $rootimg_dir/usr/lib/dracut/modules.d/97xcat/install", 0, 1);
|
||||
|
||||
|
||||
# timedatectl requires /etc/localtime link to the zoneinfo in /usr/share/zoneinfo
|
||||
@@ -321,7 +337,8 @@ sub process_request {
|
||||
$callback->({ info => ["No timezone defined in site table, skipping timezone /etc/localtime configuration"] });
|
||||
}
|
||||
|
||||
my $xcat_packimg_tmpfile = "/tmp/xcat_packimg.$$";
|
||||
my $native_filelist = $is_openeuler ? File::Temp->new(TMPDIR => 1, UNLINK => 1) : undef;
|
||||
my $xcat_packimg_tmpfile = $is_openeuler ? "$native_filelist" : "/tmp/xcat_packimg.$$";
|
||||
my $excludestr = "find . -xdev ";
|
||||
my $includestr;
|
||||
if ($exlistloc) {
|
||||
@@ -383,6 +400,8 @@ sub process_request {
|
||||
|
||||
# the files specified for statelite should be excluded
|
||||
my @excludeStatelite = ("./etc/init.d/statelite", "./etc/rc.sysinit.backup", "./.statelite*", "./.default*", "./.statebackup*");
|
||||
push @excludeStatelite, './etc/rc.d/init.d/statelite', './etc/rc.d/init.d/localdisk',
|
||||
'./etc/init.d/localdisk', './.sllocal*' if $is_openeuler;
|
||||
foreach my $entry (@excludeStatelite) {
|
||||
$excludestr .= "'!' -path '" . $entry . "' -a ";
|
||||
}
|
||||
@@ -453,6 +472,14 @@ sub process_request {
|
||||
|
||||
my $temppath;
|
||||
my $oldmask;
|
||||
my $native_failure = sub {
|
||||
my $message = shift;
|
||||
$callback->({ error => [$message], errorcode => [1] });
|
||||
chdir($oldpath);
|
||||
umask($oldmask) if defined($oldmask);
|
||||
rmtree($temppath) if defined($temppath) && -d $temppath;
|
||||
return 1;
|
||||
};
|
||||
unless (-d $rootimg_dir) {
|
||||
$callback->({ error => ["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"], errorcode => [1] });
|
||||
return 1;
|
||||
@@ -512,18 +539,42 @@ sub process_request {
|
||||
}
|
||||
|
||||
$suffix = $method.".".$suffix;
|
||||
unlink glob("$destdir/rootimg.*");
|
||||
unlink glob("$destdir/rootimg.*") unless $is_openeuler;
|
||||
my $native_archive = $is_openeuler
|
||||
? File::Temp->new(DIR => $destdir, TEMPLATE => '.packimage-XXXXXXXX', UNLINK => 1) : undef;
|
||||
my $archive_output = "../rootimg.$suffix";
|
||||
if ($is_openeuler) {
|
||||
$archive_output = "$native_archive";
|
||||
$archive_output =~ s/'/'\\''/g;
|
||||
$archive_output = "'$archive_output'";
|
||||
chdir($rootimg_dir) or return $native_failure->("Cannot enter $rootimg_dir: $!");
|
||||
my ($rc, $output) = native_pack_command("$excludestr > $xcat_packimg_tmpfile");
|
||||
return $native_failure->("Cannot enumerate $rootimg_dir: $output") if $rc;
|
||||
if ($includestr) {
|
||||
($rc, $output) = native_pack_command("$includestr >> $xcat_packimg_tmpfile");
|
||||
return $native_failure->("Cannot enumerate included files: $output") if $rc;
|
||||
}
|
||||
}
|
||||
my $publish_native_archive = sub {
|
||||
my $target = $method eq 'squashfs' ? "$destdir/rootimg.sfs" : "$destdir/rootimg.$suffix";
|
||||
unless (-s "$native_archive" && chmod(0644, "$native_archive")
|
||||
&& rename("$native_archive", $target)) {
|
||||
return $native_failure->("Cannot publish $target: $!");
|
||||
}
|
||||
unlink grep { $_ ne $target } glob("$destdir/rootimg.*");
|
||||
return 0;
|
||||
};
|
||||
|
||||
if ($method =~ /cpio/) {
|
||||
if (!$excludestr) {
|
||||
$excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix";
|
||||
$excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > $archive_output";
|
||||
} else {
|
||||
chdir("$rootimg_dir");
|
||||
system("$excludestr >> $xcat_packimg_tmpfile");
|
||||
if ($includestr) {
|
||||
system("$excludestr >> $xcat_packimg_tmpfile") unless $is_openeuler;
|
||||
if ($includestr && !$is_openeuler) {
|
||||
system("$includestr >> $xcat_packimg_tmpfile");
|
||||
}
|
||||
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.$suffix";
|
||||
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > $archive_output";
|
||||
}
|
||||
$oldmask = umask 0077;
|
||||
} elsif ($method =~ /tar/) {
|
||||
@@ -537,36 +588,44 @@ sub process_request {
|
||||
$option .= "--selinux ";
|
||||
}
|
||||
if (!$excludestr) {
|
||||
$excludestr = "find . -xdev -print0 | tar $option --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix";
|
||||
$excludestr = "find . -xdev -print0 | tar $option --no-recursion --use-compress-program=$compress --null -T - -cf $archive_output";
|
||||
} else {
|
||||
chdir("$rootimg_dir");
|
||||
system("$excludestr >> $xcat_packimg_tmpfile");
|
||||
if ($includestr) {
|
||||
system("$excludestr >> $xcat_packimg_tmpfile") unless $is_openeuler;
|
||||
if ($includestr && !$is_openeuler) {
|
||||
system("$includestr >> $xcat_packimg_tmpfile");
|
||||
}
|
||||
$excludestr = "cat $xcat_packimg_tmpfile| tar $option --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix";
|
||||
$excludestr = "cat $xcat_packimg_tmpfile| tar $option --no-recursion --use-compress-program=$compress -T - -cf $archive_output";
|
||||
}
|
||||
$oldmask = umask 0077;
|
||||
} elsif ($method =~ /squashfs/) {
|
||||
$temppath = mkdtemp("/tmp/packimage.$$.XXXXXXXX");
|
||||
chmod 0755, $temppath;
|
||||
chdir("$rootimg_dir");
|
||||
system("$excludestr >> $xcat_packimg_tmpfile");
|
||||
if ($includestr) {
|
||||
system("$excludestr >> $xcat_packimg_tmpfile") unless $is_openeuler;
|
||||
if ($includestr && !$is_openeuler) {
|
||||
system("$includestr >> $xcat_packimg_tmpfile");
|
||||
}
|
||||
$excludestr = "cat $xcat_packimg_tmpfile|cpio -dump $temppath";
|
||||
}
|
||||
chdir("$rootimg_dir");
|
||||
my $outputmsg = `$excludestr 2>&1`;
|
||||
unless($?){
|
||||
my ($archive_rc, $outputmsg);
|
||||
if ($is_openeuler) {
|
||||
($archive_rc, $outputmsg) = native_pack_command($excludestr);
|
||||
} else {
|
||||
$outputmsg = `$excludestr 2>&1`;
|
||||
$archive_rc = $?;
|
||||
}
|
||||
unless($archive_rc){
|
||||
$callback->({ info => ["$outputmsg"] });
|
||||
}else{
|
||||
$callback->({ info => ["$outputmsg"] });
|
||||
return $native_failure->("packimage failed while running: \n $excludestr") if $is_openeuler;
|
||||
$callback->({ error => ["packimage failed while running: \n $excludestr"], errorcode => [1] });
|
||||
system("rm -rf $xcat_packimg_tmpfile");
|
||||
return 1;
|
||||
}
|
||||
return 1 if $is_openeuler && $method ne 'squashfs' && $publish_native_archive->();
|
||||
|
||||
if ($method =~ /cpio/) {
|
||||
chmod 0644, "$destdir/rootimg.$suffix";
|
||||
@@ -593,6 +652,7 @@ sub process_request {
|
||||
}
|
||||
|
||||
if (!-x "/sbin/mksquashfs" && !-x "/usr/bin/mksquashfs") {
|
||||
return $native_failure->("mksquashfs not found; install squashfs-tools") if $is_openeuler;
|
||||
if ($osver =~ /sle/) {
|
||||
$callback->({ error => ["mksquashfs not found, squashfs rpm should be installed on the management node"], errorcode => [1] });
|
||||
} else {
|
||||
@@ -600,18 +660,23 @@ sub process_request {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
my $mksquashfs_command = "mksquashfs $temppath ../rootimg.sfs $flags";
|
||||
my $squashfs_output = $is_openeuler ? $archive_output : '../rootimg.sfs';
|
||||
$flags .= ' -noappend' if $is_openeuler;
|
||||
my $mksquashfs_command = "mksquashfs $temppath $squashfs_output $flags";
|
||||
xCAT::Utils->runcmd($mksquashfs_command, 0, 1);
|
||||
my $rc = $::RUNCMD_RC;
|
||||
if ($rc) {
|
||||
return $native_failure->("Command \"$mksquashfs_command\" failed") if $is_openeuler;
|
||||
$callback->({ error => ["Command \"$mksquashfs_command\" failed"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
$rc = system("rm -rf $temppath");
|
||||
if ($rc) {
|
||||
return $native_failure->("Failed to clean up temp space") if $is_openeuler;
|
||||
$callback->({ error => ["Failed to clean up temp space"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
return 1 if $is_openeuler && $publish_native_archive->();
|
||||
chmod(0644, "../rootimg.sfs");
|
||||
}
|
||||
system("rm -f $xcat_packimg_tmpfile");
|
||||
@@ -635,7 +700,17 @@ sub process_request {
|
||||
}
|
||||
|
||||
|
||||
chdir($oldpath);
|
||||
my $restored = chdir($oldpath);
|
||||
return $is_openeuler ? 0 : $restored;
|
||||
}
|
||||
|
||||
sub native_pack_command {
|
||||
my ($command) = @_;
|
||||
open(my $pipe, '-|', '/bin/bash', '-o', 'pipefail', '-c', "{ $command; } 2>&1")
|
||||
or return (1, "Cannot execute archive command: $!");
|
||||
my $output = do { local $/; <$pipe> };
|
||||
close($pipe);
|
||||
return ($?, $output // '');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
@core
|
||||
kernel
|
||||
chrony
|
||||
NetworkManager
|
||||
net-tools
|
||||
nfs-utils
|
||||
openssh-server
|
||||
openssh-clients
|
||||
rsync
|
||||
util-linux
|
||||
wget
|
||||
python3
|
||||
tar
|
||||
bzip2
|
||||
perl
|
||||
@@ -0,0 +1,38 @@
|
||||
text
|
||||
%include /tmp/repos
|
||||
keyboard --vckeymap=us --xlayouts='us'
|
||||
lang en_US.UTF-8
|
||||
#KICKSTARTNET#
|
||||
rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
|
||||
firstboot --disable
|
||||
skipx
|
||||
timezone #TABLE:site:key=timezone:value# --utc
|
||||
zerombr
|
||||
clearpart --all --initlabel
|
||||
#XCAT_PARTITION_START#
|
||||
%include /tmp/partitionfile
|
||||
#XCAT_PARTITION_END#
|
||||
firewall --disable
|
||||
selinux --disable
|
||||
reboot
|
||||
|
||||
%packages
|
||||
#INCLUDE_DEFAULT_PKGLIST#
|
||||
%end
|
||||
|
||||
%pre --interpreter=/bin/bash --erroronfail
|
||||
{
|
||||
echo "Running Kickstart Pre-installation script..."
|
||||
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.openeuler#
|
||||
} &>>/tmp/pre-install.log
|
||||
%end
|
||||
|
||||
%post --interpreter=/bin/bash --erroronfail
|
||||
mkdir -p /var/log/xcat/
|
||||
cat /tmp/pre-install.log >>/var/log/xcat/xcat.log
|
||||
{
|
||||
echo "Running Kickstart Post-installation script..."
|
||||
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat.ng#
|
||||
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rhels8#
|
||||
} &>>/var/log/xcat/xcat.log
|
||||
%end
|
||||
@@ -0,0 +1,4 @@
|
||||
#INCLUDE:${XCATROOT}/share/xcat/install/openeuler/compute.openeuler.pkglist#
|
||||
openssl
|
||||
perl-DBD-MySQL
|
||||
perl-DBD-Pg
|
||||
@@ -0,0 +1 @@
|
||||
compute.openeuler.tmpl
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler20.03sp4/x86_64/xCATsn
|
||||
xcat/xcat-dep/openeuler20.03sp4/x86_64/goconserver
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler22.03sp4/x86_64/xCATsn
|
||||
xcat/xcat-dep/openeuler22.03sp4/x86_64/goconserver
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler24.03/ppc64le/xCATsn
|
||||
xcat/xcat-dep/openeuler24.03/ppc64le/goconserver
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler24.03sp1/x86_64/xCATsn
|
||||
xcat/xcat-dep/openeuler24.03sp1/x86_64/goconserver
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler24.03sp3/x86_64/xCATsn
|
||||
xcat/xcat-dep/openeuler24.03sp3/x86_64/goconserver
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
xcat/xcat-core/openeuler24.03sp4/x86_64/xCATsn
|
||||
xcat/xcat-dep/openeuler24.03sp4/x86_64/goconserver
|
||||
@@ -33,7 +33,7 @@ fi
|
||||
|
||||
# List of internal repos to be disabled
|
||||
|
||||
internet_repo_file_list="oracle-linux-ol8.repo oracle-linux-ol9.repo uek-ol8.repo uek-ol9.repo Rocky-AppStream.repo Rocky-BaseOS.repo Rocky-Extras.repo rocky.repo rocky-extras.repo CentOS-Base.repo centos.repo centos-addons.repo almalinux-ha.repo almalinux-nfv.repo almalinux-powertools.repo almalinux.repo almalinux-resilientstorage.repo almalinux-rt.repo"
|
||||
internet_repo_file_list="oracle-linux-ol8.repo oracle-linux-ol9.repo uek-ol8.repo uek-ol9.repo Rocky-AppStream.repo Rocky-BaseOS.repo Rocky-Extras.repo rocky.repo rocky-extras.repo CentOS-Base.repo centos.repo centos-addons.repo almalinux-ha.repo almalinux-nfv.repo almalinux-powertools.repo almalinux.repo almalinux-resilientstorage.repo almalinux-rt.repo openEuler.repo"
|
||||
|
||||
for repo_file in $internet_repo_file_list
|
||||
do
|
||||
|
||||
@@ -330,7 +330,7 @@ fi
|
||||
export OSVER="#TABLE:nodetype:THISNODE:os#"
|
||||
# Create the post init service as a hook to run PS and PBS, as well as status updating
|
||||
cat >/etc/systemd/system/xcatpostinit1.service <<'EOF'
|
||||
#INCLUDE:/install/postscripts/xcatpostinit1.service#
|
||||
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1.service#
|
||||
EOF
|
||||
|
||||
case "$XCATDEBUGMODE" in
|
||||
@@ -348,7 +348,7 @@ case "$XCATDEBUGMODE" in
|
||||
esac
|
||||
|
||||
cat >/opt/xcat/xcatpostinit1 <<'EOF'
|
||||
#INCLUDE:/install/postscripts/xcatpostinit1.install#
|
||||
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1.install#
|
||||
EOF
|
||||
chmod 0755 /opt/xcat/xcatpostinit1
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
XCAT_INSTALL_PYTHON=/usr/bin/python3
|
||||
XCAT_BIOSBOOT=1
|
||||
if [ "$(uname -m)" = ppc64le ]; then
|
||||
XCAT_BOOT_FSTYPE=ext4
|
||||
XCAT_ROOT_FSTYPE=ext4
|
||||
fi
|
||||
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.rhels8#
|
||||
@@ -142,11 +142,11 @@ case "$NODESTATUS" in
|
||||
"0"|"N"|"n")
|
||||
;;
|
||||
*)
|
||||
/tmp/baz.py "installstatus installing" &
|
||||
"${XCAT_INSTALL_PYTHON:-/usr/libexec/platform-python}" /tmp/baz.py "installstatus installing" &
|
||||
;;
|
||||
esac
|
||||
|
||||
/tmp/foo.py >/foo.log 2>&1 &
|
||||
"${XCAT_INSTALL_PYTHON:-/usr/libexec/platform-python}" /tmp/foo.py >/foo.log 2>&1 &
|
||||
|
||||
base64decode()
|
||||
{
|
||||
@@ -248,8 +248,8 @@ then
|
||||
instdisk="$(cat /tmp/xcat.install_disk)"
|
||||
fi
|
||||
|
||||
BOOTFSTYPE=xfs
|
||||
FSTYPE=xfs
|
||||
BOOTFSTYPE=${XCAT_BOOT_FSTYPE:-xfs}
|
||||
FSTYPE=${XCAT_ROOT_FSTYPE:-xfs}
|
||||
EFIFSTYPE=efi
|
||||
|
||||
#remove any exiting "xcatvg" VG to avoid fatal error
|
||||
@@ -264,7 +264,11 @@ case "$(uname -m)" in
|
||||
echo "part prepboot --fstype=prepboot --asprimary --ondisk=$instdisk --size=8" >>/tmp/partitionfile
|
||||
;;
|
||||
esac
|
||||
if [ `blockdev --getsz $instdisk` -gt 4294967295 ]; then
|
||||
if [ "${XCAT_BIOSBOOT:-0}" = "1" ]; then
|
||||
if [ "$(uname -m)" = x86_64 ] && [ ! -d /sys/firmware/efi ]; then
|
||||
echo "part biosboot --ondisk=$instdisk --size=1" >> /tmp/partitionfile
|
||||
fi
|
||||
elif [ `blockdev --getsz $instdisk` -gt 4294967295 ]; then
|
||||
echo "part biosboot --ondisk=$instdisk --size=1" >> /tmp/partitionfile
|
||||
fi
|
||||
if [ -d /sys/firmware/efi ]
|
||||
|
||||
@@ -31,6 +31,9 @@ sub rpm_installroot_command {
|
||||
$non_interactive ||= "";
|
||||
$dnf_available = -x "/usr/bin/dnf" unless defined($dnf_available);
|
||||
my $majorrel = el_major_version($osver);
|
||||
my $openeuler_release = openeuler_release_version($osver);
|
||||
die "Unsupported openEuler image release: $osver\n"
|
||||
if defined($osver) && $osver =~ /^openeuler/ && !defined($openeuler_release);
|
||||
my $pkgmgr = "yum";
|
||||
|
||||
# EL8 and newer are dnf-native. Keep yum as the fallback for legacy
|
||||
@@ -38,16 +41,55 @@ sub rpm_installroot_command {
|
||||
if (defined($majorrel) && $majorrel > 7 && $dnf_available) {
|
||||
$pkgmgr = "dnf";
|
||||
}
|
||||
if (defined($openeuler_release)) {
|
||||
die "openEuler image creation requires dnf\n" unless $dnf_available;
|
||||
$pkgmgr = "dnf";
|
||||
}
|
||||
|
||||
my $cmd = "$pkgmgr $non_interactive -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir/ --disablerepo=* ";
|
||||
if (defined($majorrel) && $majorrel > 7) {
|
||||
$cmd .= "--releasever=" . $majorrel . " ";
|
||||
$cmd .= "--setopt=module_platform_id=platform:el" . $majorrel . " ";
|
||||
}
|
||||
if (defined($openeuler_release)) {
|
||||
$cmd .= "--releasever=$openeuler_release --setopt=strict=1 '--setopt=*.skip_if_unavailable=False' '--setopt=*.gpgcheck=1' ";
|
||||
}
|
||||
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
sub openeuler_release_version {
|
||||
my $osver = shift;
|
||||
return undef unless defined($osver) && $osver =~ /^openeuler(.+)$/;
|
||||
my $release = xCAT::Utils::normalize_openeuler_version($1);
|
||||
return undef unless defined($release);
|
||||
$release =~ s/sp([0-9]+)$/LTS_SP$1/ or $release .= 'LTS';
|
||||
return $release;
|
||||
}
|
||||
|
||||
sub rpm_trusted_keys {
|
||||
open(my $rpm, '-|', 'rpm', '-qa', '--qf', "%{DESCRIPTION}\n", 'gpg-pubkey*')
|
||||
or die "Cannot read trusted RPM keys: $!\n";
|
||||
local $/;
|
||||
my $keys = <$rpm>;
|
||||
close($rpm) or die "Cannot read trusted RPM keys\n";
|
||||
die "No trusted RPM signing keys are installed\n" unless defined($keys) && length($keys);
|
||||
return $keys;
|
||||
}
|
||||
|
||||
sub rpm_repository_config {
|
||||
my ($osver, $id, $url, $gpgkey) = @_;
|
||||
my $config = "[$id]\nname=$id\nbaseurl=$url\n";
|
||||
if (defined(openeuler_release_version($osver))) {
|
||||
die "openEuler repositories require trusted RPM signing keys\n"
|
||||
unless defined($gpgkey) && length($gpgkey);
|
||||
$config .= "gpgcheck=1\ngpgkey=$gpgkey\nskip_if_unavailable=False\n\n";
|
||||
} else {
|
||||
$config .= "gpgcheck=0\nskip_if_unavailable=True\n\n";
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
sub varsubinline{
|
||||
my $line=shift;
|
||||
my $refvardict=shift;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
./boot*
|
||||
./tmp*
|
||||
./var/cache/dnf*
|
||||
./var/cache/yum*
|
||||
@@ -0,0 +1,33 @@
|
||||
@core
|
||||
kernel
|
||||
chrony
|
||||
NetworkManager
|
||||
net-tools
|
||||
nfs-utils
|
||||
openssh-server
|
||||
openssh-clients
|
||||
rsync
|
||||
tar
|
||||
util-linux
|
||||
wget
|
||||
python3
|
||||
bzip2
|
||||
bc
|
||||
dracut
|
||||
dracut-network
|
||||
rsyslog
|
||||
hostname
|
||||
e2fsprogs
|
||||
ethtool
|
||||
parted
|
||||
openssl
|
||||
dhcp
|
||||
bash
|
||||
vim-minimal
|
||||
rpm
|
||||
iputils
|
||||
perl
|
||||
curl
|
||||
kmod
|
||||
findutils
|
||||
which
|
||||
@@ -0,0 +1 @@
|
||||
../rh/compute.rhels9.x86_64.postinstall
|
||||
@@ -0,0 +1 @@
|
||||
../rh/dracut
|
||||
@@ -0,0 +1 @@
|
||||
../rh/dracut_033
|
||||
@@ -0,0 +1 @@
|
||||
../rh/dracut_047
|
||||
@@ -0,0 +1 @@
|
||||
../rh/dracut_105
|
||||
@@ -0,0 +1 @@
|
||||
../rh/genimage
|
||||
@@ -0,0 +1 @@
|
||||
compute.openeuler.exlist
|
||||
@@ -0,0 +1,3 @@
|
||||
#INCLUDE:${XCATROOT}/share/xcat/netboot/openeuler/compute.openeuler.pkglist#
|
||||
perl-DBD-MySQL
|
||||
perl-DBD-Pg
|
||||
@@ -0,0 +1 @@
|
||||
compute.openeuler.postinstall
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler20.03sp4.x86_64.otherpkgs.pkglist
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler22.03sp4.x86_64.otherpkgs.pkglist
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler24.03.ppc64le.otherpkgs.pkglist
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler24.03sp1.x86_64.otherpkgs.pkglist
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler24.03sp3.x86_64.otherpkgs.pkglist
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../install/openeuler/service.openeuler24.03sp4.x86_64.otherpkgs.pkglist
|
||||
@@ -112,7 +112,9 @@ elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
|
||||
xz -cd /rootimg.cpio.xz |cpio -idum
|
||||
fi
|
||||
fi
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
if [ -x "$NEWROOT/etc/init.d/localdisk" ]; then
|
||||
"$NEWROOT/etc/init.d/localdisk"
|
||||
fi
|
||||
[ "$xcatdebugmode" > "0" ] && logger -t $log_label -p local4.debug "Done extracting the root filesystem..."
|
||||
echo "Done extracting the root filesystem..."
|
||||
elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
|
||||
@@ -138,7 +140,9 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
|
||||
tar --selinux -Jxf /rootimg.tar.xz
|
||||
fi
|
||||
fi
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
if [ -x "$NEWROOT/etc/init.d/localdisk" ]; then
|
||||
"$NEWROOT/etc/init.d/localdisk"
|
||||
fi
|
||||
msg="Done extracting the root filesystem."
|
||||
[ "$xcatdebugmode" > "0" ] && logger -t $log_label -p local4.debug "$msg"
|
||||
echo "$msg"
|
||||
|
||||
@@ -15,7 +15,7 @@ use File::Copy qw/copy cp mv move/;
|
||||
use File::Find;
|
||||
use Getopt::Long;
|
||||
use Cwd qw(realpath);
|
||||
use File::Temp qw/mkdtemp/;
|
||||
use File::Temp qw/mkdtemp tempfile/;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../imgutils";
|
||||
use imgutils;
|
||||
@@ -70,14 +70,24 @@ my $ignorekernelchk;
|
||||
my $noupdate;
|
||||
my $lock;
|
||||
my $envar;
|
||||
my $native_bootdir;
|
||||
|
||||
|
||||
sub xdie {
|
||||
unlink("$rootimg_dir/tmp/initrd.$$.gz")
|
||||
if $rootimg_dir && defined(imgutils::openeuler_release_version($osver));
|
||||
system("rm -rf /tmp/xcatinitrd.$$");
|
||||
umount_chroot($rootimg_dir);
|
||||
die @_;
|
||||
}
|
||||
|
||||
sub check_package_result {
|
||||
my ($rc) = @_;
|
||||
return unless $rc && defined(imgutils::openeuler_release_version($osver));
|
||||
unuse_hackuname();
|
||||
xdie("RPM package manager invocation failed\n");
|
||||
}
|
||||
|
||||
|
||||
#helper subroutine to get the major release number
|
||||
#of a osver
|
||||
@@ -99,7 +109,7 @@ sub mount_chroot {
|
||||
#For Redhat7 or above, mount /proc,/sys from host to avoid error messages
|
||||
#For Redhat7 or above, create /dev according to /dev on the host to avoid error messages
|
||||
#For Redhat6 or below, mount these directories might introduce error messages
|
||||
if (majversion($osver) > 6) {
|
||||
if (defined(imgutils::openeuler_release_version($osver)) || majversion($osver) > 6) {
|
||||
system("mkdir -p $rootimage_dir/proc");
|
||||
system("mount proc $rootimage_dir/proc -t proc");
|
||||
system("mkdir -p $rootimage_dir/sys");
|
||||
@@ -143,7 +153,7 @@ sub umount_chroot {
|
||||
system("umount -l $mntpt >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
if (majversion($osver) > 6) {
|
||||
if (defined(imgutils::openeuler_release_version($osver)) || majversion($osver) > 6) {
|
||||
#only remove the /dev in rootimg directory if it is not a mount point
|
||||
system("findmnt $rootimage_dir/dev/ >/dev/null 2>&1 || rm -rf $rootimage_dir/dev/*");
|
||||
}
|
||||
@@ -290,6 +300,14 @@ if($onlyinitrd){
|
||||
print("the root image directory \"$rootimg_dir\"does not exist, please run \"genimage $imagename\" to generate the root image directory first!\n");
|
||||
exit 1;
|
||||
}
|
||||
if (defined(imgutils::openeuler_release_version($osver))) {
|
||||
my $retcode;
|
||||
($retcode, $lock) = xCAT::Utils->acquire_lock_imageop($rootimg_dir);
|
||||
if ($retcode) {
|
||||
print "Could not acquire image operation lock for $rootimg_dir\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
@yumdirs = ();
|
||||
@@ -343,12 +361,19 @@ if($onlyinitrd){
|
||||
}
|
||||
|
||||
my $repnum = 0;
|
||||
my $gpgkey;
|
||||
if (defined(imgutils::openeuler_release_version($osver))) {
|
||||
my ($keyfh, $keyfile) = tempfile('genimage-rpm-keys.XXXXXX', DIR => '/tmp', UNLINK => 1);
|
||||
print $keyfh imgutils::rpm_trusted_keys() or die "Cannot write RPM signing keys: $!\n";
|
||||
close($keyfh) or die "Cannot close RPM signing keys: $!\n";
|
||||
$gpgkey = "file://$keyfile";
|
||||
}
|
||||
foreach $srcdir (@yumdirs) {
|
||||
print $yumconfig "[$osver-$arch-$repnum]\nname=$osver-$arch-$repnum\nbaseurl=file://$srcdir\ngpgcheck=0\nskip_if_unavailable=True\n\n";
|
||||
print $yumconfig imgutils::rpm_repository_config($osver, "$osver-$arch-$repnum", "file://$srcdir", $gpgkey);
|
||||
$repnum += 1;
|
||||
}
|
||||
foreach $srcdir (@pkgdir_internet) {
|
||||
print $yumconfig "[$osver-$arch-$repnum]\nname=$osver-$arch-$repnum\nbaseurl=$srcdir\ngpgcheck=0\nskip_if_unavailable=True\n\n";
|
||||
print $yumconfig imgutils::rpm_repository_config($osver, "$osver-$arch-$repnum", $srcdir, $gpgkey);
|
||||
$repnum += 1;
|
||||
}
|
||||
$repnum -= 1;
|
||||
@@ -518,14 +543,16 @@ if($onlyinitrd){
|
||||
|
||||
if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
|
||||
foreach(@otherpkgdir_url){
|
||||
print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=$_\ngpgcheck=0\nskip_if_unavailable=True\n\n";
|
||||
print $yumconfig imgutils::rpm_repository_config($osver, "otherpkgs$index", $_, $gpgkey);
|
||||
$repohash{$pass}{$index} = 1;
|
||||
$index++;
|
||||
}
|
||||
|
||||
print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=file://$srcdir_otherpkgs_local/$_\ngpgcheck=0\nskip_if_unavailable=True\n\n";
|
||||
$repohash{$pass}{$index} = 1;
|
||||
$index++;
|
||||
if (defined($srcdir_otherpkgs_local) || !defined(imgutils::openeuler_release_version($osver))) {
|
||||
print $yumconfig imgutils::rpm_repository_config($osver, "otherpkgs$index", "file://$srcdir_otherpkgs_local/$_", $gpgkey);
|
||||
$repohash{$pass}{$index} = 1;
|
||||
$index++;
|
||||
}
|
||||
my $pa = $extra_hash{$pass}{$_};
|
||||
$extrapkgnames{$pass} .= " " . join(' ', @$pa);
|
||||
}
|
||||
@@ -571,6 +598,7 @@ if($onlyinitrd){
|
||||
if ($rm_packges) {
|
||||
print "$envlist $yumcmd_remove $rm_packges\n";
|
||||
$rc = system("$envlist $yumcmd_remove $rm_packges");
|
||||
check_package_result($rc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,6 +645,7 @@ if($onlyinitrd){
|
||||
if ($rm_packges) {
|
||||
print "$envlist $yumcmd_remove $rm_packges\n";
|
||||
$rc = system("$envlist $yumcmd_remove $rm_packges");
|
||||
check_package_result($rc);
|
||||
}
|
||||
}
|
||||
$yumcmd = $yumcmd_base;
|
||||
@@ -629,6 +658,7 @@ if($onlyinitrd){
|
||||
my $excludecmd = $kernelver ? " --exclude=kernel\*" : "";
|
||||
my $yumcmd_update = $yumcmd_base . $excludecmd . " update ";
|
||||
$rc = system("$yumcmd_update");
|
||||
check_package_result($rc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,17 +723,25 @@ chomp($kernelver);
|
||||
#$updates{'kernelver'} = $kernelver if ($tempfile);
|
||||
|
||||
# copy the kernel to $destdir
|
||||
my $kernel_output = "$destdir/kernel";
|
||||
if (defined(imgutils::openeuler_release_version($osver))) {
|
||||
$native_bootdir = File::Temp->newdir('.genimage-boot.XXXXXX', DIR => $destdir, CLEANUP => 1);
|
||||
$kernel_output = "$native_bootdir/kernel";
|
||||
}
|
||||
my $kernel_copy;
|
||||
if (-e "$rootimg_dir/boot/vmlinux-$kernelver") {
|
||||
cp("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/vmlinux-$kernelver", $kernel_output);
|
||||
} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") {
|
||||
cp("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/vmlinuz-$kernelver", $kernel_output);
|
||||
} elsif (-e "$rootimg_dir/boot/image-$kernelver") {
|
||||
cp("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/boot/image-$kernelver", $kernel_output);
|
||||
} elsif (-e "$rootimg_dir/lib/modules/$kernelver/vmlinuz") {
|
||||
cp("$rootimg_dir/lib/modules/$kernelver/vmlinuz", "$destdir/kernel");
|
||||
$kernel_copy = cp("$rootimg_dir/lib/modules/$kernelver/vmlinuz", $kernel_output);
|
||||
} else {
|
||||
xdie("couldn't find the kernel file matched $kernelver in $rootimg_dir/boot");
|
||||
}
|
||||
xdie("Error: failed to copy the kernel to $kernel_output: $!\n")
|
||||
if $native_bootdir && !$kernel_copy;
|
||||
|
||||
# Load driver update disk, and copy them to the root image
|
||||
my @dd_drivers = &load_dd();
|
||||
@@ -782,10 +820,12 @@ if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut"))
|
||||
}
|
||||
print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n";
|
||||
}
|
||||
xdie("Error: failed to generate the initial ramdisk: native image has no dracut installation\n")
|
||||
if $native_bootdir && !$dracutmode;
|
||||
|
||||
# List of internet repos to be disabled
|
||||
|
||||
my @internet_repo_file_list = ("oracle-linux-ol8.repo", "oracle-linux-ol9.repo", "oracle-linux-ol10.repo", "uek-ol8.repo", "uek-ol9.repo", "uek-ol10.repo", "Rocky-AppStream.repo", "Rocky-BaseOS.repo", "Rocky-Extras.repo", "rocky.repo", "rocky-extras.repo", "CentOS-Base.repo", "centos.repo", "centos-addons.repo", "almalinux-ha.repo", "almalinux-nfv.repo", "almalinux-plus.repo", "almalinux-powertools.repo", "almalinux.repo", "almalinux-resilientstorage.repo", "almalinux-rt.repo");
|
||||
my @internet_repo_file_list = ("oracle-linux-ol8.repo", "oracle-linux-ol9.repo", "oracle-linux-ol10.repo", "uek-ol8.repo", "uek-ol9.repo", "uek-ol10.repo", "Rocky-AppStream.repo", "Rocky-BaseOS.repo", "Rocky-Extras.repo", "rocky.repo", "rocky-extras.repo", "CentOS-Base.repo", "centos.repo", "centos-addons.repo", "almalinux-ha.repo", "almalinux-nfv.repo", "almalinux-plus.repo", "almalinux-powertools.repo", "almalinux.repo", "almalinux-resilientstorage.repo", "almalinux-rt.repo", "openEuler.repo");
|
||||
|
||||
foreach ( @internet_repo_file_list ) {
|
||||
if (-e "$rootimg_dir/etc/yum.repos.d/$_") {
|
||||
@@ -880,21 +920,23 @@ if ($tempfile) {
|
||||
print FILE join('::', @a) . "\n";
|
||||
print FILE "The output for table updates ends here\n";
|
||||
|
||||
# update the imagename for statelite
|
||||
$updates_os{'provmethod'} = 'statelite';
|
||||
print FILE "The output for table updates starts here\n";
|
||||
print FILE "table::osimage\n";
|
||||
print FILE "imagename::$osver-$arch-statelite-$profile\n";
|
||||
my @a = %updates_os;
|
||||
print FILE join('::', @a) . "\n";
|
||||
print FILE "The output for table updates ends here\n";
|
||||
unless (defined(imgutils::openeuler_release_version($osver))) {
|
||||
# update the imagename for statelite
|
||||
$updates_os{'provmethod'} = 'statelite';
|
||||
print FILE "The output for table updates starts here\n";
|
||||
print FILE "table::osimage\n";
|
||||
print FILE "imagename::$osver-$arch-statelite-$profile\n";
|
||||
my @a = %updates_os;
|
||||
print FILE join('::', @a) . "\n";
|
||||
print FILE "The output for table updates ends here\n";
|
||||
|
||||
print FILE "The output for table updates starts here\n";
|
||||
print FILE "table::linuximage\n";
|
||||
print FILE "imagename::$osver-$arch-statelite-$profile\n";
|
||||
my @a = %updates;
|
||||
print FILE join('::', @a) . "\n";
|
||||
print FILE "The output for table updates ends here\n";
|
||||
print FILE "The output for table updates starts here\n";
|
||||
print FILE "table::linuximage\n";
|
||||
print FILE "imagename::$osver-$arch-statelite-$profile\n";
|
||||
my @a = %updates;
|
||||
print FILE join('::', @a) . "\n";
|
||||
print FILE "The output for table updates ends here\n";
|
||||
}
|
||||
}
|
||||
close FILE;
|
||||
}
|
||||
@@ -905,22 +947,24 @@ if ($tempfile) {
|
||||
# statelite .statelite directory added here.
|
||||
# this is where tmpfs will be created.
|
||||
|
||||
mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts.
|
||||
mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount
|
||||
mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log
|
||||
unless (defined(imgutils::openeuler_release_version($osver))) {
|
||||
mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts.
|
||||
mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount
|
||||
mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log
|
||||
|
||||
# this script will get the directories.
|
||||
# TODO: the file is re-copied in liteimg.pm
|
||||
my $cwd = $FindBin::Bin;
|
||||
unless (-f "$cwd/../add-on/statelite/rc.statelite") {
|
||||
print "Can't find $cwd/../add-on/statelite/rc.statelite!\n";
|
||||
exit 1;
|
||||
# this script will get the directories.
|
||||
# TODO: the file is re-copied in liteimg.pm
|
||||
my $cwd = $FindBin::Bin;
|
||||
unless (-f "$cwd/../add-on/statelite/rc.statelite") {
|
||||
print "Can't find $cwd/../add-on/statelite/rc.statelite!\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
mkpath "$rootimg_dir/etc/init.d";
|
||||
system("cp $cwd/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
|
||||
system("cp $cwd/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
|
||||
}
|
||||
|
||||
mkpath "$rootimg_dir/etc/init.d";
|
||||
system("cp $cwd/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
|
||||
system("cp $cwd/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
|
||||
|
||||
# also need to add this file:
|
||||
# may have already been made into a symbolic link, if so ignore it
|
||||
|
||||
@@ -975,7 +1019,7 @@ system("chroot $rootimg_dir depmod $kernelver");
|
||||
|
||||
if ($dracutmode) {
|
||||
mkinitrd_dracut("stateless");
|
||||
mkinitrd_dracut("statelite");
|
||||
mkinitrd_dracut("statelite") unless defined(imgutils::openeuler_release_version($osver));
|
||||
} else {
|
||||
mkinitrd("statelite");
|
||||
mkinitrd("stateless");
|
||||
@@ -1166,7 +1210,9 @@ sub mkinitrd_dracut {
|
||||
#update etc/dracut.conf
|
||||
open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
|
||||
my $dracutmodulelist = "xcat nfs base network kernel-modules syslog";
|
||||
if (majversion($osver) >= 10) {
|
||||
if (defined(imgutils::openeuler_release_version($osver))
|
||||
? scalar(glob($dracutmoduledir . '[0-9]*network-manager'))
|
||||
: majversion($osver) >= 10) {
|
||||
$dracutmodulelist .= " network-manager";
|
||||
}
|
||||
|
||||
@@ -1211,7 +1257,9 @@ sub mkinitrd_dracut {
|
||||
chmod($perm & 07777, "$dracutmpath/installkernel");
|
||||
|
||||
my $dracutmodulelist = "xcat nfs base network kernel-modules syslog";
|
||||
if (majversion($osver) >= 10) {
|
||||
if (defined(imgutils::openeuler_release_version($osver))
|
||||
? scalar(glob($dracutmoduledir . '[0-9]*network-manager'))
|
||||
: majversion($osver) >= 10) {
|
||||
$dracutmodulelist .= " network-manager";
|
||||
}
|
||||
|
||||
@@ -1262,6 +1310,30 @@ sub mkinitrd_dracut {
|
||||
!system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
|
||||
or xdie("Error: failed to generate the initial ramdisk for $mode.\n");
|
||||
umount_chroot($rootimg_dir);
|
||||
if ($native_bootdir) {
|
||||
move("$rootimg_dir/tmp/initrd.$$.gz", "$native_bootdir/initrd-$mode.gz")
|
||||
or xdie("Error: failed to move the initial ramdisk for $mode: $!\n");
|
||||
my $old_kernel = -e "$destdir/kernel" || -l "$destdir/kernel";
|
||||
if ($old_kernel) {
|
||||
link("$destdir/kernel", "$native_bootdir/previous-kernel")
|
||||
or xdie("Error: failed to preserve the previous kernel: $!\n");
|
||||
}
|
||||
rename("$native_bootdir/kernel", "$destdir/kernel")
|
||||
or xdie("Error: failed to publish the kernel: $!\n");
|
||||
unless (rename("$native_bootdir/initrd-$mode.gz", "$destdir/initrd-$mode.gz")) {
|
||||
my $error = $!;
|
||||
my $restored = $old_kernel
|
||||
? rename("$native_bootdir/previous-kernel", "$destdir/kernel")
|
||||
: unlink("$destdir/kernel");
|
||||
unless ($restored) {
|
||||
$native_bootdir->unlink_on_destroy(0);
|
||||
xdie("Error: failed to publish the initial ramdisk: $error; kernel rollback failed: $!. Boot files retained in $native_bootdir\n");
|
||||
}
|
||||
xdie("Error: failed to publish the initial ramdisk for $mode: $error\n");
|
||||
}
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
return;
|
||||
}
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
print("Move $rootimg_dir/tmp/initrd.$$.gz -> $destdir/initrd-$mode.gz");
|
||||
move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
|
||||
@@ -2030,6 +2102,7 @@ sub postscripts {
|
||||
|
||||
sub using_systemd {
|
||||
my $os = shift;
|
||||
return 1 if defined(imgutils::openeuler_release_version($os));
|
||||
if ($os =~ /fedora(\d+)/) {
|
||||
if ($1 >= 15) {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user