3398 slim_install should be removed from the CD during finalization
authorKaren Tung <Karen.Tung@Sun.COM>
Fri, 10 Oct 2008 22:55:06 -0700
changeset 259 944b1a40c176
parent 258 513eac86e4e2
child 260 e27885e3515b
3398 slim_install should be removed from the CD during finalization
usr/src/cmd/distro_const/DC-manifest.defval.xml
usr/src/cmd/distro_const/DC-manifest.rng
usr/src/cmd/distro_const/DC_defs.py
usr/src/cmd/distro_const/DC_tm.py
--- a/usr/src/cmd/distro_const/DC-manifest.defval.xml	Fri Oct 10 22:54:23 2008 -0700
+++ b/usr/src/cmd/distro_const/DC-manifest.defval.xml	Fri Oct 10 22:55:06 2008 -0700
@@ -275,6 +275,11 @@
 		val_no_wildcard
 	</validate>
 
+	<validate nodepath="img_params/post_install_remove_packages/pkg/name"
+	    missing="ok">
+		val_no_wildcard
+	</validate>
+
 	<validate nodepath="img_params/live_img_compression/level">
 		val_zero_thru_nine
 	</validate>
--- a/usr/src/cmd/distro_const/DC-manifest.rng	Fri Oct 10 22:54:23 2008 -0700
+++ b/usr/src/cmd/distro_const/DC-manifest.rng	Fri Oct 10 22:55:06 2008 -0700
@@ -180,6 +180,21 @@
 				</oneOrMore>
 			</element>
 
+			<!-- List of packages to remove after all packages
+			     specified in the "packages" section are
+			     installed into the package image area.  
+			     Package name can the name of an IPS incorporation
+			     if such incorporation is in the source repository.
+			     Package attributes and file tags help refine what
+			     will actually be included. -->
+			<optional>
+				<element name="post_install_remove_packages">
+					<oneOrMore>
+						<ref name="nm_pkg"/>
+					</oneOrMore>
+				</element>
+			</optional>
+
 			<!-- Files to be included in the bootroot of all media
 			     delivered by this distribution.  Bootroot contains
 			     the minimal list of contents in order to be able to
--- a/usr/src/cmd/distro_const/DC_defs.py	Fri Oct 10 22:54:23 2008 -0700
+++ b/usr/src/cmd/distro_const/DC_defs.py	Fri Oct 10 22:55:06 2008 -0700
@@ -53,11 +53,17 @@
 POST_INSTALL_ADD_AUTH_MAIN = POST_INSTALL_ADD_AUTH + "/main"
 POST_INSTALL_ADD_AUTH_URL = POST_INSTALL_ADD_AUTH_MAIN + "/url"
 POST_INSTALL_ADD_AUTH_AUTH = POST_INSTALL_ADD_AUTH_MAIN + "/authname"
-PACKAGES = IMG_PARAMS + "/packages"
-PKG =  PACKAGES + "/pkg"
-PKG_NAME =  PKG + "/name"
-PKG_ATTRS =  PKG + "/attrs"
-PKG_TAGS =  PKG + "/tags"
+PKGS_TO_INSTALL = IMG_PARAMS + "/packages"
+PKGS_TO_UNINSTALL = IMG_PARAMS + "/post_install_remove_packages"
+PKG_NAME = "/pkg/name"
+PKG_ATTRS = "/pkg/attrs"
+PKG_TAGS = "/pkg/tags"
+PKG_NAME_INSTALL = PKGS_TO_INSTALL + PKG_NAME
+PKG_NAME_UNINSTALL = PKGS_TO_UNINSTALL + PKG_NAME
+PKG_ATTRS_INSTALL =  PKGS_TO_INSTALL + PKG_ATTRS
+PKG_ATTRS_UNINSTALL =  PKGS_TO_UNINSTALL + PKG_ATTRS
+PKG_TAGS_INSTALL =  PKGS_TO_INSTALL + PKG_TAGS
+PKG_TAGS_UNINSTALL =  PKGS_TO_UNINSTALL + PKG_TAGS
 BOOT_ROOT_CONTENTS = IMG_PARAMS + "/bootroot_contents"
 BOOT_ROOT_CONTENTS_BASE_INCLUDE = BOOT_ROOT_CONTENTS + "/base_include" 
 BOOT_ROOT_CONTENTS_BASE_EXCLUDE = BOOT_ROOT_CONTENTS + "/base_exclude" 
--- a/usr/src/cmd/distro_const/DC_tm.py	Fri Oct 10 22:54:23 2008 -0700
+++ b/usr/src/cmd/distro_const/DC_tm.py	Fri Oct 10 22:55:06 2008 -0700
@@ -149,11 +149,11 @@
 	    (TM_PYTHON_LOG_HANDLER, dc_log)])
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-def DC_ips_retrieve(file_name, mntpt):
+def DC_ips_pkg_op(file_name, mntpt, ips_pkg_op):
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 	dc_log = logging.getLogger(DC_LOGGER_NAME)
 	return tm_perform_transfer([(TM_ATTR_MECHANISM, TM_PERFORM_IPS),
-	    (TM_IPS_ACTION, TM_IPS_RETRIEVE),
+	    (TM_IPS_ACTION, ips_pkg_op),
 	    (TM_IPS_PKGS, file_name),
 	    (TM_IPS_INIT_MNTPT, mntpt),
 	    (TM_PYTHON_LOG_HANDLER, dc_log)])
@@ -272,7 +272,7 @@
 
 	# Read the package list from the manifest and verify
 	# the packages are in the repository(s)
-	pkgs = get_manifest_list(manifest_server_obj, PKG_NAME)
+	pkgs = get_manifest_list(manifest_server_obj, PKG_NAME_INSTALL)
 
 	# Create a temporary file to contain the list of packages
 	# to install.
@@ -297,7 +297,8 @@
 	    
 	# And finally install the designated packages.
 	dc_log.info("Installing the designated packages")
-	status = DC_ips_retrieve(pkg_file_name, mntpt)
+	status = DC_ips_pkg_op(pkg_file_name, mntpt, TM_IPS_RETRIEVE)
+
 	if status and quit_on_pkg_failure == 'true':
 		dc_log.error("Unable to retrieve all of the specified packages")
 		pkgfile.close()
@@ -307,6 +308,34 @@
 	pkgfile.close()
 	os.unlink(pkg_file_name)
 
+	#
+	# Check to see whether there are any packages that are specified
+	# to be removed.  If so, remove them from the package image area.
+	#
+	pkgs = get_manifest_list(manifest_server_obj, PKG_NAME_UNINSTALL)
+	# Create a temporary file to contain the list of packages
+	# to uninstall.
+	pkg_file_name = tmp_dir + "/rm_pkgs%s" % str(os.getpid())
+	try:
+		pkgfile = open(pkg_file_name, 'w+')
+	except IOERROR, e:
+		dc_log.error("Unable to create " + pkg_file_name)
+
+	for pkg in pkgs:
+		pkgfile.write(pkg + '\n')
+	pkgfile.flush()
+
+	dc_log.info("Uninstalling the designated packages")
+	status = DC_ips_pkg_op(pkg_file_name, mntpt, TM_IPS_UNINSTALL)
+
+	pkgfile.close()
+	os.unlink(pkg_file_name)
+
+	if status:
+		dc_log.error("Unable to uninstall all of the specified packages")
+		if quit_on_pkg_failure == 'true':
+			return -1
+
 	# After all the packages are installed, modify the
         # configuration information in the image so that further
         # packages can be downloaded from the Open Solaris repository