From 2ade33338a5d28d2294f63fc3dbd52a3c6159bd1 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 21 Nov 2013 05:17:23 -0500 Subject: [PATCH] defect 3917: add support for running of postinstall script in mic genimage. The rootimage root is changed to overlay/rootimg from overlay/package --- xCAT-server/lib/xcat/plugins/mic.pm | 24 ++++++----- xCAT-server/sbin/configmic | 6 ++- xCAT-server/share/xcat/netboot/mic/genimage | 47 +++++++++++++++++---- 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mic.pm b/xCAT-server/lib/xcat/plugins/mic.pm index c6a12df94..1037c69b3 100644 --- a/xCAT-server/lib/xcat/plugins/mic.pm +++ b/xCAT-server/lib/xcat/plugins/mic.pm @@ -412,6 +412,8 @@ sub copytar { # creae the default dirs in the mpss image dir mkpath ("$destdir/common"); + mkpath ("$destdir/overlay/rootimg"); + mkpath ("$destdir/overlay/simple"); mkpath ("$destdir/overlay/package"); mkpath ("$destdir/overlay/rpm"); `/bin/touch "$destdir/common.filelist"`; @@ -477,12 +479,13 @@ sub copytar { } my $otherpkgdir = "$installroot/post/otherpkgs/mic$mpssver/x86_64"; + my $rootimgdir = "$destdir/overlay"; # set a default package list my $pkglist = "$::XCATROOT/share/xcat/netboot/mic/compute.pkglist"; - $litab->setAttribs({'imagename' => $imagename}, {'pkgdir' => $destdir, 'pkglist' => $pkglist, 'otherpkgdir' => $otherpkgdir}); + $litab->setAttribs({'imagename' => $imagename}, {'pkgdir' => $destdir, 'pkglist' => $pkglist, 'otherpkgdir' => $otherpkgdir, 'rootimgdir' => $rootimgdir}); - xCAT::MsgUtils->message("I", {data=>["The image $imagename has been created."]}, $callback); + xCAT::MsgUtils->message("I", {data=>["The image $imagename is created."]}, $callback); #rmtree ($tmpdir); } @@ -830,7 +833,7 @@ sub nodeset { # | `--rpm # | `--simple # | |--simple.cfg (the file must be multiple lines of 'a->b' format; 'a' is dir name in simple/, 'b' is the path on mic for 'a' - # | `--package + # | `--package (2.8.3) / rootimg (2.8.4 and later) # | |--the base file for fs # | `--opt/mic # | |--yy.filelist @@ -839,10 +842,10 @@ sub nodeset { # | `--xx #the system dir (system dir includes the files # which generated by genimage command, and will be copied to mic osimage separated) - if (! -d "$osimage{$osimg}/system") { - xCAT::MsgUtils->message("E", {error=>["Missed system directory in $osimage{$osimg}. Did you miss to run genimage command?"], errorcode=>["1"]}, $callback); - return; - } + if (! -d "$osimage{$osimg}/system") { + xCAT::MsgUtils->message("E", {error=>["Missed system directory in $osimage{$osimg}. Did you miss to run genimage command?"], errorcode=>["1"]}, $callback); + return; + } if (defined ($imghash{$osimg}{'ollist'})) { push @cfgfile, "overlay=$imghash{$osimg}{'ollist'}"; } else { @@ -862,12 +865,13 @@ sub nodeset { } } } - } elsif ($objname eq "package") { - my @pfl = <$osimage{$osimg}/overlay/package/opt/mic/*.filelist>; + } elsif ($objname eq "package" || $objname eq "rootimg") { + my @pfl = <$osimage{$osimg}/overlay/$objname/opt/mic/*.filelist>; foreach my $filelist (@pfl) { $filelist = basename($filelist); if ($filelist =~ /(.+)\.filelist/) { - $ollist .= ",pfilelist:$1"; + $ollist .= ",pfilelist:$1" if ($objname eq "package"); + $ollist .= ",ofilelist:$1" if ($objname eq "rootimg"); } } } diff --git a/xCAT-server/sbin/configmic b/xCAT-server/sbin/configmic index bfa6068a5..b6fcdddb2 100755 --- a/xCAT-server/sbin/configmic +++ b/xCAT-server/sbin/configmic @@ -164,7 +164,7 @@ if ($rc) { # | `--rpm # | `--simple # | |--simple.cfg (the file must be multiple lines of 'a->b' format; 'a' is dir name in simple/, 'b' is the path on mic for 'a' -# | `--package +# | `--package (2.8.3) / rootimg (2.8.4 and later) # | |--the base file for fs # | `--opt/mic # | |--yy.filelist @@ -225,7 +225,9 @@ my @ols = split (/,/, $overlay); foreach (@ols) { if (/^filelist:(.+)/) { $cmd = "micctrl --overlay=Filelist --source=$micmnt/overlay/$1/ --target=$micmnt/overlay/$1.filelist --state=on $miclist"; - } elsif (/^pfilelist:(.+)/) { + } elsif (/^ofilelist:(.+)/) { # for 2.8.4 and later + $cmd = "micctrl --overlay=Filelist --source=$micmnt/overlay/rootimg/ --target=$micmnt/overlay/rootimg/opt/mic/$1.filelist --state=on $miclist"; + } elsif (/^pfilelist:(.+)/) { # only for 2.8.3 $cmd = "micctrl --overlay=Filelist --source=$micmnt/overlay/package/ --target=$micmnt/overlay/package/opt/mic/$1.filelist --state=on $miclist"; } elsif (/^rpm:(.+)/) { $cmd = "micctrl --overlay=RPM --source=$micmnt/overlay/rpm/ --state=on $miclist"; diff --git a/xCAT-server/share/xcat/netboot/mic/genimage b/xCAT-server/share/xcat/netboot/mic/genimage index 6e1e52723..82a229d00 100755 --- a/xCAT-server/share/xcat/netboot/mic/genimage +++ b/xCAT-server/share/xcat/netboot/mic/genimage @@ -34,6 +34,12 @@ my $otherpkglist; my $rootimg_dir; my $srcdir_otherpkgs; my $tempfile; +my $postinstall; +my $rootimgdir; +my $prompt; + +my $imagename; + GetOptions( 'a=s' => \$arch, 'p=s' => \$profile, @@ -42,13 +48,21 @@ GetOptions( 'srcdir=s' => \$srcdir, 'otherpkglist=s' => \$otherpkglist, 'otherpkgdir=s' => \$srcdir_otherpkgs, - 'tempfile=s' =>\$tempfile, + 'tempfile=s' => \$tempfile, + 'postinstall=s' => \$postinstall, + 'rootimgdir=s' => \$rootimgdir, + 'imagename=s' => \$imagename, + 'interactive' =>\$prompt, ); -$rootimg_dir = "$srcdir/overlay/package/"; +if ($rootimgdir) { + $rootimg_dir = $rootimgdir."/rootimg"; # for 2.8.4 and later +} else { + $rootimg_dir = "$srcdir/overlay/package"; # for 2.8.3 that rootimgdir was not set by default +} + my @yumdirs; -my $imagename; -if (@ARGV > 0) { +if (!$imagename && @ARGV > 0) { $imagename=$ARGV[0]; } unless ($imagename) { @@ -64,6 +78,13 @@ sub isyumdir { } } +# creae default paths +mkpath "$srcdir/common"; +mkpath "$srcdir/overlay/rootimg"; +mkpath "$srcdir/overlay/simple"; +mkpath "$srcdir/overlay/package"; +mkpath "$srcdir/overlay/rpm"; + if ($otherpkglist) { # get the distroname @@ -120,10 +141,9 @@ if ($otherpkglist) { my $pass; 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; + 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;} @@ -202,7 +222,18 @@ if ($otherpkglist) { } } - +# run postinstall scripts +foreach my $post ( split /,/, $postinstall) { + if ( !-x $post) { + print "postinstall script $post is not executable\n"; + exit 1; + } + my $rc = system($postinstall, $rootimg_dir, $osver, $arch, $profile); + if($rc) { + print "postinstall script $post failed\n"; + exit 1; + } +} my $fsdir = "$srcdir/";