2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-08-03 10:07:36 +00:00

changes to support --noupdate flag on genimage

This commit is contained in:
Victor Hu
2014-11-06 16:58:19 -05:00
parent 0215a5bed2
commit b59f72bd8e
9 changed files with 166 additions and 132 deletions

View File

@@ -43,6 +43,7 @@ my $interactive;
my $onlyinitrd;
my $dryrun;
my $ignorekernelchk;
my $noupdate;
#-----------------------------------------------------------------------------
=head3 print_usage - usage message
@@ -55,8 +56,8 @@ sub print_usage
print "Usage:\n";
print " genimage\n\n";
print " genimage --dryrun\n\n";
print ' genimage -o <osver> [-a <arch>] -p <profile> -i <nodebootif> -n <nodenetdrivers> [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun]'."\n\n";
print ' genimage [-o <osver>] [-a <arch>] [-p <profile>] [-i <nodebootif>] [-n <nodenetdrivers>] [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun] <imagename>'."\n\n";
print ' genimage -o <osver> [-a <arch>] -p <profile> -i <nodebootif> -n <nodenetdrivers> [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun] [--noupdate]'."\n\n";
print ' genimage [-o <osver>] [-a <arch>] [-p <profile>] [-i <nodebootif>] [-n <nodenetdrivers>] [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun] [--noupdate] <imagename>'."\n\n";
print " --permission is used for statelite only\n";
print " -g is used for SLES only\n\n";
print " -m is used for urbuntu, debian and fedora12 only\n\n";
@@ -90,6 +91,7 @@ if (!GetOptions(
'onlyinitrd' => \$onlyinitrd,
'dryrun' => \$dryrun,
'ignorekernelchk' => \$ignorekernelchk,
'noupdate' => \$noupdate,
'h|help' => \$help,
'v|version' => \$version,
)) {
@@ -409,6 +411,10 @@ if ($ignorekernelchk) {
push @arg, "--ignorekernelchk";
}
if ($noupdate) {
push @arg, "--noupdate";
}
my $cmdref;
push (@{$cmdref->{arg}}, @arg);
$cmdref->{command}->[0] = "genimage";

View File

@@ -6,9 +6,9 @@ B<genimage> - Generates a stateless image to be used for a diskless install.
B<genimage>
B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] [B<--ignorekernelchk>] I<imagename>
B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] [B<--ignorekernelchk>] [B<--noupdate>] I<imagename>
B<genimage> B<-o> I<osver> [B<-a> I<arch>] B<-p> I<profile> B<-i> I<nodebootif> B<-n> I<nodenetdrivers> [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>]
B<genimage> B<-o> I<osver> [B<-a> I<arch>] B<-p> I<profile> B<-i> I<nodebootif> B<-n> I<nodenetdrivers> [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] [B<--noupdate>]
B<genimage> [B<-h> | B<--help> | B<-v> | B<--version>]
@@ -154,6 +154,10 @@ This flag shows the underlying call to the os specific genimage function. The us
Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel.
=item B<--noupdate>
This flag allows the user to bypass automatic package updating when installing other packages.
=item B<-v|--version>
Display version.

View File

@@ -70,6 +70,7 @@ sub process_request {
my $tempfile;
my $dryrun;
my $ignorekernelchk;
my $noupdate;
GetOptions(
'a=s' => \$arch,
@@ -90,6 +91,7 @@ sub process_request {
'tempfile=s' => \$tempfile,
'dryrun' => \$dryrun,
'ignorekernelchk' => \$ignorekernelchk,
'noupdate' => \$noupdate,
);
my $osimagetab;
@@ -301,6 +303,7 @@ sub process_request {
}
if ($driverupdatesrc) { $cmd .= " --driverupdatesrc $driverupdatesrc"; }
if ($ignorekernelchk) { $cmd .= " --ignorekernelchk $ignorekernelchk"; }
if ($noupdate) { $cmd .= " --noupdate $noupdate"; }
if($osfamily eq "sles") {
my @entries = xCAT::TableUtils->get_site_attribute("timezone");

View File

@@ -53,6 +53,7 @@ my $permission; # the permission works only for statelite mode currently
my $tempfile;
my $kerneldir;
my $prompt;
my $noupdate;
sub xdie {
@@ -83,6 +84,7 @@ GetOptions(
'rootimgdir=s' => \$destdir, #internal flag
'interactive' =>\$prompt,
'onlyinitrd' =>\$onlyinitrd,
'noupdate' =>\$noupdate,
);
if (@ARGV > 0) {
@@ -320,11 +322,13 @@ unless ($onlyinitrd) {
}
}
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
# ignore any return code
if (!$noupdate) {
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
# ignore any return code
}
postscripts(); #run 'postscripts'

View File

@@ -57,6 +57,7 @@ my $permission; # the permission works only for statelite mode currently
my $tempfile;
my $kerneldir;
my $prompt;
my $noupdate;
sub xdie {
@@ -87,6 +88,7 @@ GetOptions(
'rootimgdir=s' => \$destdir, #internal flag
'interactive' =>\$prompt,
'onlyinitrd' =>\$onlyinitrd,
'noupdate' =>\$noupdate,
);
if (@ARGV > 0) {
@@ -320,11 +322,13 @@ unless ($onlyinitrd) {
}
}
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
# ignore any return code
if (!$noupdate) {
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
# ignore any return code
}
postscripts(); #run 'postscripts'

View File

@@ -64,6 +64,7 @@ my $permission; # the permission works only for statelite mode currently
my $tempfile;
my $prompt;
my $ignorekernelchk;
my $noupdate;
sub xdie {
@@ -110,6 +111,7 @@ GetOptions(
'interactive' =>\$prompt,
'onlyinitrd' =>\$onlyinitrd,
'ignorekernelchk' => \$ignorekernelchk,
'noupdate' => \$noupdate,
);
if (@ARGV > 0) {
@@ -344,7 +346,7 @@ unless ($onlyinitrd) {
}
}
#Now let's handle extra packages
#Now let's handle extra packages
unless ($imagename) {
$otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist");
unless ($otherpkglist) { $otherpkglist=imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); }
@@ -358,116 +360,115 @@ unless ($onlyinitrd) {
my %repohash;
if (keys(%extra_hash) > 0) {
open($yumconfig,">>","/tmp/genimage.$$.yum.conf");
my $index=1;
foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) {
foreach (keys(%{$extra_hash{$pass}})) {
open($yumconfig,">>","/tmp/genimage.$$.yum.conf");
my $index=1;
foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) {
foreach (keys(%{$extra_hash{$pass}})) {
if($_ eq "INCLUDEBAD") {
print "Unable to open the following pkglist files:\n".join("\n",@{$extra_hash{$pass}{INCLUDEBAD}});
exit 1;
}
if($_ eq "INCLUDEBAD") {
print "Unable to open the following pkglist files:\n".join("\n",@{$extra_hash{$pass}{INCLUDEBAD}});
exit 1;
}
if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;}
print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=file://$srcdir_otherpkgs/$_\ngpgpcheck=0\n\n";
$repohash{$pass}{$index} = 1;
$index++;
my $pa=$extra_hash{$pass}{$_};
$extrapkgnames{$pass} .= " " . join(' ', @$pa);
if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;}
print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=file://$srcdir_otherpkgs/$_\ngpgpcheck=0\n\n";
$repohash{$pass}{$index} = 1;
$index++;
my $pa=$extra_hash{$pass}{$_};
$extrapkgnames{$pass} .= " " . join(' ', @$pa);
}
}
}
close($yumconfig);
$index--;
my $yumcmd_base = "yum $non_interactive -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir/ --disablerepo=* ";
close($yumconfig);
$index--;
my $yumcmd_base = "yum $non_interactive -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir/ --disablerepo=* ";
#yum/rpm/zypper has defect on calculating diskspace usage when installing rpm on a NFS mounted installroot
if(isNFSdir("$rootimg_dir")){
$yumcmd_base .= "--setopt=diskspacecheck=0 ";
}
#yum/rpm/zypper has defect on calculating diskspace usage when installing rpm on a NFS mounted installroot
if(isNFSdir("$rootimg_dir")){
$yumcmd_base .= "--setopt=diskspacecheck=0 ";
}
foreach (0..$repnum) {
$yumcmd_base .= "--enablerepo=$osver-$arch-$_ ";
}
# for (1..$index) {
# $yumcmd .= "--enablerepo=otherpkgs$_ ";
# }
foreach (0..$repnum) {
$yumcmd_base .= "--enablerepo=$osver-$arch-$_ ";
}
# for (1..$index) {
# $yumcmd .= "--enablerepo=otherpkgs$_ ";
# }
foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) {
$yumcmd = $yumcmd_base;
foreach my $repo_index ( keys %{$repohash{$pass}} ) {
$yumcmd .= "--enablerepo=otherpkgs$repo_index ";
}
foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) {
$yumcmd = $yumcmd_base;
foreach my $repo_index ( keys %{$repohash{$pass}} ) {
$yumcmd .= "--enablerepo=otherpkgs$repo_index ";
}
system("$yumcmd clean all");
system("$yumcmd clean all");
my $envlist;
if(exists($extra_hash{$pass}{ENVLIST})){
$envlist = join(' ', @{$extra_hash{$pass}{ENVLIST}});
}
# remove the packages that are specified in the otherpkgs.list files with leading '-'
my $yumcmd_remove= "$yumcmd erase ";
if (exists ($extra_hash{$pass}{'PRE_REMOVE'})) {
my $pa=$extra_hash{$pass}{'PRE_REMOVE'};
my $rm_packges= join(' ', @$pa);
if ($rm_packges) {
print "$envlist $yumcmd_remove $rm_packges\n";
$rc = system("$envlist $yumcmd_remove $rm_packges");
}
}
my $envlist;
if(exists($extra_hash{$pass}{ENVLIST})){
$envlist = join(' ', @{$extra_hash{$pass}{ENVLIST}});
}
# remove the packages that are specified in the otherpkgs.list files with leading '-'
my $yumcmd_remove= "$yumcmd erase ";
if (exists ($extra_hash{$pass}{'PRE_REMOVE'})) {
my $pa=$extra_hash{$pass}{'PRE_REMOVE'};
my $rm_packges= join(' ', @$pa);
if ($rm_packges) {
print "$envlist $yumcmd_remove $rm_packges\n";
$rc = system("$envlist $yumcmd_remove $rm_packges");
}
}
# # mount /proc file system since several packages need it.
# print "mount /proc file system\nchroot $rootimg_dir /bin/mount -t proc proc /proc\n";
# system("chroot $rootimg_dir /bin/mount -t proc proc /proc");
# # mount /proc file system since several packages need it.
# print "mount /proc file system\nchroot $rootimg_dir /bin/mount -t proc proc /proc\n";
# system("chroot $rootimg_dir /bin/mount -t proc proc /proc");
# install extra packages
my $yumcmd_base = $yumcmd;
$yumcmd .= "install ";
# append extra pkg names to yum command
if ($extrapkgnames{$pass}) {
$yumcmd .= " $extrapkgnames{$pass} ";
$yumcmd =~ s/ $/\n/;
# install extra packages
my $yumcmd_base = $yumcmd;
$yumcmd .= "install ";
# append extra pkg names to yum command
if ($extrapkgnames{$pass}) {
$yumcmd .= " $extrapkgnames{$pass} ";
$yumcmd =~ s/ $/\n/;
# debug
#print "yumcmd=$yumcmd\n";
#my $repo=`cat /tmp/genimage.$$.yum.conf`;
#print "repo=$repo";
print "$envlist $yumcmd\n";
my $rc = system("$envlist $yumcmd");
if ($rc) {
print "yum invocation failed\n";
exit 1;
}
} else {
print "No Packages marked for install\n";
}
# debug
#print "yumcmd=$yumcmd\n";
#my $repo=`cat /tmp/genimage.$$.yum.conf`;
#print "repo=$repo";
# # umount /proc file system that just mounted
# print "umount /proc file system\nchroot $rootimg_dir /bin/umount /proc\n";
# system("chroot $rootimg_dir /bin/umount /proc");
print "$envlist $yumcmd\n";
my $rc = system("$envlist $yumcmd");
if ($rc) {
print "yum invocation failed\n";
exit 1;
}
} else {
print "No Packages marked for install\n";
}
# # umount /proc file system that just mounted
# print "umount /proc file system\nchroot $rootimg_dir /bin/umount /proc\n";
# system("chroot $rootimg_dir /bin/umount /proc");
# remove the packages that are specified in the otherpkgs.list files with leading '--'
if (exists ($extra_hash{$pass}{'POST_REMOVE'})) {
my $pa=$extra_hash{$pass}{'POST_REMOVE'};
my $rm_packges= join(' ', @$pa);
if ($rm_packges) {
print "$envlist $yumcmd_remove $rm_packges\n";
$rc = system("$envlist $yumcmd_remove $rm_packges");
}
}
$yumcmd = $yumcmd_base;
# remove the packages that are specified in the otherpkgs.list files with leading '--'
if (exists ($extra_hash{$pass}{'POST_REMOVE'})) {
my $pa=$extra_hash{$pass}{'POST_REMOVE'};
my $rm_packges= join(' ', @$pa);
if ($rm_packges) {
print "$envlist $yumcmd_remove $rm_packges\n";
$rc = system("$envlist $yumcmd_remove $rm_packges");
}
}
$yumcmd = $yumcmd_base;
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
}
}
# ignore any return code
postscripts(); #run 'postscripts'
if (!$noupdate) {
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
$rc = system("$yumcmd_update");
}
}
}
# ignore any return code
postscripts(); #run 'postscripts'
}
#get the rpm version, if the rpm version is different then the db verison may change.

View File

@@ -61,6 +61,7 @@ my $tempfile;
my $prompt;
my $timezone; #the TIMEZONE of the stateless and statelite node
my $ignorekernelchk;
my $noupdate;
sub xdie {
system("rm -rf /tmp/xcatinitrd.$$");
@@ -108,6 +109,7 @@ GetOptions(
'interactive' =>\$prompt,
'onlyinitrd' =>\$onlyinitrd,
'ignorekernelchk' => \$ignorekernelchk,
'noupdate' => \$noupdate,
);
if (@ARGV > 0) {
@@ -559,15 +561,17 @@ unless ($onlyinitrd) {
}
}
# run zypper update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update;
if ($osver_host == 11) {
$yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
} else {
$yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
if (!$noupdate) {
# run zypper update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update;
if ($osver_host == 11) {
$yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
} else {
$yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
}
$rc = system("$yumcmd_update");
}
$rc = system("$yumcmd_update");
}
#remove the old repository for extra packages

View File

@@ -47,6 +47,7 @@ my $srcdir_otherpkgs;
my $otherpkglist;
my $postinstall_filename;
my $rootimg_dir;
my $noupdate;
sub xdie {
system("rm -rf /tmp/xcatinitrd.$$");
@@ -80,6 +81,7 @@ GetOptions(
't=s' => \$tmplimit,
'k=s' => \$kernelver,
'onlyinitrd' =>\$onlyinitrd,
'noupdate' => \$noupdate,
);
if (@ARGV > 0) {
$imagename=$ARGV[0];
@@ -364,11 +366,13 @@ unless ($onlyinitrd) {
$rc = system("$yumcmd_remove $rm_packges");
}
# run zypper update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = "zypper -R $rootimg_dir update ";
$rc = system("$yumcmd_update");
# ignore any return code
if (!$noupdate) {
# run zypper update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = "zypper -R $rootimg_dir update ";
$rc = system("$yumcmd_update");
# ignore any return code
}
postscripts(); #run 'postscripts'

View File

@@ -63,6 +63,7 @@ my $rootimg_dir;
my $permission; # the permission works only for statelite mode currently
my $tempfile;
my $prompt;
my $noupdate;
sub xdie {
@@ -93,6 +94,7 @@ GetOptions(
'rootimgdir=s' => \$destdir, #internal flag
'interactive' =>\$prompt,
'onlyinitrd' =>\$onlyinitrd,
'noupdate' =>\$noupdate,
);
if (@ARGV > 0) {
@@ -463,14 +465,16 @@ unless ($onlyinitrd) {
}
}
# run apt-get upgrade to update any installed debs
# needed when running genimage again after updating software in repositories
#my $aptgetcmd_update = $yumcmd_base . " upgrade ";
my $aptgetcmd_update = $aptgetcmd . "&&". $aptgetcmdby . " upgrade ";
$rc = system("$aptgetcmd_update");
print("Umount /proc, /dev, /sys, pkgdir and otherpkgdir to the rootimg.\n");
umount_chroot($rootimg_dir);
# ignore any return code
if (!$noupdate) {
# run apt-get upgrade to update any installed debs
# needed when running genimage again after updating software in repositories
#my $aptgetcmd_update = $yumcmd_base . " upgrade ";
my $aptgetcmd_update = $aptgetcmd . "&&". $aptgetcmdby . " upgrade ";
$rc = system("$aptgetcmd_update");
print("Umount /proc, /dev, /sys, pkgdir and otherpkgdir to the rootimg.\n");
umount_chroot($rootimg_dir);
# ignore any return code
}
# Add the local repo from MN
my $master = xCAT::TableUtils->get_site_Master();