7192373 AI installation fails when SVR4 packages are specified in manifest
authornirmal27<Nirmal.Agarwal@oracle.com>
Thu, 23 Aug 2012 00:17:59 -0600
changeset 1766 71fac55960e3
parent 1765 e9fe614297c7
child 1767 b3b03b4b6c9f
7192373 AI installation fails when SVR4 packages are specified in manifest 7183288 Installing SVR4 package with AI stops with an error and prevents from automatic reboot
usr/src/cmd/auto-install/auto_install.py
usr/src/lib/install_transfer/svr4.py
--- a/usr/src/cmd/auto-install/auto_install.py	Mon Aug 20 08:01:51 2012 -0700
+++ b/usr/src/cmd/auto-install/auto_install.py	Thu Aug 23 00:17:59 2012 -0600
@@ -1091,20 +1091,21 @@
                 if ckpt_info is not None:
                     self.logger.debug("Adding Transfer Checkpoint: "
                         "%s, %s, %s" % ckpt_info)
-                    if self.options.zonename and sw.tran_type.upper() == "IPS":
-                        # If we're installing a zone and transfer type is
-                        # IPS, append a kwarg specifying the zone's zonename
-                        # to the transfer checkpoint.  Also append a kwarg
-                        # specifying that we're allowing the checkpoint to
-                        # show progress to stdout.
-                        arg_dict = {"zonename": self.options.zonename,
-                                    "show_stdout": True}
+                    # If transfer type is IPS, append a kwarg specifying
+                    # that we're allowing the checkpoint to show progress
+                    # to stdout.
+                    if sw.tran_type.upper() == "IPS":
+                        arg_dict = {"show_stdout": True}
+
+                        # If we're installing a zone, specify the zone's
+                        # zonename to the IPS transfer checkpoint.
+                        if self.options.zonename:
+                            arg_dict['zonename'] = self.options.zonename
+
                         self.engine.register_checkpoint(*ckpt_info,
-                            kwargs={"arg": arg_dict})
+                                kwargs={"arg": arg_dict})
                     else:
-                        arg_dict = {"show_stdout": True}
-                        self.engine.register_checkpoint(*ckpt_info,
-                            kwargs={"arg": arg_dict})
+                        self.engine.register_checkpoint(*ckpt_info)
                 else:
                     self.logger.error(
                         "Failed to register the softare install: %s"
--- a/usr/src/lib/install_transfer/svr4.py	Mon Aug 20 08:01:51 2012 -0700
+++ b/usr/src/lib/install_transfer/svr4.py	Thu Aug 23 00:17:59 2012 -0600
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 '''Transfer SVR4 checkpoint. Sub-class of the checkpoint class'''
 
@@ -32,7 +32,7 @@
 import urllib2
 
 from osol_install.install_utils import dir_size
-from solaris_install import Popen
+from solaris_install import Popen, CalledProcessError
 from solaris_install.engine.checkpoint import AbstractCheckpoint
 from solaris_install.engine import InstallEngine
 from solaris_install.transfer.info import Args
@@ -76,6 +76,7 @@
     DEFAULT_SIZE = 1024
     PKGADD = "/usr/sbin/pkgadd"
     PKGRM = "/usr/sbin/pkgrm"
+    PKGADM = "/usr/bin/pkgadm"
     SVR4_DS_HDR_START = "# PaCkAgE DaTaStReAm"
     SVR4_DS_HDR_END = "# end of header"
 
@@ -114,6 +115,9 @@
         # Used to set for dry run
         self.dry_run = False
 
+        # set to True when sync required after pkg operation
+        self.sync_db = False
+
         # Use for progress reporting
         self.total_size = -1
         self.give_progress = False
@@ -384,6 +388,16 @@
         if os.path.exists(AbstractSVR4.ADMIN_FILE):
             os.unlink(AbstractSVR4.ADMIN_FILE)
 
+        # sync the contents db file and force contents file server to quit.
+        if self.sync_db:
+            cmd = [AbstractSVR4.PKGADM, 'sync', '-R', self.dst, '-q']
+            try:
+                self.logger.debug("Executing the pkgadm command %s" % cmd) 
+                Popen.check_call(cmd)
+            except CalledProcessError as error:
+                self.logger.warn("pkgadm command failed with following error:"
+                                 "%s", error)
+
     def _transfer(self):
         '''Method to transfer from the source to the destination'''
         if self.give_progress:
@@ -433,6 +447,7 @@
                     pkg_proc = Popen(cmd, shell=False,
                                      stdout=Popen.PIPE,
                                      stderr=Popen.STDOUT)
+                    self.sync_db = True
                     while 1:
                         self.check_cancel_event()
                         pkgoutput = pkg_proc.stdout.readline()