3358 Cleanup repo mirroring items in manifest
authorJean McCormack <Jean.McCormack@Sun.COM>
Fri, 10 Oct 2008 07:34:31 -0600
changeset 252 59158e1ccb2b
parent 251 16deab266cdc
child 253 3b0f09bc291d
3358 Cleanup repo mirroring items in manifest 3360 Allowing specifying the default repo and default authority installing pkgs 3668 constructor should use pkg purge-history upon completion
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
usr/src/cmd/distro_const/auto_install/ai_x86_image.xml
usr/src/cmd/distro_const/slim_cd/slim_cd.xml
usr/src/lib/libtransfer/transfer_defs.py
usr/src/lib/libtransfer/transfer_mod.py
usr/src/lib/libtransfer/transfermod.h
--- a/usr/src/cmd/distro_const/DC-manifest.defval.xml	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/DC-manifest.defval.xml	Fri Oct 10 07:34:31 2008 -0600
@@ -62,9 +62,6 @@
 		<deflt_setter ref="deflt_homedir"
 		    module="osol_install.distro_const.DefaultsModule.py"
 		    method="homedir"/>
-		<deflt_setter ref="deflt_distro_repo_path"
-		    module="osol_install.distro_const.DefaultsModule.py"
-		    method="distro_repo_path"/>
 		<deflt_setter ref="deflt_live_img_UID"
 		    module="osol_install.distro_const.DefaultsModule.py"
 		    method="live_img_UID"/>
@@ -109,6 +106,30 @@
 	</default>
 
 	<default nodepath=
+	    "distro_constr_params/pkg_repo_default_authority/main/url"
+	    from="value" type="attribute" missing_parent="create">
+		http://pkg.opensolaris.org:80
+	</default>
+
+	<default nodepath=
+	    "distro_constr_params/pkg_repo_default_authority/main/authname"
+	    from="value" type="attribute" missing_parent="create">
+		opensolaris.org
+	</default>
+
+	<default nodepath=
+	    "distro_constr_params/post_install_repo_default_authority/main/url"
+	    from="value" type="attribute" missing_parent="create">
+		http://pkg.opensolaris.org:80
+	</default>
+
+	<default nodepath=
+	    "distro_constr_params/post_install_repo_default_authority/main/authname"
+	    from="value" type="attribute" missing_parent="create">
+		opensolaris.org
+	</default>
+
+	<default nodepath=
 	    "distro_constr_params/distro_constr_flags/checkpoint_enable"
 	    from="value" type="element" missing_parent="create">
 		true
--- a/usr/src/cmd/distro_const/DC-manifest.rng	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/DC-manifest.rng	Fri Oct 10 07:34:31 2008 -0600
@@ -79,7 +79,7 @@
 			     FMRIs without an explicit authority will be
 			     sought-for here.  -->
 			<element name="pkg_repo_default_authority">
-				<ref name="nm_pkg_repo_auth_contents"/>
+				<ref name="nm_pkg_repo_contents"/>
 			</element>
 
 			<!-- Aliases for additional repos, where to find
@@ -91,7 +91,23 @@
 			     repos if necessary. -->
 			<zeroOrMore>
 				<element name="pkg_repo_addl_authority">
-					<ref name="nm_pkg_repo_auth_contents"/>
+					<ref name="nm_pkg_repo_contents"/>
+				</element>
+			</zeroOrMore>
+
+			<!-- The default repo (and it's mirrors) for the system
+			    to use after the install has completed.  -->
+			<optional>
+				<element name="post_install_repo_default_authority">
+					<ref name="nm_pkg_repo_contents"/>
+				</element>
+			</optional>
+
+			<!-- Additional repos (and their mirrors) for the system
+			    to use after the install has completed.  -->
+			<zeroOrMore>
+				<element name="post_install_repo_addl_authority">
+					<ref name="nm_pkg_repo_contents"/>
 				</element>
 			</zeroOrMore>
 		</interleave>
@@ -219,9 +235,9 @@
 
 			<!-- Directory to build the pkg-image area in.
 			     Will be created if it doesn't exist. -->
-				<element name="build_area">
-					<text/>	<!-- dirpath -->
-				</element>
+			<element name="build_area">
+				<text/>	<!-- dirpath -->
+			</element>
 
 			<!-- Limit of how large the pkg image area can grow.
 			     Zero is unlimited. -->
@@ -431,13 +447,13 @@
 	Define an authority and its mirror backups.
 	=======================================================================
 	-->
-	<define name="nm_pkg_repo_auth_contents">
+	<define name="nm_pkg_repo_contents">
 		<element name="main">
 			<ref name="nm_auth_name"/>
 		</element>
 		<zeroOrMore>
 			<element name="mirror">
-				<ref name="nm_auth_name"/>
+				<ref name="nm_mirror_name"/>
 			</element>
 		</zeroOrMore>
 	</define>
@@ -451,6 +467,12 @@
 		</attribute>
 	</define>
 
+	<define name="nm_mirror_name">
+		<attribute name="url">
+			<text/>
+		</attribute>
+	</define>
+
 
 	<!--
 	=======================================================================
--- a/usr/src/cmd/distro_const/DC_defs.py	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/DC_defs.py	Fri Oct 10 07:34:31 2008 -0600
@@ -37,15 +37,22 @@
 DEFAULT_MAIN_AUTHNAME = DEFAULT_MAIN + "/authname"
 DEFAULT_MAIN_URL = DEFAULT_MAIN + "/url"
 DEFAULT_MIRROR = DEFAULT_REPO + "/mirror"
-DEFAULT_MIRROR_AUTHNAME = DEFAULT_MIRROR + "/authname"
 DEFAULT_MIRROR_URL = DEFAULT_MIRROR + "/url"
 ADD_AUTH = DISTRO_PARAMS + "/pkg_repo_addl_authority"
 ADD_AUTH_MAIN = ADD_AUTH + "/main"
 ADD_AUTH_MAIN_AUTHNAME = ADD_AUTH_MAIN + "/authname"
 ADD_AUTH_MAIN_URL = ADD_AUTH_MAIN + "/url"
 ADD_AUTH_MIRROR = ADD_AUTH + "/mirror"
-ADD_AUTH_MIRROR_AUTHNAME = ADD_AUTH_MIRROR + "/authname"
 ADD_AUTH_MIRROR_URL = ADD_AUTH_MIRROR + "/url"
+POST_INSTALL_DEFAULT = DISTRO_PARAMS + "/post_install_repo_default_authority" 
+POST_INSTALL_DEFAULT_MAIN = POST_INSTALL_DEFAULT + "/main"
+POST_INSTALL_DEFAULT_URL = POST_INSTALL_DEFAULT_MAIN + "/url" 
+POST_INSTALL_DEFAULT_AUTH = POST_INSTALL_DEFAULT_MAIN + "/authname" 
+POST_INSTALL_DEFAULT_MIRROR_URL = POST_INSTALL_DEFAULT + "/mirror/url"
+POST_INSTALL_ADD_AUTH = DISTRO_PARAMS + "/post_install_repo_addl_authority"
+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"
@@ -73,9 +80,10 @@
 FINALIZER_SCRIPT_ARGS = FINALIZER_SCRIPT + "/argslist"
 FINALIZER_SCRIPT_NAME_TO_CHECKPOINT_MESSAGE = FINALIZER_SCRIPT + "[name=\"%s\"]/checkpoint/message"
 FINALIZER_SCRIPT_NAME_TO_CHECKPOINT_NAME = FINALIZER_SCRIPT + "[name=\"%s\"]/checkpoint/name"
-MIRROR_URL_TO_AUTHNAME = DEFAULT_MIRROR + "[url=\"%s\"]/authname"
 ADD_AUTH_URL_TO_AUTHNAME = ADD_AUTH_MAIN + "[url=\"%s\"]/authname"
-ADD_AUTH_MIRROR_URL_TO_AUTHNAME = ADD_AUTH_MIRROR + "[url=\"%s\"]/authname"
+ADD_AUTH_URL_TO_MIRROR_URL = ADD_AUTH_MAIN + "[url=\"%s\"]/../mirror/url"
+POST_INSTALL_ADD_URL_TO_AUTHNAME = POST_INSTALL_ADD_AUTH_MAIN + "[url=\"%s\"]/authname"
+POST_INSTALL_ADD_URL_TO_MIRROR_URL = POST_INSTALL_ADD_AUTH_MAIN + "[url=\"%s\"]/../mirror/url"
 FINALIZER_SCRIPT_NAME_TO_ARGSLIST = FINALIZER_SCRIPT + "[name=\"%s\"]/argslist"
 
 FUTURE_URL = "http://pkg.opensolaris.org:80"
--- a/usr/src/cmd/distro_const/DC_tm.py	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/DC_tm.py	Fri Oct 10 07:34:31 2008 -0600
@@ -31,6 +31,7 @@
 from osol_install.transfer_mod import *
 
 execfile("/usr/lib/python2.4/vendor-packages/osol_install/distro_const/DC_defs.py")
+execfile('/usr/lib/python2.4/vendor-packages/osol_install/transfer_defs.py')
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def DC_ips_init(pkg_url, pkg_auth, mntpt, tmp_dir):
@@ -98,9 +99,18 @@
 		return status
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-def DC_ips_set_auth(alt_url, alt_auth, mntpt, pref_flag=None):
+def DC_ips_set_auth(alt_url, alt_auth, mntpt, mirr_flag=None, pref_flag=None):
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 	dc_log = logging.getLogger(DC_LOGGER_NAME)
+	# If both mirr_flag and pref_flag are set that's an error. We
+	# can't do both at once.
+	if mirr_flag == True and pref_flag == True:
+		dc_log.error("Failed to set-authority on the IPS " \
+		    "image at " + mntpt + "It is illegal to specify " \
+		    "setting a mirror and the preferred authority in the" \
+		    " same command")
+		return -1 
 	tm_argslist = [
 	    (TM_ATTR_MECHANISM, TM_PERFORM_IPS),
 	    (TM_IPS_ACTION, TM_IPS_SET_AUTH),
@@ -108,8 +118,10 @@
 	    (TM_IPS_ALT_AUTH, alt_auth),
 	    (TM_IPS_INIT_MNTPT, mntpt),
 	    (TM_PYTHON_LOG_HANDLER, dc_log)] 
-	if (pref_flag != None):
-		tm_argslist.extend([(TM_IPS_PREF_FLAG, pref_flag)])
+	if (pref_flag == True):
+		tm_argslist.extend([(TM_IPS_PREF_FLAG, TM_IPS_PREFERRED_AUTH)])
+	elif (mirr_flag == True):
+		tm_argslist.extend([(TM_IPS_MIRROR_FLAG, TM_IPS_MIRROR)])
 	status = tm_perform_transfer(tm_argslist)
 	if status == TM_E_SUCCESS:
 		return DC_ips_refresh(mntpt)
@@ -146,90 +158,122 @@
 	    (TM_IPS_INIT_MNTPT, mntpt),
 	    (TM_PYTHON_LOG_HANDLER, dc_log)])
 
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+def DC_ips_cleanup_authorities(auth_list, future_auth, mntpt):
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+	dc_log = logging.getLogger(DC_LOGGER_NAME)
+	for auth in auth_list:
+		if auth != future_auth:
+			status = DC_ips_unset_auth(auth, mntpt)
+			if not status == TM_E_SUCCESS:
+				dc_log.error("Unable to remove the old "\
+				    "authority from the ips image")
+				return -1
+	return 0
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+def DC_ips_purge_hist(mntpt):
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+	dc_log = logging.getLogger(DC_LOGGER_NAME)
+	return tm_perform_transfer([(TM_ATTR_MECHANISM, TM_PERFORM_IPS),
+	    (TM_IPS_ACTION, TM_IPS_PURGE_HIST),
+	    (TM_IPS_INIT_MNTPT, mntpt),
+	    (TM_PYTHON_LOG_HANDLER, dc_log)])
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def DC_populate_pkg_image(mntpt, tmp_dir, manifest_server_obj):
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+	unset_auth_list = []
+
 	dc_log = logging.getLogger(DC_LOGGER_NAME)
 	pkg_url = get_manifest_value(manifest_server_obj,
 	    DEFAULT_MAIN_URL)
 	pkg_auth = get_manifest_value(manifest_server_obj,
 	    DEFAULT_MAIN_AUTHNAME)
-	if pkg_auth == "":
+	if pkg_auth is None:
 		pkg_auth = "opensolaris.org"
-	if pkg_url == "":
+	if pkg_url is None:
 		pkg_url = "http://pkg.opensolaris.org:80"
 
 	quit_on_pkg_failure = get_manifest_value(manifest_server_obj,
 	    STOP_ON_ERR).lower()
 
 	
-	# Initialize the IPS area. Use the default authority. If that
-	# generates an error, then try the mirrors.
+	# Initialize the IPS area. Use the default authority.
 	dc_log.info("Initializing the IPS package image area")
 	status = DC_ips_init(pkg_url, pkg_auth, mntpt, tmp_dir)
-	if status:
-		# The IPS image-create failed, if the user specified any
-		# mirrors, try them.
-		mirror_url_list = get_manifest_list(manifest_server_obj,
-		    DEFAULT_MIRROR_URL)
-		for pkg_url in mirror_url_list:
-			pkg_auth = get_manifest_value(manifest_server_obj,
-			    MIRROR_URL_TO_AUTHNAME % pkg_url)
-			status = DC_ips_init(pkg_url, pkg_auth,  mntpt, tmp_dir)
-			if status == TM_E_SUCCESS:
-				break;	
-		if status:
-			dc_log.error("Unable to initialize the IPS area")
-			return -1
+	if not status == TM_E_SUCCESS:
+		dc_log.error("Unable to initialize the IPS image")
+		return -1
+
+	# Keep a list of authorities to cleanup at the end.
+	unset_auth_list.append(pkg_auth)
+
+	# If the user specified any mirrors for the default authority,
+	# set them in the IPS image using the pkg set-authority -m command. 
+	mirror_url_list = get_manifest_list(manifest_server_obj,
+	   DEFAULT_MIRROR_URL)
+	for mirror_url in mirror_url_list:
+		if len(mirror_url) == 0:
+			continue
+		status = DC_ips_set_auth(mirror_url, pkg_auth, mntpt,
+		    mirr_flag=True)
+		if not status == TM_E_SUCCESS:
+			dc_log.error("Unable to set the IPS image mirror")
+			if quit_on_pkg_failure == 'true':
+				return -1
 
 	# If an alternate authority (authorities) is specified, set
-	# the authority and refresh to make sure it's valid. If not
-	# valid, the alternate authority mirror(s). 
+	# the authority and refresh to make sure it's valid.
 	add_repo_url_list = get_manifest_list(manifest_server_obj,
 	    ADD_AUTH_MAIN_URL)
 	for alt_url in add_repo_url_list:
+		# There can be multiple alternate authorities
+		# Do a set-authority for each one.
+		if len(alt_url) == 0:
+			continue
 		alt_auth = get_manifest_value(manifest_server_obj,
 		    ADD_AUTH_URL_TO_AUTHNAME % alt_url)
-		if not alt_auth is None and not alt_url is None:
-			status = DC_ips_set_auth(alt_url, alt_auth, mntpt)
-			if not status == TM_E_SUCCESS:
-				# First unset the authority that failed
+		if len(alt_auth) == 0:
+			continue
+		status = DC_ips_set_auth(alt_url, alt_auth, mntpt)
+		if not status == TM_E_SUCCESS:
+			dc_log.error("Unable to set "\
+			    "alternate "\
+			    "authority for IPS image")
+			if quit_on_pkg_failure == 'true':
+				return -1
+			else:
+				# If the set-auth fails, sometimes
+				# the authority still is listed
+				# and we need to unset it.
 				DC_ips_unset_auth(alt_auth, mntpt)
+				continue
+
+		# Add onto the list of authorities to cleanup at the end
+		unset_auth_list.append(alt_auth)
 
-				# Setting of the main alternate authority
-				# failed, either through an error setting
-				# the alt authority, or the refresh, try
-				# the mirrors
-				mirror_url_list = get_manifest_list(
-				    manifest_server_obj,
-				    ADD_AUTH_MIRROR_URL) 
-				for alt_url_mirror in mirror_url_list:
-					alt_auth_mirror = \
-					    get_manifest_value(
-					    manifest_server_obj,
-					    ADD_AUTH_MIRROR_URL_TO_AUTHNAME \
-					    % alt_url)
-					status = \
-					    DC_ips_set_auth(
-					    alt_url_mirror,
-					    alt_auth_mirror,
-					    mntpt)
-					if status == TM_E_SUCCESS:
-						break;
-					elif quit_on_pkg_failure == \
-					    'true':
-						dc_log.error("Unable to set "\
-						    "alternate "\
-				       		    "authority for "\
-						    "IPS image")
-						return -1
-					else:
-						DC_ips_unset_auth(
-						    alt_auth_mirror,
-						    mntpt)
+		# Now set the mirrors if any are specified.
+		mirror_url_list = get_manifest_list(
+		    manifest_server_obj,
+		    ADD_AUTH_URL_TO_MIRROR_URL % alt_url) 
+		for alt_url_mirror in mirror_url_list:
+			status = DC_ips_set_auth(
+			    alt_url_mirror,
+			    alt_auth,
+			    mntpt, mirr_flag=True)
+			if not status == TM_E_SUCCESS: 
+				dc_log.error("Unable to set "\
+				    "alternate "\
+		       		    "authority mirror for "\
+				    "IPS image")
+				if quit_on_pkg_failure == 'true':
+					return -1
 
+	# 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)
+
 	# Create a temporary file to contain the list of packages
 	# to install.
 	pkg_file_name = tmp_dir + "/pkgs%s" % str(os.getpid())
@@ -267,20 +311,91 @@
         # configuration information in the image so that further
         # packages can be downloaded from the Open Solaris repository
 
-	# set the opensolaris repository
-        status = DC_ips_set_auth(FUTURE_URL, FUTURE_AUTH, mntpt,
-	    pref_flag=TM_IPS_PREFERRED_AUTH)
+	# set the opensolaris default repository. This is the repository
+	# that will be used by the post installed system.
+	future_url = get_manifest_value(manifest_server_obj,
+	    POST_INSTALL_DEFAULT_URL)
+	future_auth = get_manifest_value(manifest_server_obj,
+	    POST_INSTALL_DEFAULT_AUTH)
+	if future_auth is None:
+		future_auth = "opensolaris.org"
+	if future_url is None:
+		future_url = "http://pkg.opensolaris.org:80"
+
+	status = DC_ips_set_auth(future_url, future_auth, mntpt,
+	    pref_flag=True)
 	if not status == TM_E_SUCCESS:
-		dc_log.error("Unable to set the future repository")
+		dc_log.error("Unable to set the future repository") 
+		return -1
+
+	# unset any authorities not the auth to use in the future
+	if DC_ips_cleanup_authorities(unset_auth_list, future_auth,
+	    mntpt):
 		return -1
 
-	# unset any authorities not the auth to use in the future 
-	if pkg_auth != FUTURE_AUTH:
-		status = DC_ips_unset_auth(pkg_auth, mntpt)
+	# If there are any default mirrors specified, set them.
+	future_mirror_url_list = get_manifest_list(manifest_server_obj,
+	    POST_INSTALL_DEFAULT_MIRROR_URL)
+	for future_url in future_mirror_url_list:
+		if len(future_url) == 0:
+			continue
+		status = DC_ips_set_auth(future_url, future_auth, mntpt,
+		    mirr_flag=True)
+		if not status == TM_E_SUCCESS:
+			dc_log.error("Unable to set the future IPS image mirror")
+			if quit_on_pkg_failure == 'true':
+				return -1
+
+	# If there are any additional repositories and mirrors, set them.
+	future_add_repo_url_list = get_manifest_list(manifest_server_obj,
+	    POST_INSTALL_ADD_AUTH_URL)
+	for future_alt_url in future_add_repo_url_list:
+		if len(future_alt_url) == 0:
+			continue
+		future_alt_auth = get_manifest_value(manifest_server_obj,
+		    POST_INSTALL_ADD_URL_TO_AUTHNAME % future_alt_url)
+		if len(future_alt_auth) == 0:
+			continue
+		status = DC_ips_set_auth(future_alt_url,
+		    future_alt_auth, mntpt)
 		if not status == TM_E_SUCCESS:
-			dc_log.error("Unable to remove the old authority from the ips image")
-			return -1
+			if quit_on_pkg_failure == 'true':
+				dc_log.error("Unable to set "\
+				    "future alternate"\
+				    " authority for "\
+				    "IPS image")
+				return -1
+			else:
+				# If the set-auth fails, sometimes
+				# the authority still is listed
+				# and we need to unset it.
+				DC_ips_unset_auth(
+				    future_alt_auth, mntpt)
+				continue
 
+		# Now set the mirrors if any are specified.
+		future_add_mirror_url_list = get_manifest_list(
+		    manifest_server_obj,
+		    POST_INSTALL_ADD_URL_TO_MIRROR_URL % future_alt_url)
+		for future_add_mirror_url in future_add_mirror_url_list:
+			if len(future_add_mirror_url) == 0:
+				continue
+			status = DC_ips_set_auth(
+			    future_add_mirror_url,
+			    future_alt_auth,
+			    mntpt, mirr_flag=True)
+			if not status == TM_E_SUCCESS:
+				dc_log.error("Unable to set "\
+				    "future alternate "\
+				    "authority mirror for "\
+				    "IPS image")
+				if quit_on_pkg_failure == 'true':
+					return -1
+ 
+	# purge the package history in the IPS image.
+	# This saves us some space.
+	status = DC_ips_purge_hist(mntpt)
+	if status and quit_on_pkg_failure == 'true':
+		dc_log.error("Unable to purge the IPS package history")
+		return -1
 	return 0
-	
-execfile('/usr/lib/python2.4/vendor-packages/osol_install/transfer_defs.py')
--- a/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Fri Oct 10 07:34:31 2008 -0600
@@ -35,6 +35,9 @@
 		<pkg_repo_default_authority>
 			<main url="http://pkg.opensolaris.org" authname="opensolaris.org"/>
 		</pkg_repo_default_authority>
+		<post_install_repo_default_authority>
+			<main url="http://pkg.opensolaris.org" authname="opensolaris.org"/>
+		</post_install_repo_default_authority>
 	</distro_constr_params>
 	<img_params>
 		<packages>
--- a/usr/src/cmd/distro_const/slim_cd/slim_cd.xml	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/cmd/distro_const/slim_cd/slim_cd.xml	Fri Oct 10 07:34:31 2008 -0600
@@ -34,8 +34,10 @@
 		</distro_constr_flags>
 		<pkg_repo_default_authority>
 			<main url="http://pkg.opensolaris.org" authname="opensolaris.org"/>
-			<mirror url="" authname=""/>
 		</pkg_repo_default_authority>
+		<post_install_repo_default_authority>
+			<main url="http://pkg.opensolaris.org" authname="opensolaris.org"/>
+		</post_install_repo_default_authority>
 	</distro_constr_params>
 	<img_params>
 		<packages>
@@ -183,12 +185,6 @@
 				</script>
 				<script name="/usr/share/distro_const/slim_cd/slimcd_grub_a11y">
 					<checkpoint name="grub-a11y" message="Add accessibility items to GRUB menu"/>
-					<stdout_logfile>
-					    /tmp/grub_a11y.out
-					</stdout_logfile>
-					<stderr_logfile>
-					    /tmp/grub_a11y.err
-					</stderr_logfile>
 				</script>
 				<script name="/usr/share/distro_const/create_iso">
 					<checkpoint name="iso" message="ISO image creation"/>
--- a/usr/src/lib/libtransfer/transfer_defs.py	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/lib/libtransfer/transfer_defs.py	Fri Oct 10 07:34:31 2008 -0600
@@ -31,12 +31,15 @@
 TM_IPS_REFRESH = int(tm_defines['TM_IPS_REFRESH'])
 TM_IPS_SET_AUTH = int(tm_defines['TM_IPS_SET_AUTH'])
 TM_IPS_UNSET_AUTH = int(tm_defines['TM_IPS_UNSET_AUTH'])
+TM_IPS_PURGE_HIST = int(tm_defines['TM_IPS_PURGE_HIST'])
 TM_IPS_IMAGE_TYPE = tm_defines['TM_IPS_IMAGE_TYPE'].strip('"')
 TM_IPS_IMAGE_FULL = tm_defines['TM_IPS_IMAGE_FULL'].strip('"')
 TM_IPS_IMAGE_PARTIAL = tm_defines['TM_IPS_IMAGE_PARTIAL'].strip('"')
 TM_IPS_IMAGE_USER = tm_defines['TM_IPS_IMAGE_USER'].strip('"')
 TM_IPS_ALT_AUTH = tm_defines['TM_IPS_ALT_AUTH'].strip('"')
 TM_IPS_PREF_FLAG = tm_defines['TM_IPS_PREF_FLAG'].strip('"')
+TM_IPS_MIRROR_FLAG = tm_defines['TM_IPS_MIRROR_FLAG'].strip('"')
+TM_IPS_MIRROR = tm_defines['TM_IPS_MIRROR'].strip('"')
 TM_IPS_PREFERRED_AUTH = tm_defines['TM_IPS_PREFERRED_AUTH'].strip('"')
 
 TM_IPS_ALT_URL = tm_defines['TM_IPS_ALT_URL'].strip('"')
--- a/usr/src/lib/libtransfer/transfer_mod.py	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/lib/libtransfer/transfer_mod.py	Fri Oct 10 07:34:31 2008 -0600
@@ -784,6 +784,7 @@
 		self._alt_auth = ""
 		self._alt_url = ""
 		self._pref_flag = ""
+		self._mirr_flag = ""
 		self._log_handler = None
 		
 	def prerror(self, msg):
@@ -903,9 +904,19 @@
 			raise TValueError("Specified IPS image area is "
 			    "inaccesible", TM_E_INVALID_IPS_ACT_ATTR)
 
-		cmd = TM_defs.PKG + " -R %s set-authority %s -O %s %s" % \
-		    (self._init_mntpt, self._pref_flag, self._alt_url,
-		    self._alt_auth)
+		if self._pref_flag and self._mirr_flag:
+			raise TValueError("Unable to perform IPS set-authority "
+			    "with -p and -m flags in same transaction",
+			    TM_E_INVALID_IPS_ACT_ATTR)
+
+		if self._mirr_flag:
+			cmd = TM_defs.PKG + " -R %s set-authority %s %s %s" % \
+			    (self._init_mntpt, self._mirr_flag, self._alt_url,
+			    self._alt_auth)
+		else:
+			cmd = TM_defs.PKG + " -R %s set-authority %s -O %s %s" % \
+			    (self._init_mntpt, self._pref_flag, self._alt_url,
+			    self._alt_auth)
 		try:
 			if (self._log_handler != None):
 				status = exec_cmd_outputs_to_log(cmd.split(), self._log_handler)
@@ -1037,6 +1048,36 @@
 		if missingpkg:
 			raise TIPSPkgmissing(TM_E_IPS_PKG_MISSING)
 
+	def perform_ips_purge_hist(self):
+		"""Perform an IPS pkg purge-history.
+		Raises: TAbort if unable to purge the history.
+		"""
+
+		# Check that the init_mntpt really exists. If not, error.
+		try:
+			mst = os.lstat(self._init_mntpt)
+			if not S_ISDIR(mst.st_mode):
+				raise TValueError("Specified IPS image area "
+				    "doesn't exist", TM_E_INVALID_IPS_ACT_ATTR)
+		except OSError:
+			raise TValueError("Specified IPS image area is "
+			    "inaccesible", TM_E_INVALID_IPS_ACT_ATTR)
+
+		cmd = TM_defs.PKG + " -R %s purge-history" % \
+		    (self._init_mntpt)
+		try:
+			if (self._log_handler != None):
+				status = exec_cmd_outputs_to_log(cmd.split(), self._log_handler)
+			else:
+				status = call(cmd, shell=True)
+			if status:
+				raise TAbort("Unable to pkg purge-history "
+				    " the IPS image at " + self._init_mntpt)	
+		except OSError:
+			raise TAbort("Unable to pkg purge-history "
+			    "the IPS image at " + self._init_mntpt,
+			    TM_E_IPS_RETRIEVE_FAILED)
+
 	def perform_transfer(self, args):
 		"""Perform a transfer using IPS.
 		Input: args - specifies what IPS action to
@@ -1066,6 +1107,8 @@
 				self._alt_url = val
 			elif opt == TM_IPS_PREF_FLAG:
 				self._pref_flag = val
+			elif opt == TM_IPS_MIRROR_FLAG:
+				self._mirr_flag = val
 			elif opt == TM_PYTHON_LOG_HANDLER:
 				self._log_handler = val
 			elif opt == "dbgflag":
@@ -1096,6 +1139,8 @@
 			self.perform_ips_refresh()
 		elif self._action == TM_IPS_UNSET_AUTH:
 			self.perform_ips_unset_auth()
+		elif self._action == TM_IPS_PURGE_HIST:
+			self.perform_ips_purge_hist()
 		else:
 			raise TValueError("Invalid TM_IPS_ACTION",
 			    TM_E_INVALID_IPS_ACT_ATTR)
--- a/usr/src/lib/libtransfer/transfermod.h	Thu Oct 09 23:07:48 2008 +0200
+++ b/usr/src/lib/libtransfer/transfermod.h	Fri Oct 10 07:34:31 2008 -0600
@@ -58,6 +58,8 @@
 #define	TM_IPS_ALT_URL			"TM_IPS_ALT_URL"
 #define	TM_IPS_PREF_FLAG		"TM_IPS_PREF_FLAG"
 #define	TM_IPS_PREFERRED_AUTH		"-P"
+#define	TM_IPS_MIRROR_FLAG		"TM_IPS_MIRROR_FLAG"
+#define	TM_IPS_MIRROR			"-m"
 #define	TM_CPIO_ENTIRE_SKIP_FILE_LIST	"TM_CPIO_ENTIRE_SKIP_FILE_LIST"
 #define	TM_CPIO_ARGS			"TM_CPIO_ARGS"
 
@@ -71,6 +73,7 @@
 #define	TM_IPS_REFRESH		3
 #define	TM_IPS_SET_AUTH		4
 #define	TM_IPS_UNSET_AUTH	5
+#define	TM_IPS_PURGE_HIST	6
 
 typedef enum {
 	TM_E_SUCCESS = 0,		/* command succeeded */