diff --git a/xCAT-client/bin/genimage b/xCAT-client/bin/genimage index 1bcfe4216..2e00040b0 100755 --- a/xCAT-client/bin/genimage +++ b/xCAT-client/bin/genimage @@ -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 [-a ] -p -i -n [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun]'."\n\n"; - print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] '."\n\n"; + print ' genimage -o [-a ] -p -i -n [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] [--noupdate]'."\n\n"; + print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] [--noupdate] '."\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"; diff --git a/xCAT-client/pods/man1/genimage.1.pod b/xCAT-client/pods/man1/genimage.1.pod index fdd3f5f88..7f8f17f02 100644 --- a/xCAT-client/pods/man1/genimage.1.pod +++ b/xCAT-client/pods/man1/genimage.1.pod @@ -6,9 +6,9 @@ B - Generates a stateless image to be used for a diskless install. B -B [B<-o> I] [B<-a> I] [B<-p> I] [B<-i> I] [B<-n> I] [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] [B<--ignorekernelchk>] I +B [B<-o> I] [B<-a> I] [B<-p> I] [B<-i> I] [B<-n> I] [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] [B<--ignorekernelchk>] [B<--noupdate>] I -B B<-o> I [B<-a> I] B<-p> I B<-i> I B<-n> I [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] +B B<-o> I [B<-a> I] B<-p> I B<-i> I B<-n> I [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] [B<--noupdate>] B [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. diff --git a/xCAT-server/lib/xcat/plugins/genimage.pm b/xCAT-server/lib/xcat/plugins/genimage.pm index d43ec2a05..5e66879d2 100644 --- a/xCAT-server/lib/xcat/plugins/genimage.pm +++ b/xCAT-server/lib/xcat/plugins/genimage.pm @@ -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"); diff --git a/xCAT-server/share/xcat/netboot/debian/genimage b/xCAT-server/share/xcat/netboot/debian/genimage index d1913a0ea..162355fbd 100755 --- a/xCAT-server/share/xcat/netboot/debian/genimage +++ b/xCAT-server/share/xcat/netboot/debian/genimage @@ -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' diff --git a/xCAT-server/share/xcat/netboot/fedora12/genimage b/xCAT-server/share/xcat/netboot/fedora12/genimage index 74ba09017..d00151217 100755 --- a/xCAT-server/share/xcat/netboot/fedora12/genimage +++ b/xCAT-server/share/xcat/netboot/fedora12/genimage @@ -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' diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index e142715bf..81ded62ec 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -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. diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index daedcca5a..80e2782ba 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -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 diff --git a/xCAT-server/share/xcat/netboot/suse/genimage b/xCAT-server/share/xcat/netboot/suse/genimage index 01c55a785..69f06c020 100755 --- a/xCAT-server/share/xcat/netboot/suse/genimage +++ b/xCAT-server/share/xcat/netboot/suse/genimage @@ -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' diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index efe37096c..2c3415189 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -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();