Fix bugs 3284 and 3285 - xCAT-genesis-scripts-x86_64 trying to run mknb when xcatd is not ready
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14921 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1,13 +1,47 @@ | ||||
| # Build the xCAT-genesis-base rpm on a host system. | ||||
| # Option 1:  install the xCAT-genesis-builder rpm (that includes this file) on a system installed with | ||||
| #            the distro you want to use to build xCAT-genesis-base. | ||||
| # Option 2:  untar the root file system of the distro you want to use and then chroot into it and copy | ||||
| #            this whole dir into it somewhere (like /tmp). | ||||
| # Then run this script.  The optional 1st arg should be mcp if you are building against mcp. | ||||
| HOSTOS="$1" | ||||
| DIR=`dirname $0` | ||||
| mkdir -p /usr/share/dracut/modules.d/97xcat | ||||
| cp $DIR/* /usr/share/dracut/modules.d/97xcat | ||||
| DIR=`realpath $DIR` | ||||
|  | ||||
| # get the input files for dracut in the right place | ||||
| DRACUTMODDIR=/usr/share/dracut/modules.d/97xcat | ||||
| mkdir -p $DRACUTMODDIR | ||||
| cp $DIR/* $DRACUTMODDIR | ||||
| if [ "$HOSTOS" = "mcp" ]; then | ||||
| 	mv -f $DRACUTMODDIR/install.$HOSTOS $DRACUTMODDIR/install | ||||
| 	mv -f $DRACUTMODDIR/installkernel.$HOSTOS $DRACUTMODDIR/installkernel | ||||
| fi | ||||
| mkdir -p /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs  | ||||
|  | ||||
| # run dracut | ||||
| echo Creating the initramfs in /tmp/xcatgenesis.$$.rfs using dracut ... | ||||
| dracut -m "xcat base" -f /tmp/xcatgenesis.$$.rfs | ||||
|  | ||||
| echo Expanding the initramfs into /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs ... | ||||
| cd /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs  | ||||
| zcat /tmp/xcatgenesis.$$.rfs|cpio -dumi | ||||
| cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel | ||||
|  | ||||
| # add the kernel | ||||
| if [ "$HOSTOS" = "mcp" ]; then | ||||
| 	echo Adding kernel /boot/vmlinuz-* ... | ||||
| 	cp /boot/vmlinuz-* /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel | ||||
| else | ||||
| 	echo Adding kernel /boot/vmlinuz-`uname -r` ... | ||||
| 	cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel | ||||
| fi | ||||
| cd - | ||||
|  | ||||
| # create tar file | ||||
| echo Tarring /tmp/xcatgenesis.$$/opt into ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 ... | ||||
| cd /tmp/xcatgenesis.$$ | ||||
| tar jcf ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 opt | ||||
|  | ||||
| # build the rpm | ||||
| echo Building xCAT-genesis-base rpm from ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 and $DIR/xCAT-genesis-base.spec ... | ||||
| rpmbuild -ba $DIR/xCAT-genesis-base.spec  | ||||
| rm -rf /usr/share/dracut/modules.d/97xcat | ||||
| rm -rf $DRACUTMODDIR | ||||
|   | ||||
| @@ -56,14 +56,20 @@ rm opt/xcat/share/xcat/netboot/genesis/x86_64/fs/LICENSE.html | ||||
| cd - | ||||
|  | ||||
|  | ||||
| # Since this rpm is being installed/updated, we need to run mknb to combine it with | ||||
| # xCAT-genesis-base-x86_64, but mknb will not work during an initial install of xcat | ||||
| # until the xCAT meta pkg has run xcatconfig or xCATsn has started xcatd.  Use of a trigger | ||||
| # allows us to tell those pkgs to run the code below after they run their %post scriptlets. | ||||
| # (If xCAT or xCATsn is installed already, this trigger will run when xCAT-genesis-scripts | ||||
| # is installed/updated.) | ||||
|  | ||||
| %post | ||||
| if [ "$1" == "2" -o -e /opt/xcat/sbin/mknb ]; then #only on upgrade, or if the rest of xcat is already installed | ||||
| 	if [ -f "/proc/cmdline" ]; then   # prevent running it during install into chroot image | ||||
|    		. /etc/profile.d/xcat.sh | ||||
|    		echo mknb %{tarch}... | ||||
|    		mknb %{tarch} | ||||
|    	fi | ||||
| fi | ||||
| # Touch this file to tell the xCAT and xCATsn rpms that when they install/update they | ||||
| # should run mknb.  Tried to use rpm triggers, but in several cases the trigger would | ||||
| # get run multiple times. | ||||
| #echo "touching /etc/xcat/genesis-scripts-updated" | ||||
| touch /etc/xcat/genesis-scripts-updated | ||||
|  | ||||
|  | ||||
| %Files | ||||
| %defattr(-,root,root) | ||||
|   | ||||
| @@ -1248,19 +1248,19 @@ sub setup_TFTP | ||||
|     } | ||||
|     else | ||||
|     {                         #if not mounting, have to regenerate.... | ||||
|                               #first, run mknb to get nbfs and such going? | ||||
|         my $cmdref; | ||||
|         use xCAT_plugin::mknb; | ||||
|         for my $architecture ("ppc64", "x86", "x86_64") | ||||
|         { | ||||
|             unless (-d "$::XCATROOT/share/xcat/netboot/$architecture") | ||||
|             { | ||||
|                 next; | ||||
|             } | ||||
|             $cmdref->{command}->[0] = "mknb"; | ||||
|             $cmdref->{arg}->[0]     = $architecture; | ||||
|             $doreq->($cmdref, \&xCAT::Client::handle_response); | ||||
|         } | ||||
|         # mknb is now run in xCATsn.spec | ||||
|         #use xCAT_plugin::mknb; | ||||
|         #for my $architecture ("ppc64", "x86", "x86_64") | ||||
|         #{ | ||||
|         #    unless (-d "$::XCATROOT/share/xcat/netboot/$architecture") | ||||
|         #    { | ||||
|         #        next; | ||||
|         #    } | ||||
|         #    $cmdref->{command}->[0] = "mknb"; | ||||
|         #    $cmdref->{arg}->[0]     = $architecture; | ||||
|         #    $doreq->($cmdref, \&xCAT::Client::handle_response); | ||||
|         #} | ||||
|  | ||||
|         #now, run nodeset enact on | ||||
|         my $mactab = xCAT::Table->new('mac'); | ||||
|   | ||||
| @@ -405,9 +405,6 @@ if ($::INITIALINSTALL || $::FORCE) | ||||
|         } | ||||
|      } | ||||
|  | ||||
|      # run mknb - only needed for Intel platforms for now | ||||
|      &mknb; | ||||
|  | ||||
|      # makenetworks and setup http | ||||
|      &makenetworks; | ||||
|      &setuphttp; | ||||
| @@ -548,6 +545,7 @@ if ($::INITIALINSTALL || $::FORCE) | ||||
|      my $linux_note = | ||||
|       "xCAT is now running, it is recommended to tabedit networks \nand set a dynamic ip address range on any networks where nodes \nare to be discovered. Then, run makedhcp -n to create a new dhcpd \nconfiguration file, and \/etc\/init.d\/dhcpd restart. Either examine sample \nconfiguration templates, or write your own, or specify a value per \nnode with nodeadd or tabedit."; | ||||
|      xCAT::MsgUtils->message('I', $linux_note); | ||||
|  | ||||
|    } else { #AIX | ||||
|      # makenetworks | ||||
|      &makenetworks; | ||||
| @@ -559,6 +557,11 @@ if ($::INITIALINSTALL || $::FORCE) | ||||
|  | ||||
| }    #End - more - Linux-only config | ||||
|  | ||||
| # Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot | ||||
| if (($::INITIALINSTALL || $::UPDATEINSTALL) && $::osname eq 'Linux') { | ||||
|   &mknb; | ||||
| } | ||||
|  | ||||
| END | ||||
| { | ||||
|     # Remove xcatconfig itself from the inittab | ||||
| @@ -1838,32 +1841,30 @@ sub setupLinuxexports | ||||
|  | ||||
| =head3    mknb  | ||||
| 	 | ||||
|     creates a network boot root image on Linux  | ||||
|    Creates a network boot root image on Linux  | ||||
|    Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot | ||||
|  | ||||
| =cut | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
| sub mknb | ||||
| { | ||||
|     if ($::arch eq "x86_64" || $::arch eq "x86") | ||||
|     { | ||||
|         foreach my $ar (qw(x86_64)) | ||||
|         { | ||||
|             my $cmd = "XCATBYPASS=Y $::XCATROOT/sbin/mknb $ar"; | ||||
|             my $outref = xCAT::Utils->runcmd("$cmd", 0); | ||||
|             if ($::RUNCMD_RC != 0) | ||||
|             { | ||||
|                 xCAT::MsgUtils->message('E', | ||||
|                           "The mknb $ar command returned error: $::RUNCMD_RC."); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 xCAT::MsgUtils->message('I', | ||||
|                                 "The mknb $ar command completed successfully."); | ||||
|             } | ||||
|         } | ||||
|   # The xCAT-genesis-scripts.spec file touches /etc/xcat/genesis-scripts-updated so we know to run | ||||
|   # mknb here. | ||||
|   if ($::arch eq "x86_64" && (-f '/etc/xcat/genesis-scripts-updated') ) { | ||||
|     unlink '/etc/xcat/genesis-scripts-updated'; | ||||
|     my $cmd = "$::XCATROOT/sbin/mknb $::arch"; | ||||
|     xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-scripts-x86_64 ..."); | ||||
|     #my $outref = xCAT::Utils->runcmd("$cmd", 0); | ||||
|     system($cmd); | ||||
|     if ($? != 0) { | ||||
|       my $rc = $? >> 8; | ||||
|       xCAT::MsgUtils->message('E', "The 'mknb $::arch' command returned error code: $rc."); | ||||
|     } | ||||
|  | ||||
|     else { | ||||
|       xCAT::MsgUtils->message('I', "The 'mknb $::arch' command completed successfully."); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -56,7 +56,7 @@ Requires: conserver-xcat | ||||
| %endif | ||||
|  | ||||
| %ifarch i386 i586 i686 x86 x86_64 | ||||
| Requires: syslinux xCAT-genesis-x86_64 elilo-xcat | ||||
| Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat | ||||
| Requires: ipmitool-xcat >= 1.8.9 | ||||
| Requires: xnba-undi | ||||
| %endif | ||||
|   | ||||
| @@ -51,7 +51,7 @@ Requires: conserver-xcat | ||||
| %endif | ||||
|  | ||||
| %ifarch i386 i586 i686 x86 x86_64 | ||||
| Requires: syslinux xCAT-genesis-x86_64 elilo-xcat | ||||
| Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat | ||||
| Requires: ipmitool-xcat >= 1.8.9 | ||||
| Requires: xnba-undi | ||||
| %endif | ||||
| @@ -177,6 +177,23 @@ fi | ||||
|  | ||||
| %endif | ||||
|  | ||||
| # Run mknb if xCAT-genesis-scripts-x86_64 changed | ||||
| %ifos linux | ||||
| # prevent running it during install into chroot image and only run it if xCAT-genesis-scripts-x86_64 | ||||
| # was recently updated. | ||||
| if [ -f "/proc/cmdline" -a -f "/etc/xcat/genesis-scripts-updated" ]; then | ||||
|   rm -f /etc/xcat/genesis-scripts-updated | ||||
|   # On the SN do not run mknb if we are sharing /tftpboot with the MN | ||||
|   SHAREDTFTP=`/opt/xcat/sbin/tabdump site | grep sharedtftp | cut -d'"' -f 4` | ||||
|   if [ "$SHAREDTFTP" != "1" ]; then | ||||
|       . /etc/profile.d/xcat.sh | ||||
|       echo Running '"'mknb %{tarch}'"', triggered by the installation/update of xCAT-genesis-scripts-x86_64 ... | ||||
|       mknb %{tarch} | ||||
|     fi | ||||
| fi | ||||
| %endif | ||||
|  | ||||
|  | ||||
| %clean | ||||
|  | ||||
| %files | ||||
|   | ||||
		Reference in New Issue
	
	Block a user