15148 Required DC updates to work with Early Manifest Import project changes Build136
authorKaren Tung <Karen.Tung@Sun.COM>
Wed, 24 Mar 2010 16:05:24 -0700
changeset 783 77106ac97619
parent 782 06bc494dfb77
child 784 62dff3ad51a5
15148 Required DC updates to work with Early Manifest Import project changes
usr/src/cmd/distro_const/auto_install/ai_sparc_image.xml
usr/src/cmd/distro_const/auto_install/ai_x86_image.xml
usr/src/cmd/distro_const/slim_cd/all_lang_slim_cd_x86.xml
usr/src/cmd/distro_const/slim_cd/slim_cd_x86.xml
usr/src/cmd/distro_const/text_install/text_mode_sparc.xml
usr/src/cmd/distro_const/text_install/text_mode_x86.xml
usr/src/cmd/distro_const/utils/boot_archive_configure
usr/src/cmd/distro_const/utils/generic_live.xml
usr/src/cmd/distro_const/utils/mkrepo
usr/src/cmd/slim-install/svc/live_fs_include.sh
--- a/usr/src/cmd/distro_const/auto_install/ai_sparc_image.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/auto_install/ai_sparc_image.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -152,12 +152,16 @@
                                     in the order listed.
                                 -->
                                 <smf_service_profile>
+                                        <profile path="/etc/svc/profile/generic_limited_net.xml"
+                                                 use_build_sys_file="false"/>
                                         <profile path="/var/svc/profile/generic_limited_net.xml"
                                                  use_build_sys_file="false"/>
                                         <profile path="/usr/share/distro_const/generic_live.xml"
                                                  use_build_sys_file="true"/>
                                         <profile path="/usr/share/distro_const/auto_install/ai_live.xml"
                                                  use_build_sys_file="true"/>
+                                        <profile path="/etc/svc/profile/ns_files.xml"
+                                                 use_build_sys_file="false"/>
                                         <profile path="/var/svc/profile/ns_files.xml"
                                                  use_build_sys_file="false"/>
                                 </smf_service_profile>
--- a/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/auto_install/ai_x86_image.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -167,12 +167,16 @@
                                     in the order listed.
                                 -->
                                 <smf_service_profile>
+                                        <profile path="/etc/svc/profile/generic_limited_net.xml"
+                                                 use_build_sys_file="false"/>
                                         <profile path="/var/svc/profile/generic_limited_net.xml"
                                                  use_build_sys_file="false"/>
                                         <profile path="/usr/share/distro_const/generic_live.xml"
                                                  use_build_sys_file="true"/>
                                         <profile path="/usr/share/distro_const/auto_install/ai_live.xml"
                                                  use_build_sys_file="true"/>
+                                        <profile path="/etc/svc/profile/ns_files.xml"
+                                                 use_build_sys_file="false"/>
                                         <profile path="/var/svc/profile/ns_files.xml"
                                                  use_build_sys_file="false"/>
                                 </smf_service_profile>
--- a/usr/src/cmd/distro_const/slim_cd/all_lang_slim_cd_x86.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/slim_cd/all_lang_slim_cd_x86.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -172,12 +172,16 @@
 				    in the order listed.
 				-->
 				<smf_service_profile>
+					<profile path="/etc/svc/profile/generic_limited_net.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/generic_limited_net.xml"
 					         use_build_sys_file="false"/>
 					<profile path="/usr/share/distro_const/generic_live.xml"
 					         use_build_sys_file="true"/>
 					<profile path="/usr/share/distro_const/slim_cd/slimcd_live.xml"
 					         use_build_sys_file="true"/>
+					<profile path="/etc/svc/profile/ns_files.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/ns_files.xml"
 					         use_build_sys_file="false"/>
 				</smf_service_profile>
--- a/usr/src/cmd/distro_const/slim_cd/slim_cd_x86.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/slim_cd/slim_cd_x86.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -171,12 +171,16 @@
 				    in the order listed.
 				-->
 				<smf_service_profile>
+					<profile path="/etc/svc/profile/generic_limited_net.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/generic_limited_net.xml"
 					         use_build_sys_file="false"/>
 					<profile path="/usr/share/distro_const/generic_live.xml"
 					         use_build_sys_file="true"/>
 					<profile path="/usr/share/distro_const/slim_cd/slimcd_live.xml"
 					         use_build_sys_file="true"/>
+					<profile path="/etc/svc/profile/ns_files.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/ns_files.xml"
 					         use_build_sys_file="false"/>
 				</smf_service_profile>
--- a/usr/src/cmd/distro_const/text_install/text_mode_sparc.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/text_install/text_mode_sparc.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -154,12 +154,16 @@
 				    root archive in the order listed.
 				-->
 				<smf_service_profile>
+					<profile path="/etc/svc/profile/generic_limited_net.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/generic_limited_net.xml"
 					         use_build_sys_file="false"/>
 					<profile path="/usr/share/distro_const/generic_live.xml"
 					         use_build_sys_file="true"/>
 					<profile path="/usr/share/distro_const/text_install/text_live.xml"
 					         use_build_sys_file="true"/>
+					<profile path="/etc/svc/profile/ns_files.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/ns_files.xml"
 					         use_build_sys_file="false"/>
 				</smf_service_profile>
--- a/usr/src/cmd/distro_const/text_install/text_mode_x86.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/text_install/text_mode_x86.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -168,12 +168,16 @@
 				    root archive in the order listed.
 				-->
 				<smf_service_profile>
+					<profile path="/etc/svc/profile/generic_limited_net.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/generic_limited_net.xml"
 					         use_build_sys_file="false"/>
 					<profile path="/usr/share/distro_const/generic_live.xml"
 					         use_build_sys_file="true"/>
 					<profile path="/usr/share/distro_const/text_install/text_live.xml"
 					         use_build_sys_file="true"/>
+					<profile path="/etc/svc/profile/ns_files.xml"
+					         use_build_sys_file="false"/>
 					<profile path="/var/svc/profile/ns_files.xml"
 					         use_build_sys_file="false"/>
 				</smf_service_profile>
--- a/usr/src/cmd/distro_const/utils/boot_archive_configure	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/utils/boot_archive_configure	Wed Mar 24 16:05:24 2010 -0700
@@ -238,6 +238,10 @@
 export SVCCFG_REPOSITORY=${BA_BUILD}/etc/svc/repository.db
 export LD_LIBRARY_PATH=$PKG_IMG_PATH/lib:$PKG_IMG_PATH/usr/lib:$LD_LIBRARY_PATH
 
+emi=true
+[ -f ${PKG_IMG_PATH}/lib/svc/manifest/system/early-manifest-import.xml ] || \
+	emi=false
+
 # Apply the list of SMF service profiles specified in the manifest
 PROF_NODE_PATH="distro_constr_params/output_image/boot_archive/\
 smf_service_profile/profile"
@@ -251,6 +255,23 @@
 	if [ "${USE_SYS}" != "true" ] ; then
 		DTD_ROOT=${BA_BUILD}
 		SVC_PROF=${PKG_IMG_PATH}/${PROF}
+
+		#
+		# Before Early Manifest Import (EMI) integration,
+		# profiles in the package image area should exist in /var/svc.
+		# After EMI integration, profiles in the package image area
+		# should exist in /etc/svc.  If a specified a profile
+		# is in /etc/svc, and the image to be built is a pre-EMI
+		# image, it will be skipped.  If a specified profile
+		# is in /var/svc, and the image to be built is a post-EMI
+		# image, it will be skipped.  This guarantees 
+		# correct profiles are being applied regardless EMI
+		# functionality exists or not.
+		#
+		echo $SVC_PROF | ${GREP} -q "/etc/svc/"
+		etc_profile=$?
+		[ "${emi}" == "true" -a ${etc_profile} -ne 0 ] && continue
+		[ "${emi}" == "false" -a ${etc_profile} -eq 0 ] && continue
 	else
 		DTD_ROOT="/"
 		SVC_PROF=${PROF}
--- a/usr/src/cmd/distro_const/utils/generic_live.xml	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/utils/generic_live.xml	Wed Mar 24 16:05:24 2010 -0700
@@ -119,6 +119,13 @@
   </service>
 
   <!--
+      Disable early-manifest-import
+  -->
+  <service name='system/early-manifest-import' version='1' type='service'>
+    <instance name='default' enabled='false'/>
+  </service>
+
+  <!--
       Default service instances cloned as live-media instances
   -->
   <service name='system/sysidtool' version='1' type='service'>
--- a/usr/src/cmd/distro_const/utils/mkrepo	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/distro_const/utils/mkrepo	Wed Mar 24 16:05:24 2010 -0700
@@ -45,70 +45,107 @@
 LD_LIBRARY_PATH=$PKG_IMG_PATH/lib:$PKG_IMG_PATH/usr/lib:$LD_LIBRARY_PATH
 export LD_LIBRARY_PATH
 
-X=
 [ -f /lib/svc/share/smf_include.sh ] || exit 1
 
 svccfg_import () {
-	$X $SVCCFG_CMD import $1 2>>/tmp/manifest_import.$$
+	$SVCCFG_CMD import $1 2>>/tmp/manifest_import.$$
 	if [ $? -ne 0 ]; then
 		echo > /dev/msglog
 		echo "WARNING: svccfg import $1 failed" | tee /dev/msglog
 	fi
 }
 
+import_manifests_pre_emi () {
+	#
+	# 2.  Manifest import.  Application directories first, then
+	# site-specific manifests.
+	#
 
-#
-# 2.  Manifest import.  Application directories first, then
-# site-specific manifests.
-#
-nonsite_dirs=`/usr/bin/find ${ROOTDIR}/var/svc/manifest/* -name site -prune -o -type d \
-	-print -prune`
+	nonsite_dirs=`/usr/bin/find ${ROOTDIR}/var/svc/manifest/* -name site -prune \
+	    -o -type d -print -prune`
+
+	nonsite_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan $nonsite_dirs`
+	site_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan ${ROOTDIR}/var/svc/manifest/site`
+
+	manifests="$nonsite_manifests $site_manifests"
+
+	[ -n "$_MFST_DEBUG" ] && {
+		echo "Changed manifests to import:"
+		for m in $manifests; do echo "  $m"; done
+	}
+
+	#
+	# 2b.  Import the manifests while giving a running display of imports on
+	# console, and a final count in the logfile.
+	#
+	if [ -n "$nonsite_manifests" -o -n "$site_manifests" ]; then
+		rm -f /tmp/manifest_import.$$
 
-nonsite_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan $nonsite_dirs`
-site_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan ${ROOTDIR}/var/svc/manifest/site`
+		set -- $manifests
+		backup=`echo "$#/$#" | sed 's/.//g'`
+		fwidth=`echo "$#\c" | wc -c`
+
+		echo "Loading smf(5) service descriptions: \c"
+
+		i=1; n=$#
+		while [ $# -gt 0 ]; do
+			printf "%${fwidth}s/%${fwidth}s" $i $n
+			svccfg_import $1
+			i=`expr $i + 1`
+			shift
+			echo "$backup\c"
+		done
 
-manifests="$nonsite_manifests $site_manifests"
+		echo
+		echo "Loaded $n smf(5) service descriptions"
+		activity=true
 
-[ -n "$_MFST_DEBUG" ] && {
-	echo "Changed manifests to import:"
-	for m in $manifests; do echo "  $m"; done
+		if [ -s /tmp/manifest_import.$$ ]; then
+			echo "svccfg warnings:"
+			cat /tmp/manifest_import.$$
+
+			msg="svccfg import warnings.  See"
+			msg="$msg ${ROOTDIR}/var/svc/log/system-manifest-import:default.log ."
+			echo $msg
+		fi
+		rm -f /tmp/manifest_import.$$
+	fi
 }
 
-#
-# 2b.  Import the manifests while giving a running display of imports on
-# console, and a final count in the logfile.
-#
-if [ -n "$nonsite_manifests" -o -n "$site_manifests" ]; then
-	rm -f /tmp/manifest_import.$$
+import_manifests () {
+	basedir=$1
+	logf="/tmp/manifest_import.$$"
+
+	rm -f $logf
 
-	set -- $manifests
-	backup=`echo "$#/$#" | sed 's/.//g'`
-	fwidth=`echo "$#\c" | wc -c`
+	nonsite_dirs=`/usr/bin/find $basedir/svc/manifest/* -name site \
+	    -prune -o -type d -print -prune`
 
-	echo "Loading smf(5) service descriptions: \c"
+	dirs="$nonsite_dirs $basedir/svc/manifest/site"
+	$SVCCFG_CMD import -p /dev/msglog $dirs > $logf 2>&1
 
-	i=1; n=$#
-	while [ $# -gt 0 ]; do
-		printf "%${fwidth}s/%${fwidth}s" $i $n
-		svccfg_import $1
-		i=`expr $i + 1`
-		shift
-		echo "$backup\c"
-	done
+	if [ -s $logf ]; then
+		grep "smf(5) service descriptions failed to load" $logf > /dev/null 2>&1
+		failures=$?
+		if [ $failures -eq 0 ]; then
+			echo "svccfg warnings:"
+		fi
+		cat $logf
 
-	echo
-	echo "Loaded $n smf(5) service descriptions"
-	activity=true
+		if [ $failures -eq 0 ]; then
+                        msg="svccfg import warnings.  See"
+			msg="$msg ${ROOTDIR}/var/svc/log/system-manifest-import:default.log ."
+			echo $msg
+		fi
+	fi
+	rm -f $logf
+}
 
-	if [ -s /tmp/manifest_import.$$ ]; then
-		echo "svccfg warnings:"
-		cat /tmp/manifest_import.$$
-
-		msg="svccfg import warnings.  See"
-		msg="$msg ${ROOTDIR}/var/svc/log/system-manifest-import:default.log ."
-		echo $msg
-	fi
-	rm -f /tmp/manifest_import.$$
+if [ -f ${ROOTDIR}/lib/svc/manifest/system/early-manifest-import.xml ]; then
+	import_manifests ${ROOTDIR}/lib
+	import_manifests ${ROOTDIR}/var
+else
+	import_manifests_pre_emi
 fi
 
 exit 0
--- a/usr/src/cmd/slim-install/svc/live_fs_include.sh	Wed Mar 24 13:51:14 2010 +0000
+++ b/usr/src/cmd/slim-install/svc/live_fs_include.sh	Wed Mar 24 16:05:24 2010 -0700
@@ -24,6 +24,9 @@
 # Use is subject to license terms.
 #
 
+# Set up the builtin commands.
+builtin cd
+
 #
 # libc_mount
 #
@@ -154,24 +157,29 @@
 #
 apply_platform_profile()
 {
-	if [ ! -f /var/svc/profile/platform.xml ]; then
+	if [ -f /lib/svc/manifest/system/early-manifest-import.xml ]; then
+		SMF_PROF_DIR=/etc/svc/profile
+	else
+		SMF_PROF_DIR=/var/svc/profile
+	fi
+	if [ ! -f ${SMF_PROF_DIR}/platform.xml ]; then
 		this_karch=`uname -m`
 		this_plat=`uname -i`
 
-		if [ -f /var/svc/profile/platform_$this_plat.xml ]; then
+		if [ -f ${SMF_PROF_DIR}/platform_$this_plat.xml ]; then
 			platform_profile=platform_$this_plat.xml
-		elif [ -f /var/svc/profile/platform_$this_karch.xml ]; then
+		elif [ -f ${SMF_PROF_DIR}/platform_$this_karch.xml ]; then
 			platform_profile=platform_$this_karch.xml
 		else
 			platform_profile=platform_none.xml
 		fi
 	fi
 
-        (cd /var/svc/profile; ln -s $platform_profile platform.xml)
+        (cd ${SMF_PROF_DIR}; ln -s $platform_profile platform.xml)
 
-	/usr/sbin/svccfg apply /var/svc/profile/platform.xml
+	/usr/sbin/svccfg apply ${SMF_PROF_DIR}/platform.xml
 	if [ $? -ne 0 ]; then
-		echo "Failed to apply /var/svc/profile/platform.xml" > /dev/msglog
+		echo "Failed to apply ${SMF_PROF_DIR}/platform.xml" > /dev/msglog
 	fi
 
 }